ladder logic

one-shot

edge detection

One-Shot Rising Edge in Ladder Logic: OSR Explained

‌
PLC ladder logic rung showing an OSR one-shot rising instruction converting a sustained input signal into a single-scan output pulse

The one-shot rising instruction is one of those things that looks trivial until you skip it and spend an afternoon wondering why your counter is reading 4,000 when the operator only pressed the button twice. Every working PLC programmer has that story. The OSR instruction solves a specific, concrete problem: turning a sustained TRUE signal into a single-scan pulse so downstream logic runs exactly once per trigger event.

What Is a One-Shot Rising Edge Instruction in Ladder Logic?

A one-shot rising (OSR) instruction monitors its rung condition and produces a TRUE output for exactly one PLC scan the moment that condition transitions from FALSE to TRUE. On every subsequent scan while the condition stays TRUE, the output is FALSE. The output returns to FALSE immediately on the scan after the trigger, regardless of how long the input stays high. This converts any sustained signal into a single-scan pulse that downstream instructions can act on without repeating.

Why You Need It: The Scan Cycle Problem

To understand why OSR exists, you need to remember how the PLC scan cycle works. The CPU evaluates every rung, every scan, typically at 1 to 20 ms intervals. If you wire a pushbutton directly to a CTU counter contact, and the operator holds the button for 500 ms, the counter will increment on every scan during that 500 ms. At a 10 ms scan time that is 50 counts from one button press.

The same problem hits recipe loads, alarm latches, valve toggles, and any logic that should fire once per event. A one-shot is the right fix. It is not a workaround, it is the designed solution. Understanding this also explains why PLC internal bits and flags matter so much: the OSR needs a dedicated bit to store its previous state, and that bit has to live somewhere reliable.

The Storage Bit: What It Does and Why It Must Be Unique

Every OSR instruction requires a storage bit. This is an internal memory bit that the instruction writes to each scan. The OSR logic is simple:

  • If rung is TRUE and storage bit is FALSE: fire the output TRUE, set storage bit TRUE.
  • If rung is TRUE and storage bit is TRUE: output stays FALSE (already fired).
  • If rung is FALSE: output is FALSE, clear storage bit FALSE so the next rising edge can fire again.

The gotcha that catches every newcomer: you must assign a unique storage bit to every OSR in the program. If two OSR instructions share the same bit, the second one reads a bit already set by the first and never fires. In Studio 5000 you would use unique BOOL tags, for example OSR_RecipeLoad_Storage and OSR_FaultDetect_Storage. Never use a generic OSR_Bit1 and then reuse it three rungs down.

Field gotcha: On a packaging line commissioning I found a fault-latch routine that was never triggering. The root cause was two OSR instructions sharing a single storage bit in a copied rung. The copy-paste brought the same tag name along. The fault alarm fired intermittently, maybe once every 30 seconds, because the scan cycle timing occasionally let one OSR reset before the other read it. It took two hours to find. Name your storage bits descriptively and check for duplicates.

OSR vs ONS in Studio 5000 Logix

Rockwell Allen-Bradley gives you two options in Studio 5000. OSR (One-Shot Rising) is a coil-style output instruction. You place it on the right side of the rung, and it passes the one-shot pulse to the bit you assign. ONS (One-Shot) is a contact-style instruction placed inline in the rung condition. The rung power flows through ONS for one scan on a rising edge, then blocks. Both do the same job.

InstructionPlacementStyleBest for
OSRRight side of rung (output)CoilWriting a one-shot bit used by multiple downstream rungs
ONSInline in rung condition (contact)ContactSingle-rung edge detection, cleaner to read inline
OSFRight side of rung (output)CoilDetecting falling edge (TRUE to FALSE transition)
OSR, ONS and OSF instruction comparison in Studio 5000

In practice, most experienced Logix programmers prefer ONS for inline use because it reads naturally left to right. OSR is useful when you want to generate a one-shot bit that several rungs below can all XIC on. Both are legitimate. Just do not mix up the storage bit assignment.

