OSR / OSF — One Shot Rising and Falling
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
| Name | Type | Meaning |
|---|---|---|
storageBit | BOOL | Remembers the rung state from the previous scan |
outputBit | BOOL | Pulses 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: setoutputBitfor one scan. While the rung stays true, hold it false.OSF— rung goes true → false: setoutputBitfor 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:
XIC(Button)OSR(PressStorage,PressPulse);XIC(PressPulse)ADD(Count,1,Count)
Example — Act When a Signal Drops
OSF pulses DropPulse the moment Guard opens, latching an alarm:
XIC(Guard)OSF(GuardStorage,DropPulse);XIC(DropPulse)OTL(Alarm)
One-Shots vs ONS
ONSis 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/OSFare 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, whichONScannot detect.
Common Mistakes
- Confusing a falling edge with an inverted input —
XIO(Signal)is true the whole time the signal is off;OSFpulses for a single scan when it turns off. - Sharing one
storageBitbetween two one-shot instructions — each needs its own. - Reading the
storageBitinstead of theoutputBit— the pulse is on the output bit.
Related
ONS— One Shot — rising-edge one-shot that conditions its own rung- Bit instructions overview