Mitsubishi Electric MELSEC iQ-R Series Programming Manual page 884

Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

Processing details
• This instruction updates the current value of the counter specified by (d) depending on the status of the input (phase A
pulse) specified by (s1) and the status of the input (phase B pulse) specified by (s1)+1.
• Counting up or down is determined as follows.
• (s1)+1 is turned on while (s1) is on: Count-up (counting up the current value)
• (s1)+1 is turned off while (s1) is on: Countdown (counting down the current value)
• The instruction does not count while (s1) is off.
• Count processing is performed as follows.
• When the current value equals the value specified by (s2) during count-up, the contact of the counter specified by (d) is turned on. The current value is kept
counting even when the contact of the counter is turned on.
• When the current value equals "the set value - 1" during countdown, the contact of the counter specified by (d) is turned off.
• The counter specified by (d) is a ring counter. Counting up the counter when the current value is 32767 proceeds to -32768. Similarly, counting down the
counter when the current value is -32768 proceeds to 32767. The following figure shows the processing for counting the current value.
-32768 → -32767
(1) When counting up
(2) When counting down
• The following figure shows the operation of count processing using the UDCNT2 instruction.
Ex.
Program which uses C0 (up/down counter) to count the states of X0 and X1 after X20 turns on
X20
UDCNT2
(1) Current value of C0
(2) Contact of C0
• When executed, the UDCNT2 instruction starts counting when the execution command turns on and stops counting when
the command turns off. If the execution command is turned on again, the instruction resumes counting from the current
value with which it stopped counting previously.
• The RST instruction is used to clear the current value of the counter specified by (d) and turn off the contact.
• The UDCNT2 instruction stores the device data of the argument in the work area of the CPU module, and
performs the actual count operation using system interrupts. (The device data stored in the work area of the
CPU module is cleared by turning off the execution command or setting it to STOP then RUN.) For this
reason, the pulses that can be counted must have longer on/off time than the interval of the CPU module.
The interrupt interval of the CPU module is 1ms.
• The set value cannot be changed during counting by the UDCNT2 instruction (while the execution
command is on). To change the set value, turn off the execution command in advance.
• The counter specified by the UDCNT2 instruction cannot be used by any other instruction. If another
instruction uses it, normal counting is disabled.
• The UDCNT2 instruction can be used a maximum of five times in all running programs. The sixth or
subsequent UDCNT1 instruction, if issued, causes no processing.
Operation error
There is no operation error.
7 APPLICATION INSTRUCTIONS
882
7.13 Special Counter Instructions
-2 → -1 → 0 → 1 → 2
(1)
(2)
X20
X0
C0
K3
X0
END
X1
(1)
(2)
32766 → 32767
0 1
2
3
4
5
4
3
2
1
0
-1
-2
-1
-1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents