Count up CTU
Adds 1 each time the rung turns on. DN is on at PRE.
Global.BoxesCTU
PRE 12 ACC 1 CU 1 CD 0 DN 0 OV 0 UN 0
| Tag | After two scans |
|---|---|
| Boxes | PRE 12 ACC 1 CU 1 CD 0 DN 0 OV 0 UN 0 |
How it works
Adds 1 to ACC on each false-to-true rung change; holding the rung true does not count again. DN is 1 while ACC is at or above PRE.
How it's used
Use CTU to count events: parts past a sensor, presses of a button.
Global.PartEyeXIC
Global.PartsCTU
PRE 2 ACC 2 CU 1 CD 0 DN 1 OV 0 UN 0
Global.Parts.DNXIC
Global.BoxFullOTE
| Tag | Value |
|---|---|
| PartEye | 1 |
| Parts | PRE 2 ACC 2 CU 1 CD 0 DN 1 OV 0 UN 0 |
| BoxFull | 1 |
Two parts passed. Parts.DN turned BoxFull on.
Operands
| Operand | Data type | Read or write |
|---|---|---|
| Counter | COUNTER | Reads and writes |
Inside a COUNTER tag
| Member | Type | Meaning |
|---|---|---|
| .PRE | DINT | You can write it |
| .ACC | DINT | Read only |
| .CU | BOOL | Read only |
| .CD | BOOL | Read only |
| .DN | BOOL | Read only |
| .OV | BOOL | Read only |
| .UN | BOOL | Read only |
Common mistakes
- Counting scans instead of eventsThis counter counts false-to-true transitions. A held true rung counts once.
Learn it in a lesson
- Counting eventsIntermediate · 25 min