Ladder Logic Programming has been derived from relay logic electrical circuits. This language of PLC programming is called ladder logic or LD as it looks like a ladder of many rungs. Each rung represents a line of logic by connecting inputs logically to form a condition on which the output is determined to be on or off. By completing this article, you will have enjoyed understanding the basics of the LD programming language. Consequently, you will have been able to read a ladder logic code and translate the logic in your mind or the electrical circuit between your hand into ladder rungs.
Relay logic control was the old fashion classic control in which input switches and sensors are connected between the hot voltage and relays’ coils to energize these coils and in turn, activate their contacts and thereby connect or disconnect the actuators i.e., motors, lamps, valves etc. You cannot imagine how complicated that control was besides its limitation in functionalities. In addition, it has a huge number of wires and components to achieve a simple logic. Furthermore, there are no chances to change the logic or the sequence of operation without destroying, rebuilding, and rewiring everything from scratch. When it comes to troubleshooting and maintenance, you should be very patient and generous for your time and efforts to pay to keep tracking hundreds of wires and checking up a bunch of components to figure out the problem.
To image the difference between old fashion classic control and PLC, figure 1 shows the case of a very simple process that contains four motors, and four sensors that are connected via four relays and a timer for performing a very simple logic. Let’s say we need to run motor 1 at the start and after a while, we plan to run motor 2 and 4, and at last run motor 3 considering one constraint that no more than two motors can run simultaneously. In addition, sensors will be used as protection to emergency stop motors at any time. Now on the left of the figure, you can see the relay logic control. you can imagine how many components and punch of wiring work for connecting sensors, timers, relays, and motors. On the other hand, PLC-based control shown on the right, you can notice only the PLC and input devices and output actuators are connected to the PLC. To sum up, the number of wires is reduced significantly, the effort of wiring is immensely reduced. In addition, when it comes to modification of logic or process sequence you need to destroy all old wiring and start over rewiring according to the new requirements while you can do this by modifying the program in PLC without touching the wiring. To sum up, PLC reduced the number of components, wires, time of implementation. In addition, the processing is faster thanks to PLC processing and modification becomes programmatically.
Before opening the door to enter our tutorial on ladder logic programming, let’s have a brief idea about how PLC works and what ladder logic program has to do with PLC. Well! Let me briefly say that PLC has input modules, output modules, and a processor. The input modules are connected to input switches and sensors while the output modules are connected to actuators i.e., motors, valves, lamps. And for sure processor runs the ladder logic program that we going to learn here! In the below figure, I have tried to clear it visually.
The processor works in scan cycles, in each scan cycle, it gazes into all inputs and records them in its memory and then executes the ladder logic to determine the new status of outputs and update them and go to the next cycle, and so on. So now you can tell me what ladder logic has to do with this? That is great to hear you say that it is the logical connection between inputs to determine the output status. I really can not wait to go ahead and hit the nails on the head and open the door to let us get started with our tutorial about ladder logic programming. In the below figure, I have shown PLCs of different manufacturers:
Each programming language has a structure and building blocks. The building block of a ladder program is a rung. Yes, rungs of a ladder go step by step to do the designed logic and repeat every scan cycle. Each rung forms a complete piece of logic like one complete circuit. so let us go to know how to form this rung and get to know what components of these rungs and how they are connected logically.
In the above section, we have designed a simple ladder logic program, where we have used just a single input to control our output. These contacts/inputs in their two configurations can be connected in series (AND logic), parallel (OR logic), or negation (NOT) to form logical combinations. In the below figure, I have designed three rungs of Ladder Logic, let's understand them one by one:
In the below figure, you can see a slightly complex Ladder Logic Program, having different components, let's discuss them one by one:
If we define the ladder and its building blocks which are rungs how about the word “logic” the second word in ladder logic? Well! Table 1 reviews the logic gates and their truth table. For you to expect the incoming status of your output based on the status of the inputs and the logical combination pattern. to decide the results logic output ( RLO) which is the status of the logical combination of contacts that precede the output coil. For instance, the AND gate/logic function is applied between two or more inputs when all of the inputs should be true to get the output to be true. On the other hand, the OR gate/logic function between two or more inputs is used when we need at least one of the inputs to be true to get the output to be true.
Let’s see one simple example to understand the reading ladder logic program. Figure 3 shows a very simple complete ladder logic rung that connects a normally open pushbutton to start a motor and another normally closed pushbutton to stop the motor. You can see each component of the inputs and outputs should have an address to be uniquely identified by PLC. For instance:
Now, how do you see your progress so far? I can see you are doing progressively and that’s great. However, we still have a lot to learn to master ladder logic programming. However, we need to set up the environment for simulating a Ladder logic program to be able to validate our programs and enjoy seeing its execution typically as if we have a PLC controller and to verify how far our designed ladder performance matches the real-time execution on the simulator.