Timers - TON, TONR, TOF and TOFR

Previous  Top  Next



The Timers (alongside of the Counters, of the Coils and Relays and of the Sequence Commands) are one of the principals components in PLC, acting as chronometers in the system, measuring the time of occurrence of the events associated to the control.

There are, in the IL, four types of timers, TON
, TONR, TOF and TOFR: (Obs.: this TOFR is not implemented in the STEP 7), that are mapped, respectively, to the instructions LCE

1.   when ... temporize ...;  
2.   when ... temporize_accumulate ...;  
3.   when_not ... temporize ...;  
4.   when_not ... temporize_accumulate ...;  

      1. TON:


      
LD   I0.0
      TON
   T0,   3000

In the example above, the doubleword variable T0 (temporizing variable) says, in ms, the time past since from instant that the condition I0.0 was turned on by last time (or since that the flow of power reached the instruction by first time after that the control entered on the run mode, if I0.0 already began on). If I0.0 is off, doubleword T0 remains 0 (off or off). If I0.0 was on and changes to off, doubleword T0 changes to 0, turning off/reseting the bit variable (0/1 - on/off) associated to T0.

When T0
reaches the value of the preset time, the second parameter (3000 ms = 3 s, in the example above), the bit variable associated to T0 will be turned on (or set in 1 - on), but the doubleword T0 will continue saying the time, as nothing had occurred. When I0.0 changes to off, the bit variable T0 will change to its original state off (or reseted to 0 - off) and doubleword T0 will be put in nought, remaining frozen in zero, no saying the time until I0.0 changes to on.

Functioning Diagram


timer ton


Obs.: the way that we use the variable T0
will define if we deal with doubleword variable (comparisons, assignments or mathematical operations) or bit variable (bit-logic operations), as exemplified in the diagram below:

         timerton eng

      2. TONR:


      
LD   I0.0
      TONR
   T0,   3000

It works like the anterior, with the difference that when I0.0 changes to off after the bit variable T0 has gone to on, this T0 will not change to its original state off and the doubleword T0 will not be set in zero, keeping the value of the time past until this moment and resuming the temporization from this value when I0.0 change to on again. That is, it accumulates the time that I0.0 is on.

To return the bit variable T0
to its original state off and the doubleword variable T0 to zero, we must put in the control a command reset with parameter T0 (R T0, 1).

Functioning Diagram


timer tonr



      3. TOF:


      
LD   I0.0
      TOF
   T0,   3000

In the command above, when I0.0 changes from off to on the bit variable associated to T0 will be turned on. The doubleword variable T0 says the time past since the last instant that the condition I0.0 have changed from on to off. If I0.0 changes again to on, T0 come backs to zero, but the bit variable associated to T0 will continue on.

When doubleword T0
reaches the value of the preset time, the second parameter (3000 ms = 3 s, in the example above), the bit variable associated to T0 is turned off and the time said in T0 will remain frozen, but when I0.0 changes from off to on the bit variable T0 will return to the state on and the doubleword variable T0 will be reset to zero.

Functioning Diagram

timer tof



      4. TOFR:

      
LD   I0.0
      TOFR
   T0,   3000

It functions like the anterior, with the difference that when I0.0 changes to on after the bit variable T0 has gone to off, this T0 will not change to on and the doubleword variable T0 will not be set in zero, saying the value of the frozen time past until this moment and resuming the temporization from this value when I0.0 changes to off again. That is, it accumulates the time that I0.0 is off.

To the bit variable T0
changes to on, we must put in the program a command reset with parameter T0 (R T0, 1), to change the timer to the state initial with doubleword T0 in zero and, then, when I0.0 change from off to on, the bit variable associated to T0 will be on.

Functioning Diagram

timer tofr



Obs
. 1: the response to change of the inputs can delay up to one scan cycle, although such wait was not represented at the diagrams above.

Obs
. 2: the temporizing variable must have, necessarily, the form Tn, where n can vary from 0 to 511.