ONS (One Shot) is an edge-detection instruction: when the rung entering it transitions from false to true, it passes continuity for exactly one program scan, then blocks until the rung goes false and true again.
Join 1900+ learners practicing PLC programming
How it works
Ladder logic is level-based by default: a rung that is true stays true, scan after scan, for as long as its conditions hold. Plenty of real actions must happen once per event instead — add 1 to a total, index a sequence step, capture a value the instant a sensor trips. The ONS is the bridge: it remembers, in a storage bit you assign, what the rung-in condition was on the previous scan, and it only conducts on the scan where that condition changes from false to true. Hold the button down for ten seconds at a 10 ms scan and the logic downstream of the ONS still executes exactly once, not a thousand times.
The storage bit is not decoration — it is the instruction’s entire memory, and it must be unique. Give two ONS instructions the same storage bit and they corrupt each other’s edge history, producing pulses that vanish or double depending on rung order. The bit should also never be examined, forced, or written anywhere else in the program.
Allen-Bradley actually offers three one-shot flavours, and the distinction shows up in searches and interviews constantly. ONS is an input instruction: it sits in the middle of the rung and gates continuity. OSR (One Shot Rising) and OSF (One Shot Falling) are output instructions from the SLC-500 lineage: they sit at the end of a rung and pulse a separate output bit for one scan on the rising or falling edge of the rung. In Logix ladder you will mostly write ONS; in older SLC programs and in conversions you will meet OSR everywhere.
The IEC 61131-3 world does the same job with the R_TRIG and F_TRIG function blocks (rising/falling trigger) — each instance carries its own memory, so there is no shared-storage-bit trap — and Siemens ladder programmers know the same idea as the P and N edge contacts. Mitsubishi uses PLS (pulse on rising edge) and PLF (pulse on falling edge). The concept is universal; only the packaging changes.
Across vendors
| Platform | Name / syntax | Notes |
|---|---|---|
| Allen-Bradley (Studio 5000 / RSLogix) | ONS / OSR / OSF | ONS storage_bit is an input (mid-rung) instruction. OSR/OSF are output instructions that pulse an output bit on rising/falling edges — common in SLC-500 code. |
| IEC 61131-3 (CODESYS, OpenPLC) | R_TRIG / F_TRIG | Standard function blocks: trig(CLK := Sensor); IF trig.Q THEN … Each instance holds its own edge memory. |
| Siemens (TIA Portal) | P / N contacts | The -|P|- and -|N|- edge contacts in LAD (each needs a unique memory bit, same trap as ONS), plus R_TRIG/F_TRIG blocks in SCL. |
| Mitsubishi (GX Works) | PLS / PLF | PLS M0 sets M0 for one scan on the rising edge of the rung; PLF on the falling edge. |
Searches for "one shot rising" usually mean OSR by name, but in modern Studio 5000 ladder the idiomatic instruction is ONS mid-rung. Functionally all of these detect the same false-to-true transition.
In practice
| Part_Sensor ONS_1 CTU Parts_Count | |-----] [--------[ONS]-----------------[ PRE 100 ]-|
In Logix the CTU itself is edge-sensitive on its rung-in condition, but this pattern matters the moment any other instruction sits on the rung or the counter is replaced by an ADD: the ONS guarantees the downstream logic sees exactly one true scan per part. Without edge awareness, an ADD here would increment on every scan the sensor is blocked — a 10 ms scan turns one slow-moving box into hundreds of counts.
| Toggle_PB ONS_2 Lamp Lamp_Off_Req | |----] [-------[ONS]------] [--------------------( )------| | Toggle_PB ONS_3 Lamp Lamp_On_Req | |----] [-------[ONS]------]/[--------------------( )------|
A push-on/push-off button is impossible without edge detection: while the button is held, a level-based rung would flip the lamp on and off every scan, and the final state on release would be luck. The one-shots make each press a single event; the Lamp contact steers that event to either the on-request or off-request rung.
Note the two separate storage bits (ONS_2, ONS_3). Sharing one bit between the rungs is the classic mistake — the first rung’s ONS would consume the edge and the second rung would never fire.
Gotchas
Reusing a storage bit across two ONS instructions
Each ONS needs a dedicated, unique storage bit. Shared bits corrupt the edge memory: one instruction records "already seen true" and the other never pulses. Symptoms are maddeningly rung-order dependent.
Placing the ONS before the conditions instead of after
ONS detects the transition of everything to its LEFT. Put it directly after the button contact but before qualifier contacts and the pulse can be blocked by a qualifier; put it after all conditions and adding a new series condition changes when edges are detected. Decide which event you are detecting and place the ONS so exactly that expression feeds it.
Expecting a one-shot to fire on the first scan after power-up
Storage bits that retain their value through a power cycle can suppress (or create) an edge on the first scan, depending on the pre-outage state. If first-scan behaviour matters, initialize the storage bit explicitly.
Using ONS where the platform already gives you edges
Logix CTU/CTD increment on the rung’s false-to-true transition by themselves — an ONS in front of a plain counter rung is harmless but redundant. Know which instructions are already edge-sensitive before sprinkling one-shots.
Debugging with the storage bit
Forcing or toggling the storage bit from the tag monitor rewrites the instruction’s memory and fabricates or eats edges. Watch the pulsed output bit instead.
Drop the instruction on a rung in the browser simulator, toggle the inputs, and watch the rung state, accumulator values and outputs update scan by scan.
Questions
ONS (One Shot) passes rung continuity for exactly one program scan when the rung entering it transitions from false to true. It uses a dedicated storage bit to remember the previous scan’s rung state; while the input stays true, the ONS blocks until the rung has gone false and true again.
ONS is an input (mid-rung) instruction that gates continuity on a rising edge. OSR (One Shot Rising) and OSF (One Shot Falling) are output instructions — placed at the end of a rung, they pulse a separate output bit for one scan on the rung’s rising or falling edge respectively. OSR/OSF dominate older SLC-500 programs; ONS is the usual choice in Studio 5000.
A one shot rising detects the moment a condition changes from false to true and produces a single-scan pulse. In Allen-Bradley it is the OSR instruction (or ONS mid-rung); in IEC 61131-3 it is the R_TRIG function block; Siemens ladder uses the -|P|- contact and Mitsubishi uses PLS.
Almost always a storage-bit problem: two ONS/OSR instructions sharing one storage bit, the bit being written elsewhere in the program, or the bit being forced from a tag monitor. Give every edge instruction its own bit that appears nowhere else, and the pulses become deterministic.