One-Shot Rising Edge in Siemens TIA Portal

Siemens handles edge detection differently. In TIA Portal ladder, you use a P contact (positive edge detection contact) directly in the rung. It behaves like a contact that passes power for one scan on a rising edge. There is also the P_TRIG function block if you need the edge detection result as a bit you can reference elsewhere. The P contact approach is the most compact and is what you will see in most S7-1200 programs in TIA Portal.

One difference from Logix: the Siemens P contact stores its state internally within the block's instance data, so you do not manually assign a storage bit. This removes the duplicate-bit problem but also means you cannot easily inspect the storage state from outside the rung. For S7-1200 timers and counters that need edge-triggered inputs, the P contact is the go-to.

One-Shot Rising Edge Ladder Logic Example: Counter Increment

Here is a real-world example: a proximity sensor on a conveyor counts products passing a gate. The sensor output stays TRUE for roughly 200 ms per part. Without a one-shot, a CTU counter driven directly by the sensor XIC contact would increment every scan during those 200 ms. At a 5 ms scan time that is 40 false counts per part. With an OSR or ONS, you get exactly one count per part.

Product Counter with ONS Rising-Edge Debounce (Studio 5000). Ladder logic (3 rungs): Rung 0: examine if ProxSensor_Part is on (XIC), then examine if Prox_EdgeStorage is on (XIC), then CTU on Part_Counter. Rung 1: examine if Part_Counter.DN is on (XIC), then examine if Batch_Done_OS is on (XIC), then latch output Batch_Done_Latch (OTL). Rung 2: examine if Batch_Done_Latch is on (XIC), then examine if HMI_BatchReset is on (XIC), then unlatch output Batch_Done_Latch (OTU), then either RES on Part_Counter. Rung 1: The proximity sensor contact passes through an ONS instruction (storage bit: Prox_EdgeStorage) so CTU only increments once per part, regardless of how long the sensor stays TRUE. Rung 2: When the counter reaches its preset (DN bit), an OSR fires once to set Batch_Done_Latch using OTL. The OSR storage bit (Batch_Done_Storage) prevents the latch from being re-set on every scan while DN stays TRUE. Rung 3: The operator resets the batch by acknowledging at the HMI, which resets both the latch and the counter.

Product Counter with ONS Rising-Edge Debounce (Studio 5000)Ladder logic
Toggle inputs
Rung 0
Ladder logic rung: examine if ProxSensor_Part is on (XIC), then examine if Prox_EdgeStorage is on (XIC), then CTU on Part_Counter examine if ProxSensor_Part is on (XIC), then examine if Prox_EdgeStorage is on (XIC), then CTU on Part_Counter XIC ProxSensor_Part ProxSensor_Part ProxSensor_Part ONS Prox_EdgeStorage Prox_EdgeStorage Prox_EdgeStorage ONS CTU Part_Counter 9999 0 CTUCounterPart_CounterPart_CounterPreset99999999Accum00
Rung 1
Ladder logic rung: examine if Part_Counter.DN is on (XIC), then examine if Batch_Done_OS is on (XIC), then latch output Batch_Done_Latch (OTL) examine if Part_Counter.DN is on (XIC), then examine if Batch_Done_OS is on (XIC), then latch output Batch_Done_Latch (OTL) XIC Part_Counter.DN Part_Counter.DN Part_Counter.DN OSR Batch_Done_OS Batch_Done_Storage Batch_Done_OS Batch_Done_OS OSR Batch_Done_Storage Batch_Done_StorageOTL Batch_Done_Latch Batch_Done_Latch Batch_Done_Latch L
Rung 2
Ladder logic rung: examine if Batch_Done_Latch is on (XIC), then examine if HMI_BatchReset is on (XIC), then unlatch output Batch_Done_Latch (OTU), then either RES on Part_Counter examine if Batch_Done_Latch is on (XIC), then examine if HMI_BatchReset is on (XIC), then unlatch output Batch_Done_Latch (OTU), then either RES on Part_Counter XIC Batch_Done_Latch Batch_Done_Latch Batch_Done_Latch XIC HMI_BatchReset HMI_BatchReset HMI_BatchReset OTU Batch_Done_Latch Batch_Done_Latch Batch_Done_Latch U RES Part_Counter RESAccumulatorPart_CounterPart_Counter
energizedTip: click a contact in the diagram to flip its bit.
Rung 1: The proximity sensor contact passes through an ONS instruction (storage bit: Prox_EdgeStorage) so CTU only increments once per part, regardless of how long the sensor stays TRUE. Rung 2: When the counter reaches its preset (DN bit), an OSR fires once to set Batch_Done_Latch using OTL. The OSR storage bit (Batch_Done_Storage) prevents the latch from being re-set on every scan while DN stays TRUE. Rung 3: The operator resets the batch by acknowledging at the HMI, which resets both the latch and the counter.

