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.

StepAddPBWithONSWithoutONS
1. Nothing pressed000
2. Press AddPB111
3. Hold, scan 2112
4. Hold, scan 3113
5. Release AddPB013
6. Press again124

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.

Run turns on at scan 3 and off at scan 7. ONS is on only in scan 3, the first scan where Run is on and Last scan is off.12345678ScanRunLast scanONSOSFRisingFalling

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.

Instructions used

Related