Learn PLCs free
Bistables & Edge DetectionBeginnerIEC 61131-3

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

NameTypeDescription
CLKBOOLInput signal to monitor for rising edge

Outputs

NameTypeDescription
QBOOLTRUE for one scan on rising edge of CLK

Timing Diagram

CLK: ___/‾‾‾‾‾‾‾‾‾\___/‾‾‾‾\___
Q:   ___/‾\_____________/‾\______
        ^one scan      ^one scan

Ladder 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 cycle

20 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

S

Siemens (TIA Portal)

Use R_TRIG instruction or P (positive edge) contact in TIA Portal ladder logic.

AB

Allen-Bradley (Studio 5000)

Use ONS (One-Shot) instruction or OSR (One-Shot Rising) in Studio 5000.

C

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.

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.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →