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.

10/20/2014


An example of ladder logic. Courtesy: Frank LambSoon 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!



Bob , Non-US/Not Applicable, Norway, 11/19/14 01:55 AM:

Some of my personal rules: Never to have anything on the rung after the output coil.
Never have more than one output per rung.
Simple, effective and keeps you out of trouble.
SAHEED , NIGERIA, 12/12/14 12:57 PM:

To reduce ambiguity in programming, it is better to keep it straight and simple. Clarity in programming enhance good understanding and documentation. Though, the payload could be lengthy programming steps but it worth it.
Phil , United States, 12/12/14 04:36 PM:

one exception to "one output coil per rung" rule: when code is modified, add a coil identifying programmer, or at least his group (or a larger org). helps track changes and who made which ones.
WILLIAM , MI, United States, 12/12/14 05:05 PM:

The first requirement for writing ladder code, or any other type of code, is to understand the sequence of operation of whatever is being controlled. After the sequence is written the next step is to identify the I/O that control and detect each step of that sequence. Then, with that information the writing of the program should not be hard.
Of course, programs that require calculations and communications are a different story.
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
The Engineering Leaders Under 40 program identifies and gives recognition to young engineers who...
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Sensor-to-cloud interoperability; PID and digital control efficiency; Alarm management system design; Automotive industry advances
Make Big Data and Industrial Internet of Things work for you, 2017 Engineers' Choice Finalists, Avoid control design pitfalls, Managing IIoT processes
Engineering Leaders Under 40; System integration improving packaging operation; Process sensing; PID velocity; Cybersecurity and functional safety
This article collection contains several articles on the Industrial Internet of Things (IIoT) and how it is transforming manufacturing.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

SCADA at the junction, Managing risk through maintenance, Moving at the speed of data
Flexible offshore fire protection; Big Data's impact on operations; Bridging the skills gap; Identifying security risks
The digital oilfield: Utilizing Big Data can yield big savings; Virtualization a real solution; Tracking SIS performance
click me