Learning PLC ladder logic

In industrial automation, many PLCs use Ladder Logic as their main programming language. Although there are many types of PLC, the language used to program them is the same. In this article, I'll cover the basics of PLC Ladder Logic programming like input, output, timer, counter, and more. I'll explore each instruction separately and go through examples to better understand the concepts. At the end, we'll have a case example where we'll combine all the knowledge learned within the article.

This article is an introduction to PLC ladder logic programming, so you should know some of the terminologies used within industrial automation that will help you to better understand the article. Check out my other article, Learn Industrial Automation, to learn more about the components and networks involved in each level of automation.

PLC programming languages

Simply, PLC programming languages are used to program the automation devices within industrial field. The controllers that are used in industrial automation need to be programmed to perform certain tasks like moving products or sorting them. In industrial automation, devices are connected through PLCs that are programmed using softwares. There are five programming languages for PLC that are divided into two main sections, text based and graphical. The two common methods for PLC programming are ladder logic and block diagram. All these languages are defined by the international standard for PLC programming languages and concepts. The standard explains the format, syntax, and display for the five PLC languages available. Each language is used and best suited for certain types of applications. We will be learning the basic principles for ladder logic programming, how to read, write, assemble ladder logic. Ladder logic is one of the languages used to develop software for programmable logic controllers, PLCs, used in industrial control applications. A PLC programmer is the person responsible for coming up with the logic needed and programming the controller to solve the required task.

For the purpose of better understanding the language, I'll be using a simulation software to test the programs. I'll be using it to demonstrate each instruction we cover. However, I'll focus more upon the language and the concept other than teaching the software. The concept is the same for each PLC type that uses ladder logic. Each PLC manufacturer users their own PLC ladder logic software. They might have differences, but the logic is the same. The simulation software is called LogixPro provided by Learning Pit.

This software mimics Allen Bradley Rockwell RSLogix 500. So you can download the simulation software from the website, thelearningpit.com. There is a free 15 day trial if you want to give it a try. So you can click on LogixPro Allen Bradley RSLogix Simulator in order to download the free trial.

Once you download the software and install it, then you click on LogixPro software. Once you open the program, it tells you how many days left for the free trial. So then you click on Continue in order to get into the software.

So this is the platform for the simulation software we are using. All of the ladder logic is going to be happening in this white area. So in order to add the ladder logic instructions, you go to the PLC Instruction Panel, and then you add a new rung. And in order to get the instructions, you just click on it and drag it to the rung.

Notice here that once you see the green light, this indicates that you can place the instruction on this specific location. And you can add as many instructions as you want depending on the logic you are using. And in order to delete the instruction, you just click on the instruction, and using the keyboard Delete button in order to delete the instruction.

So this simulation comes with a built-in example that you can give it a try. So you go to the Simulations tab, and then you can select any simulation example that you would like to. For the free trial, you are limited to the first three ones, the I/O Simulator, the Door Simulator, and the Silo Simulator. So in the course I'm going to use the I/O Simulator in order to see how the program works. So now for to get the addresses of each button, you just move the mouse to the device, and notice here that you can see the different addresses for each button.

So for example, for the first one you can see I:1/0. I indicates this is an input, then one is for the rack module. So you can take the address and associate that with an instruction by double-click on the instruction and then write down the address that you would like to. And then you can do the same thing for any other instructions. So for example, if I want this light to be connected to the output, so you just move your mouse in order to get the address O:2/0, and you add that to that specific instruction that you would like to. Now if you want to add description for each instruction, you right-click on it, and click on Edit Symbol. So for example if this one is a push button, then you are going to add the description that you would like to. Now the program does not work. We need to go online and download the program to the PLC. So you go here, and then you click to go online. Download to PLC. And then you click on the Run mode.

Once you are in the Run mode, now the PLC scans the ladder logic. Once you hit on the selected push button, your output will work. Now if you want to make any changes while you're online, you can select the program mode. So let's say for example instead of using this output, I'm going to use for example, let's say the fourth light. Now the fourth light has an address of O, stands for output, 2/4. So you take that address and you put it here by double-clicking on it. And then just change the light number. After making any changes online, you need to download the program again. So after downloading the program, you go to Run mode again, and you click on it and see that the other light turns on. If you want to change the color of the light, you right-click on it, and then you select any color available. And that will reflect any changes.

Now the same thing happens for the different instruction for the different buttons. If, for example, you want to use a normally closed then you right-click, and that will change it to a normally closed. If you want to use a limit switch, you right-click and then keep changing to whatever device that you would like to try. Then you would go offline, and then continue programming the ladder logic. Please note for the free trial you cannot save the ladder logic. Now if you want to give it a try, for another simulation, for example, let's go to Silo Simulator. So this is how the simulation looks like. Now if you'd like to add more rungs or start a new program, you either delete the rung by clicking on it and hit on the Delete in the keyboard. Or you can go to File and start a new file. Now the same thing applies, if you'd like to add more rungs, then you click on the rung in here, and then you drag any instruction you would like to place it on your ladder logic. And if you'd like to have the addresses of each button, then you just move the mouse to that specific button and it shows you the specific address for each one.

