Omron C200HX Computer Hardware User Manual


 
168
The previously-shown CNT can be modified to restart from SV each time power
is turned ON to the PC. This is done by using the First Cycle Flag in the SR area
(25315) to reset CNT as shown below.
00000
CP
R
CNT 004
#0150
00002
00001
00205
CNT 004
25315
Address Instruction Operands
00000 LD 00000
00001 AND 00001
00002 LD 00002
00003 OR 25315
00004 CNT 004
# 0150
00005 LD CNT 004
00006 OUT 00205
Counters that can count past 9,999 can be programmed by using one CNT to
count the number of times another CNT has counted to zero from SV.
In the following example, 00000 is used to control when CNT 001 operates. CNT
001, when 00000 is ON, counts down the number of OFF to ON changes in
00001. CNT 001 is reset by its Completion Flag, i.e., it starts counting again as
soon as its PV reaches zero. CNT 002 counts the number of times the Comple-
tion Flag for CNT 001 goes ON. Bit 00002 serves as a reset for the entire ex-
tended counter, resetting both CNT 001 and CNT 002 when it is OFF. The
Completion Flag for CNT 002 is also used to reset CNT 001 to inhibit CNT 001
operation, once SV for CNT 002 has been reached, until the entire extended
counter is reset via 00002.
Because in this example the SV for CNT 001 is 100 and the SV for CNT 002 is
200, the Completion Flag for CNT 002 turns ON when 100 x 200 or 20,000 OFF
to ON changes have been counted in 00001. This would result in 00203 being
turned ON.
00203
CP
R
CNT 001
#0100
CP
R
CNT 002
#0200
CNT 001
00002
CNT 002
00000 00001
00002
CNT 001
CNT 002
Address Instruction Operands
00000 LD 00000
00001 AND 00001
00002 LD NOT 00002
00003 OR CNT 001
00004 OR CNT 002
00005 CNT 001
# 0100
00006 LD CNT 001
00007 LD NOT 00002
00008 CNT 002
# 0200
00009 LD CNT 002
00010 OUT 00203
CNT can be used in sequence as many times as required to produce counters
capable of counting any desired values.
CNT can be used to create extended timers in two ways: by combining TIM with
CNT and by counting SR area clock pulse bits.
In the following example, CNT 002 counts the number of times TIM 001 reaches
zero from its SV. The Completion Flag for TIM 001 is used to reset TIM 001 so
that it runs continuously and CNT 002 counts the number of times the Comple-
tion Flag for TIM 001 goes ON (CNT 002 would be executed once each time be-
Example 2:
Extended Counter
Example 3:
Extended Timers
Timer and Counter Instructions Section 5-14