Mitsubishi Electric MELSEC iQ-R Series Programming Manual page 882

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

Advertisement

Processing details
• When the input specified by (s1) is turned on, this instruction updates the current value of the counter specified by (d).
• Counting up or down is determined by whether the input specified by (s1)+1 is on or off.
• Off: Count-up (counting up the current value)
• On: Count-down (counting down the current value)
• 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 UDCNT1 instruction.
Ex.
Program which uses C0 (up/down counter) to count the number of times X0 turns off and on after X20 turns on
X20
UDCNT1
(1) Current value of C0
(2) Contact of C0
• When executed, the UDCNT1 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 UDCNT1 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 UDCNT1 instruction (while the execution
command is on). To change the set value, turn off the execution command in advance.
• The counter specified by the UDCNT1 instruction cannot be used by any other instruction. If another
instruction uses it, normal counting is disabled.
• The UDCNT1 instruction can be used a maximum of six times in all running programs. The seventh or
subsequent UDCNT1 instruction, if issued, causes no processing.
Operation error
There is no operation error.
7 APPLICATION INSTRUCTIONS
880
7.13 Special Counter Instructions
-2 → -1 → 0 → 1 → 2
(1)
(2)
X20
X0
C0
K5
X0
END
X1
(1)
(2)
32766 → 32767
Up
Down
0 1 2 3 4 5 6 7 6 5 4 3 2 1 0 1 2 3 2 1 0
Up
- - - - -
1
1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents