100BBasic instructions
7.2 Timers
S7-1200 Programmable controller
172
System Manual, 11/2011, A5E02486680-05
Table 7- 19 Effect of value changes in the PT and IN parameters
Timer
Changes in the PT and IN box parameters and the corresponding coil parameters
TP
Changing PT has no effect while the timer runs.
Changing IN has no effect while the timer runs.
TON
Changing PT has no effect while the timer runs.
Changing IN to FALSE, while the timer runs, resets and stops the timer.
TOF
Changing PT has no effect while the timer runs.
Changing IN to TRUE, while the timer runs, resets and stops the timer.
TONR
Changing PT has no effect while the timer runs, but has an effect when the timer resumes.
Changing IN to FALSE, while the timer runs, stops the timer but does not reset the timer. Changing
IN back to TRUE will cause the timer to start timing from the accumulated time value.
PT (preset time) and ET (elapsed time) values are stored in the specified IEC_TIMER DB
data as signed double integers that represent milliseconds of time. TIME data uses the T#
identifier and can be entered as a simple time unit (T#200ms or 200) and as compound time
units like T#2s_200ms.
Table 7- 20 Size and range of the TIME data type
Data type
Size
Valid number ranges
1
TIME
32 bits, stored
as DInt data
T#-24d_20h_31m_23s_648ms to T#24d_20h_31m_23s_647ms
Stored as -2,147,483,648 ms to +2,147,483,647 ms
1
The negative range of the TIME data type shown above cannot be used with the timer instructions. Negative PT (preset
time) values are set to zero when the timer instruction is executed. ET (elapsed time) is always a positive value.
Timer coil example
The -(TP)-, -(TON)-, -(TOF)-, and -(TONR)- timer coils must be the last instruction in a LAD
network. As shown in the timer example, a contact instruction in a subsequent network
evaluates the Q bit in a timer coil's IEC_Timer DB data. Likewise, you must address the
ELAPSED element in the IEC_timer DB data if you want to use the elapsed time value in
your program.
The pulse timer is started on a 0 to 1 transition of the Tag_Input bit value. The timer runs for
the time specified by Tag_Time time value.
As long as the timer runs, the state of DB1.MyIEC_Timer.Q=1 and the Tag_Output value=1.
When the Tag_Time value has elapsed, then DB1.MyIEC_Timer.Q=0 and the Tag_Output
value=0.