OSR / OSF — One Shot Rising and Falling

OSR sets an output bit for one scan when its rung turns on; OSF sets it for one scan when the rung turns off. Both use a dedicated storage BOOL in the rungs.dev ladder simulator.

OSR

Storage Bit

storageBit

Output Bit

outputBit

OSF

Storage Bit

storageBit

Output Bit

outputBit

One Shot Rising (OSR). Sets its output bit for exactly one scan each time the rung goes from false to true. Uses a dedicated storage bit to remember the previous rung state.

One Shot Falling (OSF). Sets its output bit for exactly one scan each time the rung goes from true to false. Uses a dedicated storage bit to remember the previous rung state.

Unlike ONS — which conditions the rung it sits in — OSR and OSF write a separate bit you can read anywhere else in your program.

Operands

NameTypeMeaning
storageBitBOOLRemembers the rung state from the previous scan
outputBitBOOLPulses true for one scan on the edge

Each instruction needs its own storage bit. The output bit is the one you use downstream.

How They Work

Both compare the rung condition now against the storageBit (what the rung was last scan):

  • OSR — rung goes false → true: set outputBit for one scan. While the rung stays true, hold it false.
  • OSF — rung goes true → false: set outputBit for one scan. While the rung stays true or stays false, hold it false.

A falling edge is not the same as "the input is off." OSF pulses on the single scan the rung turns off, then clears even though the rung stays off — that is what makes it a one-shot and not an inverted contact.

Neither fires on the first scan for a condition that was already settled at startup. Prescan seeds the storage bit — OSR treats a rung that is already true as old news, and OSF has no stored "true" for a falling edge to measure against.

Rung   _____|‾‾‾‾‾‾‾‾|________|‾‾‾‾‾‾|___
OSR    _____|‾|_______________|‾|________
OSF    _____________|‾|______________|‾|_

Example — Pulse on a Rising Edge

OSR turns a held button into a single-scan pulse on PressPulse, which drives an ADD once per press:

0

Button

OSR

Storage Bit

PressStorage

Output Bit

PressPulse

1

PressPulse

ADD

Source A

Count

Source B

1

Dest

Count

Example — Act When a Signal Drops

OSF pulses DropPulse the moment Guard opens, latching an alarm:

0

Guard

OSF

Storage Bit

GuardStorage

Output Bit

DropPulse

1

DropPulse

Alarm

L

One-Shots vs ONS

  • ONS is an input instruction: it makes the rest of its own rung true for one scan. Best when the thing you want to pulse is right there on the same rung.
  • OSR / OSF are output instructions: they set a named bit you can examine on other rungs. Best when the same edge needs to be reused in several places — or when you need the falling edge, which ONS cannot detect.

Common Mistakes

  • Confusing a falling edge with an inverted input — XIO(Signal) is true the whole time the signal is off; OSF pulses for a single scan when it turns off.
  • Sharing one storageBit between two one-shot instructions — each needs its own.
  • Reading the storageBit instead of the outputBit — the pulse is on the output bit.

On this page