PLC One Shot: 5 Overlooked Edge Instructions Explained

Share:
PLC
PLC One Shot: 5 Overlooked Edge Instructions Explained

Edge detection turns a long input signal into a single scan pulse, so counters, sequences and commands fire exactly once.

ONS OSR and OSF R_TRIG and F_TRIG Edge Detection

A PLC one shot turns a rising or falling edge of an input into a pulse that lasts exactly one scan. It stops counters from racing, commands from repeating and sequences from skipping steps.

Hello everyone, today we are going to understand how a PLC one shot works, the difference between ONS, OSR and OSF, and how IEC edge blocks do the same job on other platforms.
PLC one shot

What Is a PLC One Shot?

A PLC one shot is an instruction that makes its output true for only one program scan when its input changes state. It is the software version of a pulse generator and a key idea covered in ladder logic for beginners.

Without edge detection, an input that stays on for half a second is seen as true in every scan during that time. At a 10 ms scan, that is about 50 scans, and any logic tied to that input runs 50 times.

Ladder logic rung using a one shot instruction to create a single scan pulse
Image credit: Control.com

The one shot remembers the previous state of the input in a storage bit. By comparing the old state with the new one, it knows exactly when an edge happens.

This makes it essential for counter instructions, sequence steps, recipe loads and any command that must execute once per button press.

5 Edge Instructions Across Platforms

ONS

Inline rising edge instruction that passes rung power for one scan.

Best for: simple push button commands
Allen Bradley
OSR

One Shot Rising output instruction with separate storage and output bits.

Best for: reusable rising edge bits
Allen Bradley
OSF

One Shot Falling output that pulses when the input turns off.

Best for: actions after a signal clears
Allen Bradley
R_TRIG

IEC 61131 3 function block that detects a rising edge.

Best for: structured text and FBD
IEC Standard
F_TRIG

IEC 61131 3 function block that detects a falling edge.

Best for: release and reset events
IEC Standard

Siemens uses positive and negative edge contacts, marked P and N, which need a memory bit just like OSR. The idea is identical even though the symbol looks different.

Choose ONS for quick inline logic and OSR or OSF when you want a named output bit that other rungs can use.

4 Steps Inside a One Shot Scan

1
Rising Edge Scan
Input turns on and storage bit is off, so the output goes true.
2
Next Scan
Input is still on but storage bit is set, so the output goes false.
3
Input Held
Output stays false for as long as the input remains on.
4
Input Released
Storage bit clears and the instruction is ready for the next edge.

This sequence depends completely on the PLC scan cycle. The pulse is always exactly one scan wide, whatever the scan time is.

Because the pulse is so short, you cannot see it with online monitoring most of the time. Use a counter or a latch driven by the pulse when you need to confirm it fired.

Counting Error Formula Without Edge Detection

Counts without edge = Input on time ÷ Scan time
Counts with edge = 1 per press

Worked example:
Push button held for 500 ms
Scan time = 10 ms
Counts without edge = 500 ÷ 10 = 50
Counts with edge = 1
Error without a one shot = 49 extra counts

This is the classic bug in a new programmer’s batch counter or step sequencer. One press jumps the sequence many steps forward or counts a whole batch in a moment.

Counter instructions in many PLCs already react only to the rising edge of their rung. Still, any add or move logic that runs every scan needs a PLC one shot in front of it.

ONS vs OSR vs OSF Comparison

FeatureONSOSROSF
Edge detectedRisingRisingFalling
Instruction typeInput style, inlineOutput styleOutput style
Storage bitOne bitStorage bitStorage bit
Output bitRung passesSeparate bitSeparate bit
Reuse of pulseSame rung onlyAnywhere in programAnywhere in program

Each instance must have its own storage bit. Sharing one storage bit between two one shots is a common error that makes one of them stop working, much like reusing addresses covered in PLC memory addressing.

In Studio 5000, ONS uses one BOOL tag, while OSR and OSF each need a storage bit and an output bit. Build a naming rule such as Pump1_Start_OS so bits never overlap.

Where Edge Detection Is Used

Push Button Commands
Start, stop and reset commands that must fire once.
Batch Counting
Counting products passing a sensor without double counts.
Sequence Steps
Advancing a step sequencer by exactly one step.
Toggle Logic
One button that switches a motor on and off alternately.
Alarm Events
Logging the moment an alarm appears or clears.
Data Snapshots
Copying a value once when a batch ends.

Toggle logic is a neat example of a flip flop built in software, similar to the circuits in flip flop types. Each press flips the state because the PLC one shot delivers a single clean pulse.

Shift logic also benefits from edges, as shown in our guide to bit shift and rotate instructions.

Extra Counts Calculator

Counts Without and With Edge Detection
Result
50 counts without edge detection, 1 with edge detection

Longer presses and faster scans make the problem worse. Modern controllers with 1 ms scans can count hundreds of times during a single press.

Benefits
  • Clean single scan pulse from any input.
  • Prevents runaway counters and sequences.
  • Works the same on every scan time.
  • Available on every PLC platform.
Common Mistakes
  • Sharing one storage bit between instructions.
  • Placing the one shot inside a skipped routine.
  • Using a one shot where a level signal is needed.
  • Forgetting the pulse is invisible when monitoring.

Logix General Instructions Manual PDF

PDF
Logix5000 Controllers General Instructions Reference Manual
Rockwell manual covering ONS, OSR, OSF and other bit instructions

OSR and OSF Tutorial Video

PLC One Shot Questions

What is a PLC one shot?
It is an instruction that makes its output true for exactly one scan when its input changes.
What is the difference between OSR and OSF?
OSR pulses on the rising edge and OSF pulses on the falling edge.
Why does each one shot need its own storage bit?
The storage bit remembers the previous state, so sharing it breaks edge detection.
What is R_TRIG?
It is the IEC 61131 3 function block for rising edge detection.
How long does the pulse last?
Exactly one program scan.
Do counters need a one shot?
Most counter instructions already count rising edges, but math and move logic do.
Can I see the pulse online?
Rarely, because it lasts only one scan, so use a counter to confirm it.

Related Articles

External References

What We Learn Today

  • Edge instructions turn a changing input into a pulse that lasts one scan.
  • ONS, OSR and OSF are Allen Bradley versions, while R_TRIG and F_TRIG are IEC blocks.
  • Every edge instruction needs its own storage bit to work correctly.
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!

Leave a Reply

Your email address will not be published. Required fields are marked *