882
7 APPLICATION INSTRUCTIONS
7.13 Special Counter Instructions
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.
• Count processing is performed as follows.
• 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
• 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.
• (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.
• 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.
(1) When counting up
(2) When counting down
(1) Current value of C0
(2) Contact of C0
32766 → 32767
-2 → -1 → 0 → 1 → 2
-32768 → -32767
(1)
(2)
X20
C0
UDCNT2
X0
END
K3
-1
-1
-2
-1
0
1
2
3
4
5
4
3
2
0 1
X1
X20
X0
(2)
(1)
Summary of Contents for MELSEC iQ-R Series
Page 1: ...MELSEC iQ R Programming Manual Instructions Standard Functions Function Blocks ...
Page 2: ......
Page 24: ...22 INDEX 2092 INSTRUCTION INDEX 2093 REVISIONS 2104 WARRANTY 2105 TRADEMARKS 2106 ...
Page 34: ...32 MEMO ...
Page 35: ...33 PART 1 PART 1 OVERVIEW This part consists of the following chapter 1 OVERVIEW ...
Page 68: ...66 1 OVERVIEW 1 5 Precautions on Programming MEMO ...
Page 1448: ...1446 14 REDUNDANT SYSTEM INSTRUCTIONS 14 2 Disabling Enabling System Switching MEMO ...
Page 1972: ...1970 33 TIME DATA TYPE FUNCTIONS 33 4 Division MEMO ...
Page 2067: ...APPX Appendix 5 PID Control Program Examples 2065 A 252 Set PID control data for loop 2 ...
Page 2109: ......