290
UDCNT2
1. With the UDCNT2 instruction, the argument device data is registered in the work area of the CPU module and counting
operation is processed as a system interrupt. (The device data registered in the work area is cleared by turning the
execution command OFF, or turning the STOP/RUN switch STOP RUN.) For this reason, the pulses that can be counted
must have longer ON and OFF times than the interrupt interval of the CPU module. The interrupt interval of individual
modules is shown below:
2. The set value cannot be changed during counting directed by the UDCNT2 instruction (while the execution command is
ON). To change the set value, turn OFF the execution command.
3. Counters designated by the UDCNT2 instruction cannot be used by any other instruction. If they are used by other
instructions, they will not be capable of returning an accurate count.
4. The UDCNT2 instruction can be used as many as 5 times within all the programs being executed. The sixth and the
subsequent UDCNT2 instructions are not processed.
Operation Error
(1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
Program Example
(1) The following program performs a count operation as instructed by C0 (count up or down) on the status of X0 and X1
after X20 has gone ON.
[Ladder Mode]
[List Mode]
[Operation]
CPU Module Type Name
Interrupt Interval
High Performance model QCPU, Process CPU,
Universal model QCPU, LCPU
1 ms
Error
code
Error details
Q00J/
Q00/
Q01
QnH
QnPH QnPRH
QnU
LCPU
4101
The device specified by exceeds the range of the corresponding
device.
––
––
S
Step
Instruction
Device
X0
X20
X1
COM present value
C0 contact
1
0
2
3
4
5
4
3
2
1
0
1
2
1
1