Beginner's Free PLC Training Part 4 of 4: PLC Ladder Logic

May 21, 2020

Beginner’s Free PLC Training Series Outline

  1. Introduction to PLCs
  2. PLC Processors (CPU)
  3. PLC Inputs and Outputs (I/O)
  4. PLC Ladder Logic

When people ask me what I do, I usually say something like “I work as an engineer for an electrical company”. If they are curious enough to ask more, I usually tell them that I do some control system design and a LOT of programming. Most people picture the stereotypical programmer pounding out miles and miles of a text-based language like C++, Java or HTML (dare I say a nerdy?).

I usually try to explain that programming PLCs is different than typical computer programming and how PLCs are used to automate industrial equipment using a graphical-based programming language called Ladder Logic and how I create programs to automate electrical back-up generators and switchgear...then when their eyes begin to glaze over...I realize...I am a nerd after all. But PLC programmers are nerdy in a different way.

You may become nerdy programming PLCs, but once you get into it, you won't care :) This post is about programming PLCs. Specifically programming PLCs with Ladder Logic.

This is what I've done almost daily for my job for the past several years. But this post is not about me. My goal in this final part of the “Beginner's Free PLC Training” series is to help YOU to understand the basics of Ladder Logic so you can start using your knowledge of PLC programming as soon as possible to help you get that pay raise, new job or just help you expand your knowledge so you can be a more valuable player! Plus, this stuff is actually pretty fun! But, before we get in to Ladder Logic, let's do a quick review.

Review

In part 3, we discussed the different types of PLC I/O and some of the applications they may used in. If you haven't yet read Part 3, you may want to go back and start there to give you an idea of the physical devices and connections that you can control with a PLC Ladder Logic program (you may want to read Part 1 and Part 2 even before that!).

What is Ladder Logic?

As I mentioned here, Ladder Logic was developed to make it intuitive to program PLCs which were replacing much of the hardwired relay logic found in industrial environments. Relay control logic was shown on drawings, usually called “ladder diagrams”.

It should be noted that with PACs now including other languages such as ST, FBD, SFC and IL, Ladder Logic is not the only language that people use for PLCs. However, it is still quite popular and the company I currently work for still uses it, almost exclusively. One of the big benefits of Ladder Logic is the ease with which one can troubleshoot the logic.

Being a visually-based language, it is easy to spot where in a rung/circuit the logic is stuck. Additionally, with its similarity to relay control ladder diagrams, Ladder Logic gives electricians, engineers and technicians the advantage of being able to transition easily between programmed Ladder Logic and hardwired circuit ladder diagrams.

Ladder Logic Instructions

Although there are at least a hundred Ladder Logic instructions in Rockwell's programming software packages (RSLogix 5/500/5000), most are rarely used. There are really only a few that you will use again and again as a PLC programmer. And I want to focus on only these most important Ladder Logic instructions in this post. We will look at some relay-type instructions, timers and counters in this post. With these few simple instructions you can do a lot!

Instead of just listing each of the instructions with a technical description (that leaves you to figure out how it works in the real world), I'm going to show you simple examples that will build on one another to show how these instructions could be used in a real industrial plant environment.

NOTE: These Ladder Logic examples are not based on existing systems. These are just examples of what you could do with Ladder Logic in a plant environment. If you decide to use any of this logic on a real system, please use common sense, test it thoroughly and verify that is safe for your particular equipment and personnel.

Relay-Type Instructions

Let's start with the most important and most used instructions, relay instructions. The three most commonly used relay instructions in Rockwell PLC Ladder Logic are the XIC (examine if closed), XIO (examine if open) and OTE (output energized) instructions. The XIC, XIO and OTE can be compared to a normally-open contact, normally-closed contact and relay coil respectively.

NOTE: In case you're new to electrical circuits, a normally open contact (N.O.) means that the circuit is normally open/disconnected and becomes closed/connected when the trigger device is activated (push-button, switch, relay coil, etc.). A normally closed contact (N.C.) is just the opposite. A normally closed contact means the circuit is normally closed/connected and becomes open/disconnected when the trigger device is activated. A relay coil is a electromagnetic device that moves contacts when current is passed through its windings.

Let's look at how these instructions might be used in a basic "seal-in" or "latch-in" circuit. The green bars indicate that that portion of the circuit is "energized".

As you can see, the 'Motor_start' coil (OTE) is energized through the N.O. 'Motor_start' contact (XIC) and the N.O. 'Stop Button' contact (XIC).

A quick note on Stop buttons and Start Buttons...Stop Buttons are usually wired to the PLC input such that if the PLC input or button fails the input will fail open. This is for safety reasons, so that if the input fails the motor doesn't run forever and will immediately stop. Start buttons are usually wired the opposite.

So to clarify, the Stop Button physical contact wired to the PLC input would be a N.C. contact that turns off the PLC input when pressed whereas the physical contact for the Start Button would be a N.O. contact that turns on the PLC input when the button is pressed .

To de-energize the the motor, the stop button must be pushed which will break the seal between the N.O. 'Motor_start' contact and the 'Motor_start' coil. To re-energize the motor, the 'Start_Button' would need to be pressed while the 'Stop_Button' was not being pressed. Energizing the 'Motor_start' coil would cause the N.O. 'Motor_start' contact to close, thus sealing the circuit in, again.

If you're not familiar with control circuits yet, this might not make much sense. But don't worry, I've included a free resource at the end of this post to help you understand these instructions better.

Two other relay-type instructions I'll briefly mention are the the Output Latch (OTL) and the Output Unlatch (OTU) which work like a typical set/reset relay. Like their relay counterparts, the OTL latches it's bit when it's rung becomes true/active. The bit latched by the OTL will stay active until an OTU instruction is activated once. This FAQ from Omron is helpful for trying to understand set/reset relays.

Timers and Counters

Probably the next-most-common instructions used in Ladder Logic are timers and counters. These instructions do exactly as their names state...time...and count, respectively.

The most common timer instruction is the Timer On Delay (TON). The TON begins timing when its rung becomes true/active. It times up to the Preset value (set in milliseconds for RSLogix 5000), and then sets the Done bit (DN) which can be used to trigger other parts of logic. Let's look at an example:

In the logic above we are building on the simple "seal-in" logic we already looked at. In this case, the timer 'Motor_Run_Timer" will be enabled (EN will be set) and will begin timing when the 'Motor_Start' output is on. The Preset is set for 300,000 miliseconds, which is 5 minutes.

After the 'Motor_Start' output has been on for 5 minutes, the 'Motor_Run_Timer.DN" will be set (turned on) opening the XIO, which will interrupt the the latched motor start rung. The 'Motor_Start' output will then turn off which disables 'Motor_Run_Timer' (the EN and DN bits will turn off).

The most common type of counter used is the Count Up counter (CTU). Let's add one to our logic and see how it works.

In the logic above we have now added CTU instruction and named it 'Motor_Run_Counter'. We set the Preset value to 1000. That means that the 'Motor_Run_Counter' must be enabled 1000 times before the DN bit will be set. Whenever the CTU is enabled the CU bit will be set.

The counter will only count when the rung goes from false to true. In our case that means it will count up (add one to the Accum) every time the 'Motor_Start' output is turned on. It is programmed to count 1000 motor starts and then to turn on the 'Maintenance_Light' output. This could be used to alert the operator that motor needed to be serviced.

Alright, so what happens after the motor has reached 1000 starts? In the logic above the maintenance light would stay on forever. To allow the operator to turn off the maintenance light once the maintenance has been completed we will provide a reset push button and we'll call it 'Maintenance_Reset_Button'. Let's see what that looks like below.

Now, when the maintenance light is on and the operator has completed the motor maintenance he can reset the 'Motor_Run_Counter' and turn off the 'Maintenance_Light' output by pushing the 'Maintenance_Reset_Button'. In the Ladder Logic the 'Motor_Run_Counter' accumulator will be reset to zero when the Reset (RES) instruction is enabled. The maintenance light will now be off until the motor is started another 1000 times.

Where do you go from here?

Now that you have seen real examples of how to use relay-type instructions, counters and timers you should be able to start putting together some basic PLC programs. If you don't have any Rockwell PLC programming software, I show you how to get free Rockwell software and how to use it here: Get Free Rockwell PLC Software.

Also, I've created a 13-page Ladder Logic Instructions Cheat Sheet  for you to print out and use as a reference as you're beginning your Ladder Logic programming journey. Be sure to grab that at the end of this post!

In part 1 of the Beginner's Free PLC Training series we looked at what PLCs are, their history, and the basics of how they work. In part 2 we zoomed in on the PLC controller (CPU) and its function. In part 3 we looked at the different types of PLC I/O and the types of signals you might need to interface with in a PLC system.

And now in this post we have looked at the basics of Ladder Logic and some of the most important instructions for automation systems! At this point you should have a good foundation for getting started with PLCs.

What I want you to do now, if you haven't already - is to begin playing around with PLC programming software and building and testing some basic programs! You can use this free that I created to help those who want to learn Ladder Logic.

It includes descriptions and screenshots of the most common and important Ladder Logic instructions. I use most of these instructions almost everyday to program real PLC control systems!  

 

 

Thank you for following this 4-part series. Once you have gone through cheat sheet and have tried your hand at some basic Ladder Logic programming and are not sure what to do next, don't hesitate to comment below with questions!

P.S. Interested in learning more about our online PLC training course? Check out our course inside myPLCtraining Academy.

Get the Free PLC Cheat Sheet

PLCs are really not that complicated. If you are new to PLCs or just looking to get a better handle on how they work, check out this free cheat sheet, called the "Motivated Electrician's Guide to Understanding ANY PLC System."

Grab the Cheat Sheet
Close

Where should we send it?