ethercat-linux/docs/verification-progress.md
Tony Cao 2837f2a13d EL6695 secondary side: SAFEOP/OP bring-up + 1kHz data loop
- 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
2026-07-23 00:46:48 +08:00

133 lines
4.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# EL6695 1 kHz 通讯验证实施进度
- 创建日期2026-07-22
- 当前状态:**TwinCAT 待切回 RunPLC 波形逻辑已部署**
- 关联文档:`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
powershell -ExecutionPolicy Bypass -File C:\Users\tonycao\work\free\ads-state.ps1
```
输出:
```text
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. 下一步
1. **切 TwinCAT 到 Run 模式**
- 首选:`free/switch-to-run.ps1`(通过 DTE/COM 打开工程后调用 `StartRestartTwinCAT` 并轮询)
- 备选:`free/activate-and-run.ps1`完整流程ActivateConfiguration + StartRestartTwinCAT + 轮询)
- 最坏情况:若 ADS/DTE 均无法切 Run考虑重启 Windows 后再试
2. **确认端口 851 可达**
- `ads-state.ps1` 应输出 `port10000: ads=Run``port851: ads=Run`
3. **启动 J1900 侧**
```bash
ssh root@<j1900-ip> /root/gateway/el6695_rt eth1 --mode follow --duration 120
```
4. **运行波形快照验证**
```powershell
powershell -ExecutionPolicy Bypass -File C:\Users\tonycao\work\free\ads-waveform-snapshot.ps1
```
预期值:
| 字段 | 预期 |
|---|---|
| `nRttUs` | ≈ 4000 µs |
| `nInSeqDelta` | 1 |
| `nJ1900Delta` | 1 |
| `nJ1900JitterNs` | < 1 µsfollow 模式锁定后 |
| `nJ1900PhaseErrNs` | 稳定在某一直流值 165 µs |
5. **在 TwinCAT Scope View 中添加 YT Chart**
- 数据源ADS 符号
- 通道上述 5 个变量
- 采样率挂到 PLC 任务 1 kHz
6. **提交 git**
- 当前 `src/main.rs` 有未提交修改
- 提交信息`feat: add jitter/phase_err diagnostics for TwinCAT Scope waveform`
---
## 5. 相关文件
- `C:/Users/tonycao/work/ethercat-linux/src/main.rs`
- `C:/Users/tonycao/work/ethercat-linux/docs/scope-waveform-design.md`
- `C:/Users/tonycao/work/ethercat-linux/docs/verification-progress.md`
- `C:/Users/tonycao/work/free/TwinCATProject1/PlcSync/GVLs/GVL_Sync.TcGVL`
- `C:/Users/tonycao/work/free/TwinCATProject1/PlcSync/POUs/MAIN.TcPOU`
- `C:/Users/tonycao/work/free/rt-activate2.ps1`
- `C:/Users/tonycao/work/free/ads-state.ps1`
- `C:/Users/tonycao/work/free/ads-waveform-snapshot.ps1`
- `C:/Users/tonycao/work/free/switch-to-run.ps1`
- `C:/Users/tonycao/work/free/activate-and-run.ps1`