跳到主要内容

AI 驱动文档

您想了解什么?

设置数字输出逻辑

本指南展示如何配置 OV10i 的数字输出,以基于检测结果控制外部设备。相机提供 2 个数字输出,采用 True/False 逻辑来触发分拣机构、指示灯、警报或其他自动化设备。

何时使用数字输出: 自动分拣系统、通过/不通过指示灯、拒绝机构、警报系统、PLC 通信,或需要根据检测结果触发的任一外部设备。

先决条件

  • OV10i 相机系统已设置并连接
  • 带检测逻辑的活动配方已配置
  • 待控外部设备(用于测试时可选)
  • 对数字 I/O 概念的基本理解

数字输出规格

OV10i 通过 M12 连接器提供 2 个数字输出:

输出引脚号线色功能
数字输出 110紫色可配置输出
数字输出 211灰色/粉色可配置输出
注意

数字输出 (DO0 / DO1) 为 NPN 开集电极输出(仅电流下拉)。需要外部上拉或负载至 +V,输出可以拉至 0 V(接地)但不能源出 24 V。

NPN 下拉输出工作原理

点击下方按钮,查看数字输出激活时电流在电路中的流向。

CameraFalseRelay+24V+24VDOGNDSystem GND

Status: OFF

Turn ON the digital output to sink current through the relay coil to ground.

工作逻辑:

  • True = Output ON (24V)
  • False = Output OFF (0V)

第一步:访问 Node-RED 编辑器

1.1 导航至 IO Block

  1. 在 Recipe Editor 中打开您的活动配方
  2. 点击 Configure IO 或在面包屑菜单中选择 IO Block 进入 Node-RED 编辑器

1.2 验证 Node-RED 界面

检查点: 您应该看到左侧带有节点调色板的 Node-RED 流编辑器。

步骤 2:添加数字输出节点

2.1 定位输出节点

  1. 在左侧面板(Overview 部分)中找到“Output”节点
  2. 将“Output”节点拖放到流画布上
  3. 双击节点 进行配置

image.png

2.2 配置输出设置

节点配置:

设置选项描述
输出引脚DO0、DO1选择要控制的物理输出
初始状态OFF、ON系统启动时的起始状态
名称自定义文本用于识别的可选标签

2.3 输出配置步骤

  1. 选择输出引脚:
    • DO0 = Digital Output 1(引脚 10,紫色线)
    • DO1 = Digital Output 2(引脚 11,灰色/粉色线)
  2. 设置初始状态:
    • OFF = 输出在 OFF 状态启动(推荐)
    • ON = 输出在 ON 状态启动
  3. 给节点命名:
    • 使用描述性名称,如 "Reject_Signal""Pass_Light"
  4. 点击 "Done" 保存配置

第三步:将逻辑连接到输出

3.1 基本 Pass/Fail Output

For simple pass/fail indication:

  1. Add "Final Pass/Fail Output" node (if not already present)
  2. Connect: Final Pass/Fail → Output Node
  3. Result: Output activates when inspection passes

3.2 Inverted Logic (Fail Signal)

To trigger output on inspection failure:

  1. Add "function" node between pass/fail and output
  2. Configure function node:
// Invert pass/fail signal - ensure boolean output
msg.payload = !msg.payload;
return msg;

  1. Connect: Final Pass/Fail → Function → Output Node
  2. Result: Output activates when inspection fails

3.3 Custom Logic from Classification Results

When using classification or other inspection data:

  1. Add "function" node to convert results to boolean
  2. Configure function for your logic:
// Convert classification result to boolean
// Example: Activate output for specific class
if (msg.payload.class === "Defective") {
msg.payload = true; // Turn output ON
} else {
msg.payload = false; // Turn output OFF
}
return msg;

  1. Connect: Data Source → Function → Output Node

3.4 Boolean Conversion Examples

For different data sources, always convert to boolean:

From confidence values:

// Activate if confidence below threshold
msg.payload = (msg.payload.confidence <0.8);
return msg;

From ROI results:

// Activate if any ROI failed
msg.payload = msg.payload.roi_results.some(roi => !roi.pass);
return msg;

备注

The Output node requires boolean input (true/false). Always ensure your logic produces boolean values before connecting to the Output node.

4.1 Why Use Pulse Output

Pulse output is recommended because:

  • Provides clear signal indication
  • Prevents output from staying ON indefinitely
  • Better for triggering external equipment
  • Easier to troubleshoot signal timing

4.2 Add Trigger Node

  1. Add "trigger" node from Function section
  2. Place between logic source and output node
  3. Double-click trigger node to configure

4.3 Configure Trigger Settings

Pulse Configuration:

SettingRecommended ValueDescription
SendTrueInitial signal to send
Then wait500msPulse duration
Then sendFalseSignal after delay
Extend delayDisabledDon't extend on new messages

image.png

4.4 Trigger Configuration Steps

  1. First Output:
    • Send: booleantrue
    • This turns the output ON
  2. Delay Settings:
    • Then wait for: 500 milliseconds
    • Then send: booleanfalse
    • This turns the output OFF after delay
  3. Advanced Options:
    • Extend delay if new message arrives: Unchecked
    • Stop existing delay if new message arrives: Checked
  4. Click "Done" to save

Digital output

Noderedflow

4.5 Wire Pulse Configuration

Connect nodes in this order: Logic Source → Trigger → Output Node

Example flow: Final Pass/Fail → Trigger → Output (DO0)

步骤 5:部署与测试配置

