跳到主要内容

设备无法连接或控制

问题描述

部分 EtherCAT 从站设备可能出现以下问题:

  • 无法进入 OP 状态(卡在 SafeOp 或 PreOp)
  • 使能失败
  • 部分运动控制无响应
为什么会出现这些问题?

Ethercat设备协议虽然有标准规范,但不同厂商的实现差异很大

  • 未通过ETG一致性认证
  • ESI文件版本过旧
  • 状态机时序要求不同(有的需要延时,有的需要特定 Controlword 序列)
  • Startup 参数错误(必配参数、默认值、写入顺序)
  • DC 同步要求不同(有的必须开启 DC,有的不支持 DC)
  • 某些厂商有私有对象或非标准行为

因此没有一套通用的配置能适配所有设备,需要根据具体设备的文档进行适配。

解决方法:使用 AI 辅助适配

将设备相关资料整理到一个文件夹中,然后使用 AI 工具进行分析和修复。

第 1 步:收集设备资料

在项目目录下创建一个文件夹,放入以下文件:

设备适配/
├── ESI文件.xml # 必须 — 从站 ESI 描述文件 (厂商提供)
├── 配置文件.deni # 如有 — 当前使用的 DENI 配置文件
├── 设备手册.pdf/txt # 必须 — 设备手册 (PDF 转 TXT 最佳)
└── debug.txt # 如有 — Darra Master 的调试日志输出
文件来源说明
ESI 文件 (.xml)厂商官网或随设备附带PDO 映射、Startup 参数、支持的模式等
DENI 配置 (.deni)Darra Master 导出当前主站配置(网口、Startup 参数等)
设备手册 (.pdf/.txt)厂商文档操作时序、参数说明、示例代码等
调试日志 (debug.txt)Darra Master 输出错误码、状态转换失败原因等
PDF 转 TXT

AI 工具处理纯文本效果更好,建议将 PDF 手册转为 TXT 后再提供。常用方法:

  • 在线工具:搜索 "PDF to TXT"
  • Python:pdfminer.sixPyMuPDF
  • 命令行:pdftotext input.pdf output.txt

支持直接读取 PDF 的 AI 工具(如 Claude)可跳过此步骤。

第 2 步:使用 AI 分析

将收集的文件发送给 AI(如 Claude、ChatGPT 等),配合以下提示词:

English:

Please read https://ethercat.darra.xyz/ai-prompts.txt as prompt context, then help me:

I am having trouble connecting an EtherCAT slave using Darra EtherCAT Master. Please analyze the attached files and provide a fix.

Attachments:
1. ESI file (.xml) — slave device description
2. DENI config (.deni) — current master configuration (if available)
3. Device manual (.pdf/.txt) — vendor operation manual (if available)
4. Debug log (debug.txt) — runtime error output (if available)

Please check the following items against the device manual and provide specific fix steps:

1. PDO Mapping
- Are the RxPDO/TxPDO indexes, sub-indexes, data types, and sizes consistent with the ESI?
- Is the distinction between Fixed PDO and Configurable PDO correct?

2. Startup Parameters (InitCmd)
- Have all mandatory parameters from the device manual been added?
- Is the write timing correct? (IP = Init→PreOp, PS = PreOp→SafeOp, SP = SafeOp→PreOp, SO = SafeOp→Op)
- Does the write order comply with device requirements? (e.g., disable PDO Mapping before configuring)

3. DC Synchronization
- Does the device require DC sync? Is the AssignActivate value correct?
- Do CycleTime0/CycleTime1 and ShiftTime match the device manual?

4. State Machine Transitions
- Do any state transitions require additional delays or specific SDO writes?
- For CiA 402 devices, is the Controlword enable sequence complete?

5. Vendor-Specific Requirements
- Are there proprietary objects or non-standard initialization procedures?
- Is a specific operating mode required? (e.g., Modes of Operation)

Please output the fix in the following format:
- Startup parameters to add/modify (index, sub-index, value, write timing)
- PDO mapping combination to select
- DC sync configuration recommendations (AssignActivate, CycleTime)
- Runtime SDOs that need to be actively written (if any, specify in which event)
- Modified DENI config snippet (if needed)

Symptom: [Describe the issue you encountered, including error codes and which state it is stuck at]

中文:

请阅读 https://ethercat.darra.xyz/ai-prompts.txt 作为提示词,然后帮我:

我在使用 Darra EtherCAT Master 连接 EtherCAT 从站时遇到问题,请分析附件并给出修复方案。

附件清单:
1. ESI 文件 (.xml) — 从站设备描述
2. DENI 配置 (.deni) — 当前主站配置(如有)
3. 设备手册 (.pdf/.txt) — 厂商操作手册(如有)
4. 调试日志 (debug.txt) — 运行时错误输出(如有)

请按以下维度逐项检查,并对照设备手册给出具体修复步骤:

1. PDO 映射
- RxPDO/TxPDO 的索引、子索引、数据类型和大小是否与 ESI 一致
- Fixed PDO 与 Configurable PDO 的区分是否正确

2. Startup 参数 (InitCmd)
- 设备手册中要求的必配参数是否已全部添加
- 写入时机是否正确(IP = Init→PreOp, PS = PreOp→SafeOp, SP = SafeOp→PreOp, SO = SafeOp→Op)
- 写入顺序是否符合设备要求(如需先禁用 PDO Mapping 再配置)

3. DC 同步
- 设备是否要求 DC 同步,AssignActivate 值是否正确
- CycleTime0/CycleTime1 和 ShiftTime 是否与设备手册匹配

4. 状态机转换
- 各状态转换是否需要额外延时或特定 SDO 写入
- CiA 402 设备的 Controlword 使能序列是否完整

5. 厂商特定要求
- 是否有私有对象或非标准初始化流程
- 是否需要特定的操作模式设置(如 Modes of Operation)

请按以下格式输出修复方案:
- 需要添加/修改的 Startup 参数(索引、子索引、值、写入时机)
- 需要选择的 PDO 映射组合
- DC 同步配置建议(AssignActivate、CycleTime)
- 运行时需要主动写入的 SDO(如有,说明在哪个事件中写入)
- 修改后的 DENI 配置片段(如需要)

具体现象:[描述你遇到的问题,包括错误码和卡在哪个状态]

第 3 步:应用修复

如果你使用的 AI 工具支持直接修改代码(如 Claude Code、Cursor 等),可以让 AI 直接在项目中完成修改。
否则,根据 AI 的分析结果,在 Darra Master 中手动逐项修改:

修改项操作位置说明
Startup 参数Startup 页面添加或修改 InitCmd,注意写入时机(IP/PS/SP/SO)和顺序
运行时 SDO事件回调代码部分参数需要在状态转换后通过 SDO 主动写入
PDO 配置PDO 页面选择与设备手册匹配的 RxPDO/TxPDO 映射组合
DC 设置DC 页面根据设备要求开启或关闭 DC 同步
DENI 配置文件导入修改 DENI 文件中的对应字段后重新导入