Contacts (input instruction)

ONS: One Shot (rising edge)

True for exactly one scan, on the scan where the conditions before it go from false to true.

Also called: OSR, rising edge, positive transition, P trigger, R_TRIG.

ONS(tag)

What it does

A one shot turns a level into an event. The conditions to its left may stay true for ten minutes; ONS lets power through on the first scan of those ten minutes and never again until they go false and true once more.

That matters because a PLC re-evaluates every rung thousands of times a second. An operator pressing a button holds it for perhaps a quarter of a second, which on a 10 ms scan is twenty-five scans. Feed that straight into a counter and you count twenty-five parts from one press. Put a one shot in front of it and you count one.

The storage bit that ONS takes is not decoration and it is not shared. The instruction uses it to remember what the conditions looked like on the previous scan, which is the only way it can tell an edge from a level. Two instructions pointing at the same storage bit will interfere with each other in ways that are extremely hard to see on a running machine.

A rung you can run

One press, one count

[object Object]
XIC(Part_Sensor)ONS(Part_Edge)CTU(Part_Count,500)
XIC(Part_Count.DN)OTE(Batch_Full)

Without the ONS, the counter would increment on every scan the sensor is blocked, which for a part passing at conveyor speed is dozens of counts for one part.

Run this rung in the simulator

What it is called on other controllers

PlatformEquivalent
Rockwell (Studio 5000)ONS as an input instruction, OSR as an output instruction
Rockwell (PLC-5 and SLC-500)OSR, placed in the rung condition
Siemens (TIA Portal)P trigger, drawn -|P|-
Mitsubishi (GX Works)PLS
CODESYS and IEC 61131-3R_TRIG function block

Common mistakes

  • Reusing one storage bit for two one shots. Each ONS needs its own, and the symptom of sharing one is an edge that sometimes does not fire.
  • Putting the one shot after the output instead of before it. It belongs in the rung condition, where it gates what follows.
  • Reaching for a one shot when the real problem is a bouncing input. A contact that chatters produces many genuine edges; that needs a debounce timer, not an edge detector.

Practise it

Interactive exercises that use ONS. Each one checks your ladder against a real scan.

Related instructions

All ladder logic instructions