Omron CP1E-NA@@D@-@ Computer Hardware User Manual


 
2 Instructions
2-62
CP1E CPU Unit Instructions Reference Manual(W483)
Example Timer and Counter Applications
Example 1: Long-term Timers
The following program examples show three ways to create long-term timers with standard TIM and
CNT instructions.
1) Two TIM Instructions
In this example, two TIM instructions are combined to make a 30-minute timer.
2) 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 combi-
nation 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.
3) 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 (A200.11) is ORed with the counter’s reset input (CIO 0.01), the counter’s PV will
be reset to the SV (0700) when program execution begins rather than resuming the count from the pre-
vious PV.
TIM
0001
#9000
0.00
TIM
0002
#9000
T0001
T0002
100.00
(900 seconds)
(900 seconds)
Instruction Operands
0.00
1
#9000
T0001
2
#9000
T000
100.00
LD
TM
LD
TM
LD
OUT
CNT
0002
#0100
100.00
100.01
TIM
0001
#0050
100.00
0.01
T0001
C0002
0.00 100.00 C0002
OperandsInstruction
Count upStart
(100 times)
(5 seconds)
100.00
0.01
2
#0100
0.00
100.00
C0002
1
#0050
T0001
100.00
C0002
100.01
LD
LD
CNT
LD
AND NOT
AND NOT
TIM
LD
OUT
LD
OUT
CNT
0001
#0700
0.00
0.01
A200.11
C0001
100.02
P_1s (1-s clock)
Instruction
Operands
0.00
1s
0.01
1
#0700
C0001
100.02
LD
AND
LD NOT
CNT