5.1 部署流程

  1. **单击“部署”**按钮(右上角)
  2. 验证部署是否成功的消息
  3. 检查节点状态指示器

5.2 监控 I/O 状态

使用内置的 I/O 监控屏幕:

  1. **在主界面导航到“I/O Live Monitor”**页面
  2. 实时观察输出状态
  3. **检查“Last state change”**时间戳

Digital Outputs on IO Live Monitor page.png

I/O 状态屏幕显示:

  • 当前输出状态(ON/OFF)
  • 最近状态变更时间戳
  • 实时状态更新

5.3 测试输出激活

手动测试:

  1. 添加“inject”节点用于测试
  2. 配置 inject 节点:
    • Payload: booleantrue
    • Name: "Test Output"
  3. 连接: Inject → Trigger → Output
  4. 单击 inject 按钮以测试输出
  5. 在 I/O 状态屏幕中验证输出激活

Step 6: Advanced Output Configurations

6.1 多输出控制

同时控制两个输出:

  1. 为 DO0 和 DO1 添加单独的输出节点
  2. 将相同逻辑源连接到两个输出
  3. 如有需要,使用不同的触发延迟

6.2 条件输出选择

基于条件路由到不同的输出:

  1. 从 Function 部分添加“switch”节点
  2. 配置路由规则:
// Route based on classification result
if (msg.payload.class === "Large") {
return [msg, null]; // Send to first output (DO0)
} else if (msg.payload.class === "Small") {
return [null, msg]; // Send to second output (DO1)
}
return [null, null]; // No output

  1. 将 switch 输出连接到各自的输出节点

6.3 延迟输出序列

创建定时输出序列:

  1. 添加多个 trigger 节点,具有不同的延迟
  2. 配置序列时序:
    • First trigger: 100ms pulse
    • Second trigger: 500ms delay, then 200ms pulse
  3. 串联连接以实现顺序激活

Step 7: Integration Examples

7.1 Sorting System Integration

双向分拣设置:

  • DO0 (Output 1): Good parts conveyor
  • DO1 (Output 2): Reject bin actuator
Final Pass/Fail → Switch Node → Trigger → DO0 (Pass)
→ Trigger → DO1 (Fail)

7.2 Alarm System Integration

多级报警系统:

  • DO0: Warning light (minor defects)
  • DO1: Alarm horn (major defects)
Classification Logic → Function (Check severity) → Appropriate Output

7.3 PLC Communication

简单 PLC 握手:

  • DO0: Inspection complete signal
  • DO1: Part reject signal
All Block Outputs → Format for PLC → Trigger → DO0
→ Reject Logic → Trigger → DO1

Step 8: Troubleshooting Output Issues

8.1 输出未激活

问题检查项解决方案
没有输出信号节点连接确保所有线缆已连接
逻辑从未触发输入条件检查通过/失败逻辑配置
时序问题触发设置调整脉冲持续时间
错误引脚被选中输出引脚选择验证 DO0/DO1 配置

8.2 使用 I/O 状态进行故障排除

数字 I/O 屏幕有助于识别:

  1. 当前输出状态: 检查输出是否实际在变化
  2. 最近状态变更: 验证输出激活的时序
  3. 状态历史: 追踪输出随时间的表现

使用 I/O 屏幕进行故障排除:

  • 输出始终显示“OFF”:逻辑可能未触发
  • 输出始终显示“ON”:缺少脉冲配置
  • 没有时间戳更新:检查 Node-RED 连接
  • 状态快速变化:逻辑可能触发过于频繁

8.3 外部设备问题

问题原因解决方案
设备无响应电压不匹配验证 24V 兼容性
间歇性运行接线问题检查 M12 连接器接线
响应延迟外部设备时序调整脉冲持续时间

Step 9: Testing and Validation

9.1 系统性测试

逐项测试每个输出:

测试预期结果状态
手动触发 DO0输出 1 在脉冲持续时间内激活
手动触发 DO1输出 2 在脉冲持续时间内激活
通过条件正确输出激活
失败条件正确输出激活
I/O 状态更新时间戳显示状态变化

9.2 生产验证

在投入生产之前:

  1. 使用实际零件和检测条件进行测试
  2. 验证输出时序是否符合外部设备要求
  3. 确认电气连接是否牢固
  4. 记录输出分配以便维护

9.3 性能验证

请监控以下方面:

  • 响应时间: 检测后输出激活延迟
  • 可靠性: 输出行为随时间保持一致
  • 时序精度: 脉冲持续时间与配置相符

成功!您的数字输出就绪

您的数字输出系统现在可以:

  • 基于检测结果控制外部设备
  • 提供脉冲信号以实现可靠触发
  • 支持多种输出配置以实现复杂自动化
  • 与 PLCs 和分拣系统集成,用于生产自动化
  • 通过内置的 I/O 界面监控输出状态

持续维护

常规系统检查

  • 监控 I/O 状态屏幕以确保稳定运行
  • 验证输出时序仍在规范范围内
  • 检查 M12 连接器处的电连接
  • 定期测试手动触发,以确保系统健康

故障排除资源

  • 使用 I/O 状态屏幕进行实时诊断
  • 检查 Node-RED 调试面板以诊断逻辑问题
  • 验证外部设备规格是否与输出能力相符
  • 记录任何配置更改,以备将来参考

下一步

配置数字输出后:

  1. 如需要,为外部控制设置数字输入触发器
  2. 配置 PLC 通信,以实现集成自动化
  3. 在生产环境中实现安全互锁
  4. 建立系统健康的自动化监控

🔗 相关链接