Wrapping Your Head Around Ladder Logic

The most important thing about learning to program PLCs is understanding ladder logic. Unlike other computer languages, ladder logic is graphical, meaning that the program is literally drawn out rather than typed. This can be confusing to programmers who come from a background in traditional languages, such as C or C++. You don’t get anything too fancy with ladder logic; rather, the graphical program is meant to represent a facsimile of a wiring diagram for traditional relay logic. Relays were used, and still are, to control various systems and these control systems are often very complicated. Engineers needed a way to represent the complicated arrangements and relationships in a relay control system, so the ladder logic representation was developed to make things clear. You will find schematic diagrams for relay racks written out using ladder logic notation to this day.

The popularity and longevity of ladder logic notation can be traced to its ease of use. Ladder logic is easy for both a human and a machine controller to process. The simple visual format helps programmers parse the logic sequence at a glance, and easily catch errors before they are implemented. This offers a middle ground between diagrams using full-grammar language (which is easy for humans to read but difficult to translate for the controller), and diagrams using machine code, which is easy for the controller to parse, but can be nearly incomprehensible to humans.

A relay is simply a switch that can be electrically actuated. So, before the days of PLCs, all control systems consisted of large racks of relays all wired to turn each other off and on according to the design of the system. Essentially the program was hard-wired into the physical relays themselves, and this approach is still preferred for some special applications. However, a giant rack of relays is not practical for most control systems, which is why the PLC was first developed as a direct replacement. Instead of opening up a panel to rewire a bunch of contracts, a PLC program can be altered simply and easily by a programmer, and then deployed to the device. The fundamental notation has not changed since the days of relay logic, but many new symbols and capabilities have been introduced, and PLCs have evolved.

PLC example
PLC example

At its heart, a PLC is a small, rugged computer, designed to replace giant banks of impractical relays. The program for a PLC can be thought of as a fully customizable relay rack contained entirely inside the device. It’s best to imagine relay logic in physical terms as if it were an actual schematic. The basic elements of ladder logic are designed to resemble an actual electrical circuit.

To begin, a PLC program is read from left to right and top to bottom. It resembles a ladder where the left rail is the high side, where the power comes from, and the right rail is essentially ground. In between are the rungs of the ladder, which represent the individual instructions of the PLC program. The two most basic symbols in ladder logic are the contact symbol and the coil symbol.

The contact symbol (Left), and coil symbol (Right)
The contact symbol (Left), and coil symbol (Right)

The amazing thing about relay logic is that very complex systems can be created with just these two simple elements. The contact’s job is to complete the circuit from high to ground. There are two types of contact, normally open, meaning that it behaves like a switch that is off by default, and normally closed, which is on by default. They behave as inputs and can be instructed to open or close in many ways such as a button, sensor, timer, counter, or most importantly by a coil. The coil is responsible for opening or closing contacts elsewhere in the circuit or at the outputs of the system. When energized, any contacts that are paired with the coil will be actuated.

The first and simplest program that everyone learns when starting out with PLC programming is the start and stop button example. Momentary switches are made to make contact only while the switch is pressed, they are most commonly found in the form of a button. Say we want to send power to a motor and we would like to start the motor using a switch. Ideally, we would like to have one big green button to start the motor and another big red button to stop it. But these buttons are momentary switches and they only send power while the buttons are held down, so how can we keep the motor running after we release the button? This is where relays come in. The great thing about relays is their ability to take momentary electric signals and turn that into all kinds of useful actions. Now we should mention, there are no actual relays inside a PLC, but the device is instead made to emulate the same capabilities as a traditional relay control system.

To begin the example, from left to right, two contacts are placed in series on the first rung, the first is normally open followed by a normally closed contact. The normally open contact is tied to an input connected to a momentary button that will serve as the start button. Likewise, the normally closed contact will be tied to the stop button. A coil is then placed after the two contacts which actuate the output to our motor. Finally, and this is the most important part, a third contact is placed in parallel with the start button and this contact is also actuated by the motor coil.

PLC Programming Example
PLC Programming Example

So now when the start button is pressed, power will go to the motor coil across the stop button, since that is normally closed. The motor coil will energize and send power to the motor, but at the same time the parallel motor contact will close and bypass the start button to keep the power flowing. The motor will stay on until the stop button is pressed which breaks the connection to the motor coil and releases the motor contact. This is the first example of what is known as a latching and unlatching system. The start button triggers the latching contact, and the stop button unlatches it. This is such a common configuration that specialized latching and unlatching coils are actually included.

Those familiar with traditional programming might recognize that contacts are a bit like “IF” statements. Placing them in a series is the equivalent of a logical “AND” statement while placing them in parallel is the equivalent of an “OR” statement. If a contact is normally closed, that could be thought of as equivalent to NOT normally open. So, if we were to read this rung as a traditional logical program it would sound something like this: “IF (start button OR motor contact) AND NOT stop button THEN motor coil.” So now we see why this is known as ladder logic. The contacts themselves are Boolean values and their arrangement forms the Boolean operators.

There are many more features and symbols of Allen Bradley PLCs that go well beyond simple contact and coil programs. There are tons of specialized modules for timers, counters, and analog sensors, which can add tremendous capabilities to your automation system. These are just the basics. Allen Bradley PLCs also include support for remote communication and other advanced features. Once you master the basics of ladder logic, you will be able to integrate more and more complexity into your automation systems and take full advantage of the features that modern PLCs have to offer.

For more information or to purchase a PLC, please visit our homepage here.

dosupply
Posted on:
DO Supply Inc. makes no representations as to the completeness, validity, correctness, suitability, or accuracy of any information on this website and will not be liable for any delays, omissions, or errors in this information or any losses, injuries, or damages arising from its display or use. All the information on this website is provided on an "as-is" basis. It is the reader’s responsibility to verify their own facts. DO Supply Inc. is not an authorized distributor and is not in anyway affiliated with Rockwell Automation. DO Supply Inc. makes no representation as to your ability or right to download, obtain, or use any firmware provided by the product's manufacturer. To the extent you wish to use such firmware, it is your responsibility to comply with the terms of any applicable license or other such agreement related to the download, installation, or use of the firmware. DO Supply makes no representation that the version of the firmware that is installed on any product it sells is appropriate for your needs or use. Further, DO Supply Inc. does not sell, re-sell, or license software that may be needed to operate certain hardware and customers must obtain any necessary software licensing, maintenance, or upgrades from the manufacturer or other authorized source. To the extent any of the products sold by DO Supply requires software for operation, you acknowledge that DO Supply does not sell or license such software and that it is solely your responsibility to obtain the software or a proper license to use it from authorized sources.
Post author

Leave a comment

Your email address will not be published. Required fields are marked *