Lesson #11 Rising and Falling Edge in Ladder Logic

Overview

Lesson #11 Rising and Falling Edge in Ladder Logic

In SIMATIC Manager (Siemens S7), edge detection—rising edge (positive edge) and falling edge (negative edge)—is not an inherent instruction in classic Ladder Logic but can be implemented manually using memory bits or functional blocks. Here's how it works:


🔄 What Are Rising and Falling Edges?


⚙️ Edge Detection Implementation in SIMATIC Manager

Since SIMATIC Manager (S7) Ladder doesn’t include a built-in POS (positive) or NEG (negative) instruction like TIA Portal, you typically:

  1. Store the previous input state in a memory bit (M‑bit or DB tag).

  2. On each scan, compare current input with stored value.

  3. Generate an output pulse when the comparison detects the specific transition.

  4. Update the stored memory bit with the current input value for the next scan.

Example in Ladder Logic (conceptual):

Network 1: Rising edge detection --[ I0.0 ]--| |----( )---- Q0.0 ; I0.0 = 1 and M0.0 = 0 M0.0 Network 2: Falling edge detection --[ /I0.0 ]--| |----( )---- Q0.1 ; I0.0 = 0 and M0.0 = 1 M0.0

Then always:

M0.0 := I0.0 ; store input for next scan

🧠 Implementing in SCL (Structured Control Language)

// Rising Edge FB FUNCTION_BLOCK FB_Rising VAR_INPUT A: BOOL; END_VAR VAR_OUTPUT B: BOOL; END_VAR VAR STORE: BOOL; END_VAR IF (A = TRUE) AND (STORE = FALSE) THEN B := TRUE; ELSE B := FALSE; END_IF; STORE := A; END_FUNCTION_BLOCK

// Falling Edge FB FUNCTION_BLOCK FB_Falling VAR_INPUT A: BOOL; END_VAR VAR_OUTPUT B: BOOL; END_VAR VAR STORE: BOOL; END_VAR IF (A = FALSE) AND (STORE = TRUE) THEN B := TRUE; ELSE B := FALSE; END_IF; STORE := A; END_FUNCTION_BLOCK

These blocks can be called within your Ladder logic or any SCL program to generate edge pulses reliably 


🧐 Why This Works

  • The comparison of current vs previous state lets you detect transitions (rising or falling).

  • The resulting output B is only TRUE for one scan cycle, effectively making it a one-shot pulse.

  • This matches the behavior of an edge trigger: you act only on the change, not on steady state.


🗣 Insights from Practitioners (Reddit)

A user explains the memory bit logic clearly:

“To tell if it's a falling edge … you need a memory bit to hold the state from the last cycle. Then you run a comparison: is I615.1 low and M4.2 high? Then yes, you have a negative edge.” 

Another explains that M-bits store past states to enable edge detection in SIMATIC Manager’s legacy style .


✅ Summary Table

Edge TypeConditionImplementation
RisingInput = 1 & Last = 0(A = TRUE) AND (STORE = FALSE)
FallingInput = 0 & Last = 1(A = FALSE) AND (STORE = TRUE)
Memory UpdateStore current to lastSTORE := A

🧩 In Ladder Logic

  • Use contacts to check current and memory bit.

  • Use coil to set output one scan.

  • Always update the memory bit at end of network.

💻 In SCL

  • Encapsulate logic in Function Block (FB).

  • Use STORE variable for memory state.

  • Call FB for each edge-detection input.


🧭 Practical Use Cases

  • Counting pulses: Trigger counter on rising edge.

  • Timers: Start a timer only once when input changes.

  • State changes: React only when inputs flip edge, not when steady.