100BBasic instructions
7.2 Timers
S7-1200 Programmable controller
174
System Manual, 11/2011, A5E02486680-05
Timer
Timing diagram
TOF: OFF-delay timer
The TOF timer resets output Q to OFF after a preset
time delay.
,1
4
(7
37
37
37
TONR: ON-delay Retentive timer
The TONR timer sets output Q to ON after a preset time
delay. Elapsed time is accumulated over multiple timing
periods until the R input is used to reset the elapsed
time.
,1
4
5
(7
37
Note
In the CPU, no dedicated resource is allocated to any specific timer instruction. Instead,
each timer utilizes its own timer structure in DB memory and a continuously-running internal
CPU timer to perform timing.
When a timer is started due to an edge change on the input of a TP, TON, TOF, or TONR
instruction, the value of the continuously-running internal CPU timer is copied into the
START member of the DB structure allocated for this timer instruction. This start value
remains unchanged while the timer continues to run, and is used later each time the timer is
updated. Each time the timer is started, a new start value is loaded into the timer structure
from the internal CPU timer.
When a timer is updated, the start value described above is subtracted from the current
value of the internal CPU timer to determine the elapsed time. The elapsed time is then
compared with the preset to determine the state of the timer Q bit. The ELAPSED and Q
members are then updated in the DB structure allocated for this timer. Note that the elapsed
time is clamped at the preset value (the timer does not continue to accumulate elapsed time
after the preset is reached).