Notice the two distinct storage bits: Prox_EdgeStorage for the ONS on rung 1, and Batch_Done_Storage for the OSR on rung 2. They are different bits doing different jobs. This is a pattern you will use constantly. For a deeper look at CTU and CTD instructions, see PLC Counter Instructions: CTU, CTD and CTUD Explained.

Common Use Cases for One-Shot Instructions

  • Counter increments from sensors or pushbuttons (the classic case above).
  • Triggering a fault latch via OTL on the rising edge of a fault bit, so the latch fires once and holds. See OTL and OTU Latch Coils in Ladder Logic Explained for how latch coils pair with one-shots.
  • Loading a recipe or preset value into a working register when an HMI button is pressed.
  • Toggling an output state: XOR the current state with a one-shot pulse to flip it.
  • Initiating a timed sequence: the one-shot sets a bit that enables a TON timer on the next rung. Mixing edge detection with timers is covered in TON, TOF and TONR Timers: What Actually Differs.
  • Alarm acknowledgement: detect the rising edge of an HMI ACK button to clear a latched fault without the clear logic running every scan.

Troubleshooting One-Shot Logic That Is Not Firing

When a one-shot seems stuck or never fires, work through these checks:

  1. Go online and watch the storage bit. If it is permanently TRUE, the rung condition never went FALSE, so the OSR can never see a new rising edge. Find out why the rung condition is stuck. PLC Troubleshooting with Online Monitoring covers exactly this technique.
  2. Check for duplicate storage bits. Search your project for the storage bit tag name and confirm it appears only once as an OSR or ONS operand.
  3. Check the rung condition, not just the OSR. If the XIC contacts feeding the OSR are not all energized simultaneously for at least one scan, the one-shot never fires. Use online monitoring to check each contact state individually.
  4. Verify scan time vs signal duration. If the input signal is shorter than one scan cycle, the PLC may miss it entirely. A 2 ms pulse on a 10 ms scan will be missed roughly 80% of the time. For short pulses you need hardware input filtering disabled and possibly a faster task. See PLC Scan Cycle Problems: Logic and Timing Faults for scan-time edge cases.
  5. Check for a forced state. A forced TRUE on the storage bit prevents the rising-edge detection from seeing any new transition.

One-Shot vs Latch Coil: Choosing the Right Tool

A one-shot and an OTL latch coil are often used together, but they are not interchangeable. The one-shot produces a single-scan pulse. The OTL latch coil holds a bit TRUE until explicitly cleared with OTU. The typical pattern is: OSR detects the event edge, OTL captures the result into a held state, and OTU clears it when the operator acknowledges. If you drive an OTL directly from a sustained contact, it will keep setting every scan but will still hold after the contact goes FALSE, so functionally it works. But driving OTL from an OSR is cleaner and avoids any ambiguity about when the latch was set. Check Ladder Logic Interlocks: How They Work and Why for how latches and interlocks combine in real sequences.

Also worth knowing: in Studio 5000 you can use XIC and XIO contacts on the output bit of the OSR to feed multiple downstream rungs from a single one-shot event. One OSR sets a BOOL tag, and three rungs below each XIC on that tag. All three fire for that one scan. This is cleaner than putting three separate OSR instructions on three separate rungs, and it avoids the storage-bit duplication trap.

