BlockWerk Documentation
↗

Edge Detect

Logic

Detects changes in the input signal. Can detect rising edges (input increases), falling edges (input decreases), or any change.

Simulate in BlockWerk

Interactive sandbox directly in your browser — zero installation, WASM-powered.

Simulate in BlockWerk →

Mathematical Model

rising:y[n]={1,u[n]>u[n−1]0,otherwisefalling:y[n]={1,u[n]<u[n−1]0,otherwiseeither:y[n]={1,u[n]≠u[n−1]0,otherwise\begin{aligned} &\text{rising:} && y[n] = \begin{cases} 1, & u[n] > u[n-1] \\ 0, & \text{otherwise} \end{cases} \\ &\text{falling:} && y[n] = \begin{cases} 1, & u[n] < u[n-1] \\ 0, & \text{otherwise} \end{cases} \\ &\text{either:} && y[n] = \begin{cases} 1, & u[n] \neq u[n-1] \\ 0, & \text{otherwise} \end{cases} \end{aligned}

First sample: y[0] = 0 for all modes.

Inputs & Outputs

Direction ID Label Type Status
→ In in In number Required
← Out out Out boolean Output

Parameters

Parameters Label Type Default Description
mode Detection Mode select rising
threshold Threshold number 0.5 Signal level separating low from high. An edge is a crossing of this level; move it outside the noise band to avoid spurious edges.
initialState Initial State number 0

Usage Examples

  • Zie de ingebouwde voorbeelden in de handleiding voor een demonstratie van dit blok.

Remarks & Best Practices

  • Pulse width: Output is high for exactly one simulation timestep per detected edge
  • First sample: Always outputs 0 on the first sample (no prior state available)
  • Noise sensitivity: EdgeDetect triggers on any change; pre-filter noisy signals before edge detection
  • Rising vs falling: Use rising for positive-going thresholds, falling for negative-going
  • Either mode: Detects any change in either direction; useful for change-of-state triggers

Related Components