User Manual

Programming made easy
6.3 Powerful instructions make programming easy
Easy Book
108 Manual, 03/2014, A5E02486774-AF
Timer programming
The following consequences of timer operation should be considered when planning and
creating your user program:
You can have multiple updates of a timer in the same scan. The timer is updated each
time the timer instruction (TP, TON, TOF, TONR) is executed and each time the
ELAPSED or Q member of the timer structure is used as a parameter of another
executed instruction. This is an advantage if you want the latest time data (essentially an
immediate read of the timer). However, if you desire to have consistent values throughout
a program scan, then place your timer instruction prior to all other instructions that need
these values, and use tags from the Q and ET outputs of the timer instruction instead of
the ELAPSED and Q members of the timer DB structure.
You can have scans during which no update of a timer occurs. It is possible to start your
timer in a function, and then cease to call that function again for one or more scans. If no
other instructions are executed which reference the ELAPSED or Q members of the timer
structure, then the timer will not be updated. A new update will not occur until either the
timer instruction is executed again or some other instruction is executed using ELAPSED
or Q from the timer structure as a parameter.
Although not typical, you can assign the same DB timer structure to multiple timer
instructions. In general, to avoid unexpected interaction, you should only use one timer
instruction (TP, TON, TOF, TONR) per DB timer structure.
Self-resetting timers are useful to trigger actions that need to occur periodically. Typically,
self-resetting timers are created by placing a normally-closed contact which references the
timer bit in front of the timer instruction. This timer network is typically located above one or
more dependent networks that use the timer bit to trigger actions. When the timer expires
(elapsed time reaches preset value), the timer bit is ON for one scan, allowing the dependent
network logic controlled by the timer bit to execute. Upon the next execution of the timer
network, the normally closed contact is OFF, thus resetting the timer and clearing the timer
bit. The next scan, the normally closed contact is ON, thus restarting the timer. When
creating self-resetting timers such as this, do not use the "Q" member of the timer DB
structure as the parameter for the normally-closed contact in front of the timer instruction.
Instead, use the tag connected to the "Q" output of the timer instruction for this purpose. The
reason to avoid accessing the Q member of the timer DB structure is because this causes an
update to the timer and if the timer is updated due to the normally closed contact, then the
contact will reset the timer instruction immediately. The Q output of the timer instruction will
not be ON for the one scan and the dependent networks will not execute.
The -(TP)-, -(TON)-, -(TOF)-, and -(TONR)- timer coils must be the last instruction in a
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.