285
Timer and Counter Instructions Section 3-6
Example 1:
Long-term Timers
The following program examples show three ways to create long-term timers
with standard TIM and CNT instructions.
Two TIM Instructions
In this example, two TIM instructions are combined to make a 30-minute
timer.
TIM and CNT Instructions
In this example, a TIM instruction and a CNT instruction are combined to
make a 500-second timer.
TIM 0001 generates a pulse every 5 s and CNT 0002 counts these pulses.
The set value for this combination is the timer interval
× counter SV. In this
case, the timer SV would be 5 s
× 100 = 500 s. With this combination, the
long-term timer’s PV is actually the PV of a counter, which is maintained
through power interruptions.
Clock Pulse and CNT Instruction
In this example, a CNT instruction counts the pulses from the 1-s clock pulse
to make a 700-second timer.
If the First Cycle Flag (A20011) is ORed with the counter’s reset input
(CIO 000001), the counter’s PV will be reset to the SV (0700) when program
execution begins rather than resuming the count from the previous PV.
000000 LD 000000
000001 TIM 0001
#9000
000002 LD T0001
000003 TIM 0002
#9000
000004 LD T0002
000005 OUT 000200
000000
T0001
T0002
Instruction OperandsAddress
000000 LD 010000
000001 LD 000001
000002 CNT 0002
#0100
000003 LD 000000
000004 AND NOT 010000
000005 AND NOT C0002
000006 TIM 0001
#0050
000007 LD T0001
000008 OUT 010000
000009 LD C0002
000010 OUT 000201
Instruction Operands
Count up
Address
Start