Sample program, 2 instructions, Range comparison – Omron SYSMAC CP CP1E-N@@D@-@ User Manual
Page 354
2 Instructions
2-318
CP1E CPU Unit Instructions Reference Manual(W483)
Range Comparison
The corresponding interrupt task is called and executed when the PV enters a set range.
• The same interrupt task number can be specified for more than one target value.
• The range comparison table contains 6 ranges, each of which is defined by a lower limit and an upper
limit. If a range is not to be used, set the interrupt task number to FFFF hex to disable the range.
• The interrupt task is executed only once when the PV enters the range.
If the PV is within more than one range when the comparison is made, the interrupt task for the range
closest to the beginning of the table will be given priority and other interrupt tasks will be executed in
following cycles.
• If there is no reason to execute an interrupt task, specify AAAA hex as the interrupt task number. The
range comparison results can be read with PRV(881) or using the Range Comparison In-progress
Flags.
Note An error will occur if the upper limit is less than the lower limit for any one range.
Sample program
When CIO 0.00 turns ON in the following programming example, CTBL(882) registers a target value
comparison table and starts comparison for high-speed counter 0. The PV of the high-speed counter is
counted incrementally and when it reaches 500, it equals target value 1 and interrupt task 1 is exe-
cuted. When the PV is incremented to 1000, it equals target value 2 and interrupt task 2 is executed.
@CTBL
#0000
#0000
D100
0002
01F4
0000
0001
03E8
0000
0002
0.00
D100
D101
D102
D103
D104
D105
D106
Two target values
Target value 1: 0000 01F4 hex (500)
Incrementing, Interrupt task number 1
Target value 2: 0000 03E8 hex (1000)
Incrementing, Interrupt task number 2
Register target comparison table
and start comparison
High-speed counter input 0