- Fix SM ctrl bytes for SM2 (0x64) and SM3 (0x20) per ESI - Add SM2/SM3 register config + FMMU + PDO assignment via SDO - Change SM_TX_ADDR/RX_ADDR to SM2(0x1C00)/SM3(0x8E00) - Add ensure_od_secondary for PDO assignment - Add secondary-side diagnostics (CoE object probe) - Update SM2/SM3 enable/disable sequence for clean config - Add full bring-up sequence: INIT->PREOP->SAFEOP->OP
4.2 KiB
4.2 KiB
EL6695 1 kHz 通讯验证实施进度
- 创建日期:2026-07-22
- 当前状态:TwinCAT 待切回 Run,PLC 波形逻辑已部署
- 关联文档:
docs/scope-waveform-design.md
1. 目标
在 TwinCAT Scope View 中直观观测 J1900 ↔ TwinCAT(经 EL6695 桥)1 kHz 通讯的周期与抖动,并验证其稳定性。
2. 已完成
2.1 J1900 侧(src/main.rs)
- 在回显帧
tx_buf的 [264..272] 追加诊断字段:tx_buf[264..268]:jitter_ns(i32 LE)—— el6695_rt 内部 PLL/唤醒抖动tx_buf[268..272]:last_phase_err_ns(i32 LE)—— 与 TwinCAT DC 网格的相位误差
- 已在 J1900 上构建并部署到
/root/gateway/el6695_rt - 协议兼容性:诊断区位于图案校验区 [16..255] 之后、时间戳 [256..263] 之后,不触发 PLC 的
nMismatch
2.2 TwinCAT PLC 侧(free/TwinCATProject1/PlcSync)
GVL_Sync.TcGVL 新增变量:
| 变量 | 类型 | 含义 |
|---|---|---|
nRttUs |
DINT |
端到端往返时间(µs) |
nInSeqDelta |
DINT |
nReturnedSeq 周期差分 |
nJ1900Delta |
DINT |
nJ1900Cycle 周期差分 |
nJ1900JitterNs |
DINT |
J1900 自测抖动(ns) |
nJ1900PhaseErrNs |
DINT |
J1900 相位误差(ns) |
nPrevRetSeq |
ULINT |
差分寄存器 |
nPrevJ1900 |
ULINT |
差分寄存器 |
MAIN.TcPOU 末尾追加:
- 通道 1:
nRttUs = (nEchoTimestamp - nSendTimestamp) / 10 - 通道 2/3:两个序列号的周期差分
- 通道 4/5:两条
MEMCPY从aIn1[264..271]拷贝到 DINT
2.3 TwinCAT 工程激活
- 运行
free/rt-activate2.ps1 ActivateConfiguration()返回成功- 但后续系统进入 Config 模式,未自动进入 Run
3. 当前阻塞
TwinCAT 系统服务停留在 Config 模式,PLC 端口 851 未启动。
验证命令:
powershell -ExecutionPolicy Bypass -File C:\Users\tonycao\work\free\ads-state.ps1
输出:
port10000: ads=Config device=1
port851 err: Target port could not be found. (AdsErrorCode: 6, 0x6)
已尝试但未成功的方法:
ads-set-run.ps1:WriteControl重载问题失败- 直接
TcAdsClient.WriteControl([AdsState]::Run):状态仍为 Config rt-activate2.ps1中的StartRestartTwinCAT():进入 Config 后未切 Run
4. 下一步
-
切 TwinCAT 到 Run 模式
- 首选:
free/switch-to-run.ps1(通过 DTE/COM 打开工程后调用StartRestartTwinCAT并轮询) - 备选:
free/activate-and-run.ps1(完整流程:ActivateConfiguration + StartRestartTwinCAT + 轮询) - 最坏情况:若 ADS/DTE 均无法切 Run,考虑重启 Windows 后再试
- 首选:
-
确认端口 851 可达
ads-state.ps1应输出port10000: ads=Run且port851: ads=Run
-
启动 J1900 侧
ssh root@<j1900-ip> /root/gateway/el6695_rt eth1 --mode follow --duration 120 -
运行波形快照验证
powershell -ExecutionPolicy Bypass -File C:\Users\tonycao\work\free\ads-waveform-snapshot.ps1预期值:
字段 预期 nRttUs≈ 4000 µs nInSeqDelta1 nJ1900Delta1 nJ1900JitterNs< 1 µs(follow 模式锁定后) nJ1900PhaseErrNs稳定在某一直流值(约 165 µs) -
在 TwinCAT Scope View 中添加 YT Chart
- 数据源:ADS 符号
- 通道:上述 5 个变量
- 采样率:挂到 PLC 任务 1 kHz
-
提交 git
- 当前
src/main.rs有未提交修改 - 提交信息:
feat: add jitter/phase_err diagnostics for TwinCAT Scope waveform
- 当前
5. 相关文件
C:/Users/tonycao/work/ethercat-linux/src/main.rsC:/Users/tonycao/work/ethercat-linux/docs/scope-waveform-design.mdC:/Users/tonycao/work/ethercat-linux/docs/verification-progress.mdC:/Users/tonycao/work/free/TwinCATProject1/PlcSync/GVLs/GVL_Sync.TcGVLC:/Users/tonycao/work/free/TwinCATProject1/PlcSync/POUs/MAIN.TcPOUC:/Users/tonycao/work/free/rt-activate2.ps1C:/Users/tonycao/work/free/ads-state.ps1C:/Users/tonycao/work/free/ads-waveform-snapshot.ps1C:/Users/tonycao/work/free/switch-to-run.ps1C:/Users/tonycao/work/free/activate-and-run.ps1