BlockWerk 文档
↗

Edge Detect

Logic

检测输入信号中的突变或边沿。能够检测上升沿(输入信号向上穿越阈值)、下降沿(输入信号向下穿越阈值)或任意边沿跳变。

在 BlockWerk 中仿真

浏览器即开即用的交互式仿真环境 — 无需安装,由 WebAssembly 强力驱动。

在 BlockWerk 中仿真 →

数学模型

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}

首个采样点:所有模式下 y[0] = 0。

输入与输出

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

参数

参数 Label 类型 默认值 描述
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

使用示例

  • 事件触发:当控制信号从 0 跳变至 1 时,触发积分器复位或启动计时器。
  • 脉冲计数:配合离散累加器使用,对机械转速脉冲或传感器事件计数。

说明与最佳实践

  • 脉冲宽度:每检测到一个边沿,输出严格在一个仿真时间步长内保持高电平(1)。
  • 首个采样点:在第一个时间步上始终输出 0(因为没有可对比的前序历史数据)。
  • 噪声敏感性:边沿检测对方块输入的变化极为敏感;在执行边沿检测前建议对含噪信号进行低通滤波。
  • 上升沿与下降沿:使用 rising 捕获正向阈值跳变,使用 falling 捕获负向阈值跌落。
  • Either 模式:双向检测任何跳变;非常适合作为状态改变时的通用触发器。

相关模块