Act once per press
A button stays on for many scans. Without a one-shot, a rung that adds 1 adds it every scan.
Step by step
Pick a step. The rungs are drawn by the editor after Core scans the program up to that step.
1. Nothing pressed. Both rungs are false. ONS stores that the rung is off.
2. Press AddPB. AddPB has just turned on. ONS passes power for this scan, so both rungs add 1.
3. Hold, scan 2. AddPB is still on. ONS blocks power because it was already on last scan. Only rung 1 adds.
4. Hold, scan 3. Same again. WithoutONS counts every scan the button is held.
5. Release AddPB. Both rungs are false. ONS remembers that the rung is off.
6. Press again. A new rising edge. ONS passes for one scan and WithONS reaches 2.
| Step | AddPB | WithONS | WithoutONS |
|---|---|---|---|
| 1. Nothing pressed | 0 | 0 | 0 |
| 2. Press AddPB | 1 | 1 | 1 |
| 3. Hold, scan 2 | 1 | 1 | 2 |
| 4. Hold, scan 3 | 1 | 1 | 3 |
| 5. Release AddPB | 0 | 1 | 3 |
| 6. Press again | 1 | 2 | 4 |
How the edge is caught
ONS keeps the rung's state from the last scan. It passes power only on the scan where the rung is on now and was off last scan.
Why it works
- The ONS sits after the condition, so it sees the rung turning on, not the button itself.
- Every instruction after the ONS gets power for one scan per press, however long the button is held.
- Use OSF instead to act once when the rung turns off.
Common mistakes
- ONS before the conditionAn ONS at the start of the rung sees power that is always on. Put it right after the conditions it should watch.
- Counting with CTU and an ONSA CTU already counts only rising edges. It does not need an ONS in front of it.