Omron C20K Video Game Controller User Manual


 
92
Because in this example the SV for CNT 01 is 100 and the SV for CNT 02 is
200, the completion flag for CNT 02 turns ON when 100 x 200 or 20,000 OFF
to ON changes have been counted in 0001. This would result in 0203 being
turned ON.
0203
CP
R
CNT 01
#0100
CP
R
CNT 02
#0200
CNT 01
0002
CNT 02
0000 0001
0002
CNT 01
CNT 02
Address Instruction Operands
0000 LD 0000
0001 AND 0001
0002 LD NOT 0002
0003 OR CNT 01
0004 OR CNT 02
0005 CNT 01
# 0100
0006 LD CNT 01
0007 LD NOT 0002
0008 CNT 02
# 0200
0009 LD CNT 02
0010 OUT 0203
CNT can be used in sequence as many times as required to produce count-
ers capable of counting down even higher 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 02 counts the number of times TIM 01
reaches zero from its SV. The completion flag for TIM 01 is used to reset TIM
01 so that is runs continuously and CNT 02 counts the number of times the
completion flag for TIM 01 goes ON (CNT 02 would be executed once each
time between when the completion flag for TIM 01 goes ON and TIM 01 is
reset by its completion flag). TIM 01 is also reset by the completion flag for
CNT 02 so that the extended timer would not start again until CNT 02 was
reset by 0001, which serves as the reset for the entire extended timer.
As the SV for TIM 01 is 5.0 seconds and the SV for CNT 02 is 100, the com-
pletion flag for CNT 02 turns ON when 5 seconds x 100 times, or 8 minutes
and 20 seconds have expired. This would result in 0201 being turned ON.
0000 TIM 01 CNT 02
TIM 01
0001
CNT 02
0200
CP
R
CNT 02
#0100
Address Instruction Operands
0000 LD 0000
0001 AND NOT TIM 01
0002 AND NOT CNT 02
0003 TIM 01
# 0050
0004 LD TIM 01
0005 LD 0001
0006 CNT 02
# 0100
0007 LD CNT 02
0008 OUT 0200
TIM 01
#0050
In the following example, CNT 01 counts the number of times the 1-second
clock pulse bit (1902) goes from OFF to ON. Here again, 0000 is used to
control when CNT is operating.
Example 3:
Extended Timers
Timer and Counter Instructions Section 5-11