203
Timer and Counter Instructions Section 3-5
3-5-10 Example Timer and Counter Applications
The following examples show various applications of timer and counter
instructions including long-term timers, a two-stage counter, ON/OFF delay,
one-shot bit, and flicker bit.
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.
000000 LD 0.00
000001 TIM 0001
#9000
000002 LD T0001
000003 TIM 0002
#9000
000004 LD T0002
000005 OUT 200.00
T0001
T0002
200.00
0.00
Instruction OperandsAddress
000000 LD 100.00
000001 LD 0.01
000002 CNT 0002
#100
000003 LD 0.00
000004 100.00
000005 C0002
000006 TIM 0001
#50
000007 LD T0001
000008 OUT 100.00
000009 LD C0002
000010 OUT 201.01
100.00
0.01
0.00 100.00
#100
#50
100.00
200.01
AND NOT
AND NOT
Instruction Operands
Count up
Address
Start