Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Hi friends! I hope you are doing well! Today we are going to learn and practice a new topic which is a very crucial technique in plc programming. the topic is called “latching”. We mean by Latching to keep the output running starting from the instance of giving a kick-off command until we hit a command to stop running of the motor. Imagine my friends, operator wants to start a motor by hitting a start push button and want the motor to keep running and leave and go for doing another task or job. And then it keeps running until the operator wants to stop it. The problem here is that, once the operator releases his hand away from the push button, the motor automatically stopped and that is not like what the operator wants to do with the motor. To clear the problem that we are going to solve, and for which we need to use the latching technique to connect a load, Figure 1 has been created for you to show the situation to make a direct connection to a motor by using a simple push-button. In this circuit, the operator needs to keep pressing the push button as long as he needs the motor to keep working. Otherwise, the motor will stop once he releases the push button. So would please think with to figure out what is the solution for that?

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 1: Connecting motor to power by push button directly

Let’s try to connect the motor through a relay as it is typically in the industry. Maybe that helps us to control the way to energize the relay coil and use its contacts to start and stop the motor, Figure 2 shows how we can employ a relay to connect the motor to the power source. However, again In fig. 2, the operator still has to keep pressing the button as long as he wants the motor to keep running. This is not the best practice in real life, the operator has many jobs to do. So, he wants to give the command to commence running the motor and leave it running to perform some other tasks and then has the motor stops after the job has been done. In this case, latching is the best practice to connect the motor or any load we want it to run for a while or until complete some functions.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 2: relaying motor to DC power by hitting start push button

How does latching work?

Now, I hope you can feel the problem between our hands and sense the meaning of the word “latching”. Again, in a real-life situation, motors or any actuators can be run via relay, by energizing the relay’s coil, the contacts of the relay switches over from off to on and then connects the motor to let it starts spinning. So for running the motor, the rely on coil should be energized. However, the latching technique makes that requirements go away, instead of that, the contact that has been used for connecting the motor to power, is used to be another pathway to connect the rely on the coil to power without needing to keep pressing the start push button. WoW! What amazing solution is that! to just hit a button and then forget about it and use the contact to make like a closed-loop to have the coil connected to power forever and let the motor work forever. Ohhh!! Forever!!! How do we run the motor without stopping? Yes, you are correct. It should be a way to break that loop when we want to do stop it. we need a way to just stop the latching, to break its loop, to enable the operator to stop the motor when they need to do.

Steps to perform latching

Let’s now show you guys how we can establish and construct a complete latching circuit step by step. In the following subsections, three steps by which will be demonstrating how to complete a typical latching circuit including only push-button and relay.

Latching Step one

First of all, in a very simple circuitry which is shown in Fig. 3, the DC power lines positive and negative are connected with a push-button and relay to run a load. The positive wire in red is connected to the push button and then to the coil terminal A1 and A2, and then to the ground black wire. So now, it’s clear that when the push button is pressed it turned on and connects the circuit of the relay coil all the way to be energized. As a result, the contact of the relay is connected and now it is ready to connect the external circuit to run an actuator i.e. motor. But when the push button is released, the coil will be de-energized and the relay coil turns back to the open state and the motor is going to stop. So moving to the next step of building a latching circuit in which we aim at creating another pathway to supply the relay coil with power to forget about the push button and have it continue to run even after releasing the push button.

Fig. 3: the typical push-button and relay circuit

Latching step two

Now Fig. 4 shows the main wiring schematic of a basic latching circuit by which we indeed realize the concept and functionality of the latching technique. in the circuit, you can notice my friends that, the contact upper point and the relay upper point are connected in such a way that, it creates another pathway for energizing the relay coil without any needs to press or even touch the push-button B1. Again, when the push button B1 is pressed, the relay coil will be energized. As a result, the relay contact will be close contacted and in turn bridges point A1 to the positive red wire. Now, when the push button is released, the relay coil still has another pathway to connect to the positive wire so the relay coil will keep energized. I know now what comes out to your mind? if this configuration and schematic can put the relay coil in the loop and energize all the time by the first kick-off by hitting the start button thanks to the latching technique. The question now is, how about stopping the motor?. How to break this loop? Yes, that’s the only thing is remaining to complete a typical latching circuit.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 4: the second step of latching

