Building a Retentive Timer Using TON Instruction in RSLogix Studio 5000
Introduction
PLC Programming requires practice and problem-solving. You may be asked at an interview or a job site to create various code that accomplishes a specific task within a process.Â
In this tutorial, you’re going to learn how to build a retentive timer using a TON instruction. RSLogix Studio 5000 provides a way to create this using a single instruction (RTO), however, if your understanding of PLC Programming basics is correct, you should be able to build the same functionality without the RTO.
Understanding the RTO Retentive Timer On RSLogix Studio 5000 Instruction
If you enable the Timer 3 Enable XCI bit, you'll see the timer count all the way to 10 seconds. If you disable this bit you’ll notice the accumulated value of the RTO instructions is not going to reset back to zero unlike the TON and TOF instructions.Â
This is extremely useful in very specific scenarios. For example, when you're filling a certain vessel, such as an ingredient tank, you typically want to track the time that you're filling the tank but you also want to stay at that same level because you already put in that amount of ingredients. Therefore, if the valve shuts off you already failed for six seconds and you don't want to bring that back to zero and fill for another ten seconds unless you empty the tank.
In such a scenario, you can toggle the RTO instruction and it's going to resume counting from that point on.
Building RTO Using TON Instruction
An interesting question that can be asked, is how can you build this using just the TON instruction? To do this, you’re going to have a couple of options.
First, you’ll need to create a new rung, enable the instruction as well as add an XIC instruction.
Next, you'll need to move the timer value into a separate register. To do this, you’re going to add a branch and you're going to add a timer. This is the TON instruction that's going to actuate.
Next, create a timer4 so you've got a blank timer to work with and set its value to 10 000 milliseconds so you can have something to compare to.
Now you need to think. Once timer4 is enabled you need to put the value back into the timer, but once it is disabled you also need to store the value. So how can you do this?Â
In order to put the value in you can use the One Shot (ONS) instruction. The One Shot as is going to execute once the Timer4Enable XIC instruction is executed. The ONS instruction will execute for a single time when this rung is read.
Here what you can do, is add a MOV instruction and you can use this to put the value back into the timer accumulated register.Â
To do this, you’re going to put this timer that accumulated register by adding Time4Retentive next to Source under the MOV instruction. That's going to be your register from which you need to put the value from and that's going to be a double integer.Â
Next, you need to set the timer for the ONS instruction which will be a boolean value.
Finally, you need to create something that's going to save the value every single cycle. To do this, you’re going to add a MOV instruction and you’re going to store Timer4.Accumulated into the register every single scan time.
Testing Ladder Logic of RTO
Now you’re ready to test your implementation to see if everything works properly.
To do this, you’re going to enable the rung and you should see the timer begin counting and the register updating.
If you stop the rung you'll notice that you've saved the most recent value of the timer. Here you can swap the MOV and the TON instructions to get the last value but that's not extremely important because that's purely scan time.
That being said you have now stored the timer value in the MOV instruction, and once you resume the rung you're going to perform a single move into the accumulated value and the timer should resume from there.
So if you toggle the Time4Enable you should see the timer resumes counting, and if you toggle it again the timer goes back to zero but you've stored the retentive value of the timer, and thus we are able to resume counting from that specific value once this rung is re-enabled.
This is just something that you need to be aware of, but obviously, it's not practical to do it this way. This being said, you can use the timer or the accumulated value of your timer in other specific cases in PLC programming
As mentioned at the beginning of the tutorial, this entire run can be replaced by an RTO instruction which is something that you need to be very familiar with.
Conclusion
In this tutorial, you learned how to build a retentive timer in RSLogix Studio 5000 using only a TON instruction. Although RSLogix Studio 5000 provides a way to create this using a single instruction (RTO), you could be asked on an interview how to build the same functionality without the RTO to test your understanding of PLC Programming basics.