Up/down counting
An entry sensor adds 1 and an exit sensor takes 1 away, so ACC is the number of parts in the buffer.
Step by step
Pick a step. The rungs are drawn by the editor after Core scans the program up to that step.
Global.InEyeXIC
Global.BufferCTU
PRE 2 ACC 1 CU 1 CD 0 DN 0 OV 0 UN 0
Global.OutEyeXIC
Global.BufferCTD
PRE 2 ACC 1 CU 1 CD 0 DN 0 OV 0 UN 0
Global.Buffer.DNXIC
Global.BufferFullOTE
1. Part in. The CTU adds 1. ACC is 1.
Global.InEyeXIC
Global.BufferCTU
PRE 2 ACC 1 CU 0 CD 0 DN 0 OV 0 UN 0
Global.OutEyeXIC
Global.BufferCTD
PRE 2 ACC 1 CU 0 CD 0 DN 0 OV 0 UN 0
Global.Buffer.DNXIC
Global.BufferFullOTE
2. Gap. Nothing changes.
Global.InEyeXIC
Global.BufferCTU
PRE 2 ACC 2 CU 1 CD 0 DN 1 OV 0 UN 0
Global.OutEyeXIC
Global.BufferCTD
PRE 2 ACC 2 CU 1 CD 0 DN 1 OV 0 UN 0
Global.Buffer.DNXIC
Global.BufferFullOTE
3. Part in. ACC is 2, which reaches PRE. DN turns on BufferFull.
Global.InEyeXIC
Global.BufferCTU
PRE 2 ACC 1 CU 0 CD 1 DN 0 OV 0 UN 0
Global.OutEyeXIC
Global.BufferCTD
PRE 2 ACC 1 CU 0 CD 1 DN 0 OV 0 UN 0
Global.Buffer.DNXIC
Global.BufferFullOTE
4. Part out. The CTD takes 1 away from the same ACC. ACC is 1 and BufferFull turns off.
Global.InEyeXIC
Global.BufferCTU
PRE 2 ACC 1 CU 0 CD 0 DN 0 OV 0 UN 0
Global.OutEyeXIC
Global.BufferCTD
PRE 2 ACC 1 CU 0 CD 0 DN 0 OV 0 UN 0
Global.Buffer.DNXIC
Global.BufferFullOTE
5. Gap. ACC stays at 1.
| Step | InEye | OutEye | Buffer.ACC | BufferFull |
|---|---|---|---|---|
| 1. Part in | 1 | 0 | 1 | 0 |
| 2. Gap | 0 | 0 | 1 | 0 |
| 3. Part in | 1 | 0 | 2 | 1 |
| 4. Part out | 0 | 1 | 1 | 0 |
| 5. Gap | 0 | 0 | 1 | 0 |
Why it works
- CTU and CTD name the same COUNTER tag, so they share one ACC.
- Each counts only when its own rung turns on, so a part held in front of a sensor counts once.
- DN is on while ACC is at or above PRE, here when the buffer holds 2 parts.
Common mistakes
- Two counter tagsA CTU on one tag and a CTD on another cannot share a total. Use one tag for both.