1. Count up CTU
1. Count up CTU
1.1. Instruction Description
Every time the input energy flow transitions from closed to open, the Count Up (CTU) instruction counts up from the current value. When the current value (CVxxx) is greater than or equal to the preset value (SV), the counter bit (Cxxx) is turned on. When reaching the maximum value (32767 or 2147483647), the counter stops counting. Performing a reset operation can reset the counter, that is, the counter bit (Cxxx) is set to 0, and the current value of the counter (CVxxx) is set to 0.
Counter range: CVxxx=CV0 to CV255; Cxxx=C0 to C255.
| Counter Type | Counter Bit Number | Maximum Value | Counter Number |
|---|---|---|---|
| CTU | 16 bits | 32767 | C0-C199 |
| CTU | 32-bit | 2147483647 | C200 – C234 |
| CTU | 32-bit (high-speed) | 2147483647 | C235-C255 |
Note: Since each counter has a current value, do not set the same counter number to more than one counter (up and down counters with the same number access the same current value).
1.2. The valid operands of the instruction
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| CV | 16 bit integer | CV | Counter |
| SV | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | preset value |
1.3. Example
Command table:
NETWORK 000
LD X000
CTU CV0 D0 // The counter starts counting upwards from the current value CV0, and the set value (SV) is D0
NETWORK 001
LD C0
OUT Y000
图1 CTU