Programming cconcepts

Ladder logic is used to develop software for Programmable Logic Controllers, PLC, that are used in industrial control applications. So devices are connected to the input and output module within PLC and according to the software, controlling industrial applications happen. The name ladder logic programming came from the fact that the program at the end looks similar to a ladder with different instructions and rungs. PLC ladder logic programming basics begin in making a clear distinction between input and output within the program itself. In PLC ladder logic, generally speaking, inputs are written on the left side of the ladder logic. Outputs are on the right side. You will learn later in the article that not all inputs and outputs are necessarily connected to a physical device, but for simplicity let's assume so for now. The left and right rails indicate the positive and the ground of the power supply. Electrical current flows from left to right. The logic is read as following. When the switch is on, the light is on from left to right. Each line is called rung. The rungs represent how the program is designed. If we have multiple rungs, the way we read the program is from left to right top to bottom. So each rung is read by the software and the same thing applies, left to right. Each ladder logic program ends in a rung with an end instruction to indicate that this is the end of the program. Knowing this will help you in programming PLC ladder logic as where to place each input and output according to the logic you design. So for example if you have a light and a fan and you have two switches and you want to execute the light first, then you need to place it in the first rung and so on.

Let's take a look at what input means in PLC ladder logic programming. The way we write input is as following: as two bars facing each other representing the input. And to differentiate between the physical input device and the input within the software, we will refer to the input in the PLC program as input instruction. There are two main types of input instructions; Examine If Closed, XIC, and sometimes called normally open, Examine If Open, XIO, and sometimes it's called normally closed. Notice, that the only difference between them, is that the XIO has a sidebar that indicates it's already closed and we're examining if it opens. In ladder logic program, the instruction is highlighted when the logic state is true. I'll be using a green highlight in the slides here, similar to what is used in Allan-Bradley software. However, it's very similar in any other PLC types. Different colors might be used in different softwares but they all indicate the same concept. Examine If Closed, Examine If Open instructions, tell the processor to test for an ON condition from the reference address bits. Simply, the instruction checks a memory location. And according to the bit, zero or one, then the instruction is either activated or not. So here's a simple layout of a digital input device connected to a PLC input module, to provide an input, and it has a specific memory location to indicate the status. And by using this memory location address in the PLC instruction, we can connect the physical to the program we are writing. So, the input signal is received from a physical device. The physical device is connected to the PLC input module terminal, and the bit is then stored in the input memory address location. And according to the bit address, the input instruction behaves accordingly. The two input instructions, XIC, Examine If Closed, and XIO, Examine If Open, are Boolean type. Which means, either on or off, zero and one, and we refer to it as the logic state. In the case of Examine If Closed, XIC, the instruction is highlighted when the memory location associated with it is one. Usually in many softwares, a gidian highlight is at a presentation that the logic state is true. So, XIC is true when the memory address bit is one, and is false when the memory address bit is zero. The XIO, Examine If Open instruction, acts the opposite way. It is activated when the logic state is zero, and not activated when the logic state is one. So, XIO is true when it has a zero, and false when the logic state is one. To summarize, in the ladder logic program, the instruction is highlighted in green when it's logic state is true. Example, one is not necessarily true, as we saw. True, active, or highlighted all mean the same thing. Simply means, an ON condition. The difference between XIC and XIO is when each of them is a true. XIC is true when the logic state is one. XIO is true when the logic state is zero. So try not to associate one as true. Inputs are written in the left side of the ladder logic.

Let's see what an output instruction in PLC ladder logic programing. The way we write an output instruction is similar to two brackets as you see and to differentiate between the physical output device and the output within a program, we refer to the output as output instruction. There are three main types of outputs. An empty bracket is referred to an output energize, OTE. The other two types are output latch, OTL, output unlatch, OTU. Outputs are written in the right-hand side. So, what's an output instruction? An output instruction represents the action that is to be taken when the input instructions or instructions are true. Basically, when the rung is true, the output is activated as a result and since the output is connected to a memory address and according to that bit as status, the device turn on or off. A physical output device is connected to the output module of the PLC and work accordingly. Output is always the last instruction before the right power rail. So, you cannot put an input after placing an output. Everything in front of the output tends to be an input instruction for that specific output. Please, keep in mind not all outputs are connected to a physical devices. Sometimes, we use an internal register tag or address instead, so thing as a real device and a virtual device. A rung can still work with only an output and once the program is activated, the rung is true and the output is activated. Every rung must have the minimum of one output instructions, so I cannot have a rung without any outputs. Only use a particular output one time in your program, so if you have two switches to turn on the same light, then use the particular output one time in your program. If you have multiple outputs, associate it with the same input, then put them in parallel. Multiple outputs are preferred to programed in parallel. Output is activated when the memory location is one, so it is true when it's one and false when it's zero. I always recommend that having this table when you start programming. It makes it easier for you to remember when each instruction is highlighted.

No comments?

There are intentionally no comments on this site. Enjoy! If you found any errors in this article, please feel free to edit on GitHub.