Ecmweb 8160 Ladder Logic Pr
Ecmweb 8160 Ladder Logic Pr
Ecmweb 8160 Ladder Logic Pr
Ecmweb 8160 Ladder Logic Pr
Ecmweb 8160 Ladder Logic Pr

What is Ladder Logic?

April 22, 2016
A basic introduction helps establish a fundamental understanding of this subject.

Programmable logic controllers (PLCs) are used extensively throughout the world. Over time, they have advanced to become more user-friendly, efficient, smaller, and less expensive. Different types of programming languages have also been developed for PLCs, but the most frequently used is known as ladder logic.

The structure of ladder logic

The structure behind ladder logic is based on the electrical ladder diagrams that were used with relay logic (see Relay Logic on page C7). These diagrams documented how connections between devices were made on relay panels. They are called “ladder” diagrams because they are constructed in a way that resembles a ladder with two vertical rails and rungs between them. The positive power rail (on the left) flows to the negative power rail (on the right) through the physical devices connected on the rungs. In the example shown in Fig. 1, “PB” stands for pushbutton,”and “CR” stands for control relay. “L1” is a light, and “M1” is a motor.

Fig. 1. Note how this electrical diagram resembles the shape of a ladder with two separate rails and rungs between them.

Similarities with ladder diagrams

Ladder logic was designed to have the same look and feel as ladder diagrams, but with ladder logic the physical contacts and coils are replaced with memory bits. Let’s run through a ladder logic example so you can see how it works.

Fig. 2. Ladder logic uses memory locations rather than hard-wired logic.

For the program shown in Fig. 2, we took the relay logic’s ladder diagram from Fig. 1 and duplicated it with ladder logic — no more hard-wired logic but memory locations instead. Some of these memory locations are used internally, and others are used with external inputs and outputs. To monitor and control real-world devices, they will need to be wired to I/O modules. For this PLC, these inputs and outputs are assigned to X and Y memory addresses like the X001 seen with PB1. This normally open contact’s state is read from the input on the I/O module where the physical pushbutton is connected. On the other hand, each Y bit will have an output device wired to it, as seen with the light controlled by Y001. All of the other locations are assigned to internal bits that we can use as needed. Note: Today’s PLC CPUs offer many types of functions, not just simple contacts and coils. Math, shift registers, drum sequencers, etc., are available to aid in your programming. However, for now, we’ll keep it simple.

Execution of ladder logic

The CPU will interpret the logic in a sequential order. Starting at the top left of the program, the CPU will work its way down the rail, executing each rung or sub-rung from left to right. So if PB1 is pressed, the CPU will turn ON CR1. Since CR1 has changed states, in rung 3 the CPU will activate CR3. CR3’s normally closed state is used in rung 4, so the CPU will then turn OFF L1. Even though we still refer to coils and contacts in ladder logic, remember that they are memory representations, not actual devices. Once the CPU reaches the last rung, it will loop back to the start of the program and run it all over again. This process will continue as long as the CPU is powered and in the RUN mode. The time it takes the CPU to loop back to the beginning is known as scan time. Scan time also includes the time it takes the CPU to read the inputs and update the outputs, and it can be important to applications where timing is critical. Subroutines and special purpose I/O modules can be used to help reduce the scan time, if needed.

The logic behind the ladder

So what logic can ladder logic actually perform? With the increasing demand for functionality and ease of use, many of today’s PLCs incorporate function blocks with ladder logic. The structure of the program is still a ladder with the more complex instructions being function blocks. So to answer the question, let’s look at a few examples:

• Boolean logic: The ON/OFF, TRUE/FALSE algebra of binary systems. The basics of which are AND, OR, and NOT operators. To put it simply, rung 5 in our code needs CR1(C1) AND CR2(C2) to turn ON motor M1 (Y002).

• Timing: Timer instructions are available to allow for ON-delayed or OFF-delayed events. Once triggered, the timer will turn its associated output ON (on-delay) or OFF (off-delay) after the set time has elapsed.

• Counting: Count-up and count-down functions increase or decrease the counter value on every transition of the input.

• Comparisons: Compare instructions are available to determine if values are less than, equal to, or greater than each other.

• Math: These instructions not only allow for the simple addition and subtraction but also for more complex operations like tangents, square roots, etc.

• Special functions: PID loops, communication instructions, shift registers, drum sequencers, ramp generators, etc.

This article was meant to serve as an introduction to ladder logic. It only begins to scratch the surface of the many functions/applications of this programming language.   

A technical marketer with AutomationDirect in Cumming, Ga., Dehner has a BS in electrical engineering and over 15 years of experience working with electrical systems, 11 of which have been focused on implementing control systems in the industrial automation field. He can be reached at [email protected].

SIDEBAR: Relay Logic

Using a combination of switches, relays coils, and contacts is referred to as relay logic. Relay logic is a dependable controls method, a method still in limited use today. But the cost associated with it in terms of time-consuming logic changes, failures over time due to mechanical switching, and extensive wiring and space requirements forced many industries to look elsewhere for their control needs. This led them to the PLC.

About the Author

Bill Dehner | Technical Marketer

A technical marketer with AutomationDirect in Cumming, Ga., Dehner has a BS in electrical engineering and over 15 years of experience working with electrical systems, 11 of which have been focused on implementing control systems in the industrial automation field. He can be reached at [email protected].

Voice your opinion!

To join the conversation, and become an exclusive member of EC&M, create an account today!

Sponsored Recommendations

Electrical Conduit Comparison Chart

CHAMPION FIBERGLASS electrical conduit is a lightweight, durable option that provides lasting savings when compared to other materials. Compare electrical conduit types including...

Fiberglass Electrical Conduit Chemical Resistance Chart

This information is provided solely as a guide since it is impossible to anticipate all individual site conditions. For specific applications which are not covered in this guide...

Considerations for Direct Burial Conduit

Installation type plays a key role in the type of conduit selected for electrical systems in industrial construction projects. Above ground, below ground, direct buried, encased...

How to Calculate Labor Costs

Most important to accurately estimating labor costs is knowing the approximate hours required for project completion. Learn how to calculate electrical labor cost.