Timing diagram for PLC one-shot rising OSR instruction showing input signal, storage bit state, and single-scan output pulse across multiple scan cycles
The OSR output is TRUE for exactly one scan. The storage bit stays TRUE while the rung condition is TRUE, preventing re-firing.

Falling Edge Detection: OSF and N Contacts

Everything above applies equally to falling-edge detection. Studio 5000 OSF (One-Shot Falling) fires for one scan when the rung condition transitions from TRUE to FALSE. Siemens uses an N contact in TIA Portal ladder. Falling-edge one-shots are useful for detecting the end of a cycle, the moment a part leaves a sensor, or when a VFD run-confirm drops. The storage bit rules are identical: unique bit per instruction, never shared.


One-shot instructions make the most sense once you understand the broader context of how contacts, coils, and internal bits work together. Start with XIC vs XIO: Ladder Logic Contacts Explained if contacts still feel fuzzy, then move to OTL and OTU Latch Coils in Ladder Logic Explained to see how one-shots and latches combine. For a full practical project that uses edge detection inside a sequence, the PLC Bottle Filling Machine: Step-by-Step Project is a good next challenge.

Related Blogs

Flat vector diagram comparing XIC and XIO ladder logic contact symbols with bit-state labels showing how each instruction evaluates its tag
ladder logicallen-bradleystudio 5000

XIC vs XIO: Ladder Logic Contacts Explained

XIC and XIO are the two most fundamental contacts in Allen-Bradley ladder logic. Learn exactly how each evaluates its bit, where to use them, and the mistakes that catch beginners out.

9 min read

Flat vector ladder logic diagram showing OTL latch coil and OTU unlatch coil rungs with a shared retentive bit and memory icon
ladder logiclatching coilplc programming

OTL and OTU Latch Coils in Ladder Logic Explained

OTL and OTU latch coils hold state through a power cycle. Learn how they work in ladder logic, how they differ from seal-in rungs, and when each belongs in your program.

8 min read

Flat vector infographic showing four ladder logic interlock rung patterns for PLC programming, including permissive, mutual exclusion, run confirm and safety guard circuits
ladder logicinterlocksplc programming

Ladder Logic Interlocks: How They Work and Why

Ladder logic interlocks stop dangerous or invalid machine states before they happen. Learn the four core interlock patterns, see real rung examples, and avoid the wiring gotchas that bite engineers on commissioning day.

8 min read

CTU CTD and CTUD PLC counter instructions diagram showing preset and accumulated count values
countersladder logicplc programming

PLC Counter Instructions: CTU, CTD and CTUD Explained

CTU, CTD and CTUD counters explained with real preset values, accumulated counts, reset behaviour, and vendor-specific differences you need to know.

9 min read

TON TOF TONR PLC timer comparison diagram showing input and output timing waveforms
timersladder logicplc programming

TON, TOF and TONR Timers: What Actually Differs

TON, TOF and TONR timers behave very differently under power loss and input cycling. Here's exactly how each one works, with real ladder examples and common gotchas.

7 min read

Flat vector diagram of a PLC rack with internal bit memory cells highlighted in teal and grey showing how internal flags connect input and output logic rungs
internal bitsplc flagsladder logic

PLC Internal Bits: Flags, Coils and How to Use Them

Internal bits, flags and internal coils let your PLC logic communicate with itself across rungs. Learn what they are, how to use them correctly, and the gotchas that trap beginners.

9 min read

Flat vector infographic of the PLC scan cycle showing four phases arranged in a circle: input scan, program execution, output scan, and housekeeping with connecting arrows
plc scan cycleplc basicsladder logic

How the PLC Scan Cycle Works: Step by Step

The PLC scan cycle is the heartbeat of every control system. Learn exactly what happens during input scan, program execution, and output scan, with real numbers and field gotchas.

10 min read