R_TRIG (Rising Edge Detection)
Detects FALSE-to-TRUE transition, outputs single-scan pulse on rising edge.
The R_TRIG (Rising Edge Trigger) function block detects a FALSE-to-TRUE transition on its input (CLK). The output (Q) is TRUE for exactly one PLC scan cycle when the rising edge occurs, then returns to FALSE. R_TRIG is one of the most important function blocks in PLC programming, used to trigger actions on signal changes rather than signal levels. Applications include counting pulse inputs, triggering one-shot operations, detecting button presses, and synchronizing events.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| CLK | BOOL | Input signal to monitor for rising edge |
Outputs
| Name | Type | Description |
|---|---|---|
| Q | BOOL | TRUE for one scan on rising edge of CLK |
Timing Diagram
CLK: ___/‾‾‾‾‾‾‾‾‾\___/‾‾‾‾\___
Q: ___/‾\_____________/‾\______
^one scan ^one scanLadder Logic Example
// Ladder Logic - R_TRIG (Button Press Detection) // // |----[ Button ]----[R_TRIG Edge_Detect]----| // | CLK: Button | // | Q: Button_Pressed | // // |----[ Button_Pressed ]----[CTU Counter]---|
Structured Text Example
VAR
Edge_Detect : R_TRIG;
Button : BOOL;
Button_Pressed : BOOL;
END_VAR
Edge_Detect(CLK := Button);
Button_Pressed := Edge_Detect.Q;
// Button_Pressed is TRUE for only one scan cycle20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use R_TRIG instruction or P (positive edge) contact in TIA Portal ladder logic.
Allen-Bradley (Studio 5000)
Use ONS (One-Shot) instruction or OSR (One-Shot Rising) in Studio 5000.
CODESYS
Standard R_TRIG in Standard library. Each instance tracks its own edge state.
Common Applications
- Button press detection
- Counter input conditioning
- One-shot event triggering
- Pulse counting
- State machine transitions
Common Mistakes to Avoid
- Assuming Q stays TRUE for more than one scan
- Not creating a separate R_TRIG instance for each signal
- Calling R_TRIG multiple times per scan for the same instance
Frequently Asked Questions
What is R_TRIG (Rising Edge Detection) in PLC programming?
Detects FALSE-to-TRUE transition, outputs single-scan pulse on rising edge. The R_TRIG (Rising Edge Trigger) function block detects a FALSE-to-TRUE transition on its input (CLK). The output (Q) is TRUE for exactly one PLC scan cycle when the rising edge occurs, then returns to FALSE.
What are common applications of R_TRIG (Rising Edge Detection)?
R_TRIG (Rising Edge Detection) is commonly used for: Button press detection, Counter input conditioning, One-shot event triggering, Pulse counting, State machine transitions.
How do I use R_TRIG (Rising Edge Detection) in different PLC platforms?
Siemens: Use R_TRIG instruction or P (positive edge) contact in TIA Portal ladder logic. Allen-Bradley: Use ONS (One-Shot) instruction or OSR (One-Shot Rising) in Studio 5000. CODESYS: Standard R_TRIG in Standard library. Each instance tracks its own edge state.
Related Function Blocks
F_TRIG (Falling Edge Detection)
Detects TRUE-to-FALSE transition, outputs single-scan pulse on falling edge.
View Reference →SR (Set-Reset Flip-Flop, Set Dominant)
Set-dominant flip-flop: output latches TRUE on set, cleared by reset. Set wins if both active.
View Reference →CTU (Counter Up)
Counts up on each rising edge; output activates when count reaches preset.
View Reference →RS (Reset-Set Flip-Flop, Reset Dominant)
Reset-dominant flip-flop: reset wins if both set and reset are active simultaneously.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects