Hello World, so what is Ladder Logic?

Hello WorldLadder logic is a visual programming language used to program PLC’s (Programmable Logic Controllers).

Ladder logic consists of horizontal Rungs  and Instructions embedded between vertical Rails on either side. Rungs house instructions which are referenced by tags or variables. The rails represent the opposing polarity of power rails as shown on an electrical schematic. The rungs and subsequent instructions represent the “load” between the rails.
Rungs and rails are graphical representations of electrical schematics. The real magic behind ladder logic is the instructions, and there are a bunch of them. There are Boolean, Math, Timer, Counter, and Specialty instructions just to name a few. All instructions reference a tag or variable which is an address to a memory location. Got all that? Good.

Why ladder logic? I mean really, what advantage is there to programming in ladder logic?

Take a look at the picture below. On the left is Structured Text and on the right is Ladder Logic. Both programs accomplish the same thing just with different languages. Notice the green vertical rails in the ladder logic example and the green vertical bar in the structured text example. The green lets you know that the logic is enabled and running.


Take a look at the rung on the right. Instantly you know the values of the tags are zero. How? That’s easy, because if either of them had a value of 1 they would be green just like the rails.

Now take a look at the code on the left. It’s impossible to determine the input and output tag values without bringing up a watch window and checking the value of the tags. Incidentally all values in both programs are set to 0 in this example.

The picture below shows the exact same logic, however something is different on the rung example. The instructions are now highlighted in green the same way the rails are in the last example. Both tag values are now set to 1 as indicated by the green highlighting of the instructions.


In the Structured Text program both values are 1, however the code is just that, code. The code does not provide feedback like the ladder logic example does.

It’s possible to open a watch window to see the value of the two variables, for that matter the same watch window could be opened for the ladder logic program as well. The major difference being is it’s unnecessary for the ladder program. Just a quick glance lets you know what is on and what is off.

This kind of feedback is undoubtedly the major advantage of using ladder logic. Ladder logic places all the information you need where you need it. It makes troubleshooting quick and easy, and this functionality isn’t limited to just bit instructions. Variables are displayed on instructions as well. Most ladder instructions will show the value of tags in real time. Take a look at the Equal To instruction below. If the value of Source A is equal to the value of Source B turn on the output bit. In this case they are not equal and the output bit is off.

Variable Example

Now imagine you have been tasked to find out why the variable “Output_Bit” is off. Just a quick glance at the ladder rung and it’s easy to determine why the bit is off. The two variables in the comparison instruction are not equal therefore the “Output_Bit” if off. From there you can do a simple cross reference on the variables to discover why the variables are not equal.

Programming ladder logic entails dragging and dropping instructions, rungs and branches. Programming structured text entails knowing the correct syntax. Take another look at the structured text examples above. Notice the Semicolons and Colons. This is representative of the Pascal programming language. Instructions are in Blue and tags are in Red. Setting a value is done with the :=  operator while comparing values is done with just the = operator.

Ladder logic is scanned the same as a book is read, from top to bottom left to right.

So, if you had a program with 10 rungs the top rung would be scanned first starting with the left most instruction and proceeding to the right most instruction of the rung. All subsequent rungs would be scanned the same way, and upon completion the scan would start over at the top most rung again. I say typically because most ladder programs are scanned this way however they can be event or time driven as well.

Ladder logic is but one of five standard PLC programming languages as defined by IEC 61131-3 and are as follows.

  1. Ladder Logic
  2. Structured Text
  3. Sequential Function Chart
  4. Instruction List
  5. Function Block Diagram

The RSLogix 5000 platform accommodates all the standard programming languages with the exception of  Instruction List in any combination. That is, it is possible for a single project to contain all of the different languages.

If you don’t already have RSlogix 5000 programming software you can get a free copy here.

This demo software is version 17 and is for offline programming only, which is a heck of a lot better than nothing. The demo software is good for 90 days. Follow the instructions on Allen Bradley’s website to install the software Update! The software is no longer available from Rockwell. When and if it becomes available again I will link to it from here. You can still follow along with the video tutorials. After completing this tutorial you should be able to add Rails, Rungs, Branches, Instructions and Tags.

I recently released a book on Amazon titled “Learn How to Program and Troubleshoot Ladder Logic“. If you are new to programming PLC’s grab a copy and jump start your journey into the rewarding world of controls.Book-Page-002