Timer & Timer Compare
This covers both the Timer Block (lower highlighted tool) and Timer Compare Decision Block.
Timers keep track of time elapsed while Timer Compares check to see if desired time has elapsed.
Timers are background functions. Once you start a Timer, it will continue to run, until you Pause it.
Timers cannot be passed into or out of Subroutines, but their values can be.
|To Start a Timer, select Start/Continue.
Provide an I32 Tag in the „Timer slot“. This is where the time is kept.
The time elapsed is stored as number of milliseconds since timer was started.
It will not initialize the timer value to 0. It start it or restart it after a pause.
|Pause stops the timer, but retains it’s value.|
|Reset puts a 0 in the Timer’s Tag. It doesn’t stop the Timer.|
Once you’ve created a Timer, you probability want to test if an amount of time has elapsed. For this we use Timer Compare.
In Timer Compare you must select your Timer Tag in the leftmost slot. The right slot can have a number or Tag. The right tag uses the drop-down to specify the time you’d like to use in the comparison.
In Ladder: How to execute tasks only once at startup?
Useful for defining the starting value of certain tags or for background tasks.
Note: Since some tools are background tasks, it is not necessary to run them every PLC cycle. If you run it every cycle, the tool will not work properly because you are constantly configuring it.
Just add a "BIT" that will be turned ON right after.
|All your lines that only need to start once at startup :
Note: You can use any name for the ColdStart bit.
Example Timer Application
- We start (or continue) the timer.
- We check if we are > at 5.5 seconds.
- If yes, OutBitD1 = 1
- We check if we are > at 7.5 seconds.
- If yes, OutBitD1 = 0 and we reset the timer
As you can see, we can reset the timer in another way.
The idea is to let always the timer running. Just reset it when you need it !