CTUD
CTUD (Count Up / Down)
CTUD instruction counts upward by one when Counter Up bit is set and the instruction counts downward by one when Counter Down bit is set.
| |
C | Counter device address to set |
V | Preset value |
Instruction | Device address | No. of Steps | Flag | |||||||||||||||
M | X | Y | K | L | F | T | C | S | Z | D | @D | Int. | Error | Zero | Carry | |||
CTD | C | - | - | - | - | - | - | - | o | - | - | - | - | - | 3 | - | - | - |
V | - | - | - | - | - | - | - | - | - | - | o | - | o |
When Counter Up bit is enable, CTUD instruction increments the counter by one. When Counter Down bit is enable, CTUD instruction decrements the counter by one. When disabled, the CTUD instruction retains its ACC value. When ACC value reaches preset value, counter bit is set.
The range of preset (v) : 0 ~ 65535
If Counter Up and Counter Down bit are set at the same time, the ACC value does not change.
Example)
Whenever M00 is ON, the CTUD instruction increments the counter by one. Whenever M01 is ON, the CTUD instruction decrements the counter by one.
When ACC value reaches 5, C10 and Y15 are set. (ACC ¡Ã preset : C10 and Y15 are set)
When M02 is ON, the ACC value is cleared.