Ladder Logic 101: Where do I start?

For those who are just getting into writing ladder logic and have maybe taken a few classes or seen some examples, it is quite simple to write your own template.

By Frank Lamb October 22, 2014

Soon after I started my controls company in 1996 and started doing work for NAS, I found that I needed help. My first couple of employees were ITT tech students who worked for me part time building panels and wiring machines, and one in particular showed some initiative and wanted to learn how to program PLCs. At first he would get involved on start-ups, checking I/O online, doing simple debug and making minor changes, but over the course of a couple of years he was able to take a program outline, look at a few examples and write programs himself. Part of this may be simply because he had a lot of interest in the field which was why he had gone to school in the first place.

Over time I hired several full time engineers, most with experience in a maintenance role but not so much in design. It became a challenge to ensure that everyone followed the same general outline which made writing a template a necessity. The template was basically a partially written program with some generic rungs of logic establishing mode control for the machine, showing fault examples and creating I/O buffer type rungs.

Before I used a template though I remember one engineer who didn’t feel he had the ability to generate a program. He could modify existing programs, was an excellent troubleshooter but lacked the confidence to start a program himself. To ease him into programming I started out by writing him a few rungs of logic on graph paper and having him type them in, he would come by my office and ask a few questions and before you knew it he became an excellent programmer.

For those who are just getting into writing ladder logic and have maybe taken a few classes or seen some examples, it is quite simple to write your own template. A great way to start is to write a few mutually latching/unlatching rungs for maintenance/manual mode and auto mode, write a couple of either latching or numerical register comparison fault rungs, say a generic timer rung and a generic E-Stop rung, establish a fault bit and put it into your mode logic in the appropriate place. Write a few generic input and output buffer rungs with your mode logic in the output rungs. Your inputs driving some kind of tag such as InX_status can constitute your input buffer rungs. Separating these into separate subroutines (or function calls/blocks) can make them easy to copy to other programs later. Even a simple auto sequence with perhaps a first and last step and a single generic middle step using some of your generic I/O bits can be helpful. Again, keeping them in separate sections or routines can be very useful later.

For a long time I kept examples of code written by other people or companies as a resource. After a while you come to realize that most people write code in a similar manner to what I have described above. It may be in a different order, use a lot of different techniques, but the general structure is usually similar. There are always those "job security" rungs you will occasionally run across, but disassembling them into separate rungs is usually not too difficult.

Happy Automating!


Author Bio: Frank Lamb is founder and owner of Automation Consulting LLC and member of the Control Engineering editorial advisory board.