Latching step three

We can name this step by ending latching. As shown in fig. 5, a normally close (NC) push-button B2 is added in the way from contact to the positive, red, power wire. Firstly, when the push button B1 is pressed, the relay coil is energized. And the contact of the coil is connected to the positive red wire as the push-button B2 is in a closed state by default. So now, it will be latching as long as the connection to the positive wire does not break. So by hitting push-button B2, it will turn out to open state and the connection to the positive wire is broken. Therefore, the relay coil will be de-energized and the latching gets to stop.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 5: Ending latching step 3

Latching in ladder logic programming

I know guys you all are waiting to come to this point to go to our lab and simulator and practice our tutorial. So now after we discussed the concept and basics of what latching is and how does it work? We now are all set to start our simulator and practice latching techniques in ladder logic programming as we used to do every tutorial.

Ladder logic without latching

Now we need to connect a simple start push button “input A” to the motor at “output” Q0.0 straight forward as in fig. 6. You can see, by pressing the input push button switch, the output motor starts spinning. But how about after releasing our hands off the start button?

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 6: Before latching

Well done! Yes, exactly like what you expected, as shown in fig. 7, when the start pushbutton has been released, the motor stops immediately.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 7: the motor stops when we released the start button

Now by adding another pathway to run the motor as shown in Fig. 8, a contact from relay “output” has been used in parallel to form “OR” logic with the start push button. So, in the first place, when the start button is pressed, the output goes high and the closed contact now adds another pathway in “OR” logic.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 8: the latching effect in ladder logic example

Figure 9 shows how the closed contact that has been taken from the relay plays the role of the alternative path to connect the output to the power. So when the input start push button has been released, the closed contact of the output relay makes the connection and the output continue running. However, there is now one problem that, how to break that connection to stop the output?

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 9: the latching effect after releasing the start button

The solution for having a way to shut down or break the latching connection is that, adding a normally closed (NC) push button “input B” in series as shown in fig. 10. This way enables to break the latching connection and shut down the output.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 10: adding a stop push button to end latching

So by hitting input B, the connection of latching is broken and the output stops running. But breaking the connection will make an issue if the input B is a switch like an emergency switch. The problem is that it should be returned to its normally closed state to enable the cycle to start by hitting input A or the start push button.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 11: the usage of adding stop button to end latching

By having the stop button return to the normally closed condition, the cycle can be restarted by pressing the start push button and enabling the latching once again.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 12: restarting the process by resetting the stop push button

Latching using set and reset

There is another way to perform latching of the output. The set instruction can be used to set the output to run until a reset command is met to reset the output. This is a piece of cake to latch an output by employing set and reset instructions. Let’s practice this way in the simulator. Figure 13 shows a simple ladder logic program that uses set and reset instructions to perform latching of the output. Input push-button input A is used to set the output while input push-button input B is used to reset the latch of the output.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 13: latching using set and reset technique

By hitting the input at I0.0 which is input A, the output is set to true. The question is what happens when input A becomes false?

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 14: set to enable latching the output

Figure 15 answers our wondering that, even after input becomes false the output keeps energized thanks to using a set instruction. So when will see the output turns out to be false?

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 15: the output keep set true even after input becomes false

After setting the output to true, it won’t become false until a reset command is used like in the example shown in fig. 16. The output is reset by input B and becomes a false state.

Latching in ladder logic programming, how does latching works, latching in plc, plc latching, latching in ladder logic, plc latching code, ladder logic latching code

Fig. 16: reset to end the latching

What’s next?

I really would like to thank you guys so much to follow our tutorial till this point and I hope you have become well known for latching concepts, and how to use and utilize them to solve a real problem in real industrial life. Now let’s continue our series, learn and enjoy practicing ladder logic programming series. Our next station will be the comparator operators including equal, not equal, greater than, equal, less than, et cetera. And how to master using this operator to compare different data types and control the logic of a ladder logic program based on the results of these comparator operators.