AgentSkillsCN

mm-apr-ethercat

在使用EtherCAT通信协议为HIWIN E1驱动器进行开发时,可重点掌握以下内容: (1) PDO/SDO概念及其映射配置; (2) CiA-402规范对象与状态机的运用; (3) CSP与CSV模式的选择与实施; (4) 分布式时钟(DC)同步与自由运行模式的对比与应用; (5) 在TwinCAT中导入ESI文件并完成设备扫描。

SKILL.md
--- frontmatter
name: mm-apr-ethercat
description: |
  Use when working with EtherCAT communication for HIWIN E1 drives:
  (1) PDO/SDO concepts and mapping configuration,
  (2) CiA-402 profile objects and state machine,
  (3) CSP vs CSV mode selection and implementation,
  (4) DC synchronization (Distributed Clocks) vs Free Run,
  (5) ESI file import and device scanning in TwinCAT.

EtherCAT Communication Guide for APR System

Version: APR-2026.01 | TwinCAT: 3.1 Build 4024.65

PDO/SDO mapping and CiA-402 protocol reference for HIWIN E1 drives.

Overview

This skill covers EtherCAT communication architecture for the APR dual-axis linear motor system, including process data exchange (PDO), service data access (SDO), and the CiA-402 drive profile standard.

Communication Architecture

code
┌─────────────────────────────────────────────────────────────────┐
│                    Communication Layers                          │
├─────────────────────────────────────────────────────────────────┤
│  ┌──────────────┐                                               │
│  │   TwinCAT    │                                               │
│  │   PLC/NC     │                                               │
│  └──────┬───────┘                                               │
│         │                                                        │
│         ▼                                                        │
│  ┌──────────────┐    Cyclic (Real-time)                        │
│  │     PDO      │◄──────────────────────► Process Data          │
│  │  (Fast I/O)  │    Every cycle (1ms)                          │
│  └──────────────┘                                               │
│                                                                  │
│  ┌──────────────┐    Acyclic (Mailbox)                         │
│  │     SDO      │◄──────────────────────► Parameter Access      │
│  │ (Parameters) │    On-demand                                  │
│  └──────────────┘                                               │
│                                                                  │
│  ┌──────────────┐                                               │
│  │  CiA-402     │    Profile Standard                           │
│  │   Profile    │    Motion Control Objects                     │
│  └──────────────┘                                               │
└─────────────────────────────────────────────────────────────────┘

PDO vs SDO

FeaturePDOSDO
Full NameProcess Data ObjectService Data Object
PurposeReal-time control/feedbackParameter configuration
TimingEvery EtherCAT cycleOn-demand (async)
SpeedFast (μs level)Slow (ms level)
Use CasePosition, velocity, statusSetup, diagnostics

PDO (Process Data Object) - Big Picture

PDO is the "real-time data packet" exchanged every EtherCAT cycle (e.g., 1ms)

  • Think of EtherCAT as having a "delivery truck" every 1ms
  • PDO is what you load into that truck: control word, target position, actual position, status...
  • Fast, fixed length, exchanged every cycle

SDO (Service Data Object) - Big Picture

SDO is like a "settings/parameter" service channel

  • Used to change: max velocity, acceleration limits, following error threshold, PDO mapping...
  • Slow, not every cycle, typically used at startup/tuning/maintenance
  • For example, locking Drive's Max profile velocity is often done via SDO once

CSP vs CSV Mode Selection

For APR system (4.2m travel, 9.7 m/s max, ≥1m constant velocity zone):

CSP (Cyclic Synchronous Position) is recommended because:

  • Precise distance control for constant velocity zone
  • Better multi-axis synchronization
  • Easier trajectory planning (position points)
  • Direct following error protection
ModeCode (0x6060)Command ObjectUse Case
CSP80x607A Target PositionPosition trajectory
CSV90x60FF Target VelocitySpeed control

Why CSP for Your Application

  • Guaranteed constant velocity distance ≥ 1m: CSP gives "next position point every cycle" - constant velocity is naturally achieved with fixed Δpos/cycle
  • Reach 9.7 m/s within 4.2m: CSP lets you calculate "accel/const/decel" distance allocation directly
  • Dual-axis synchronization: CSP is more intuitive for multi-axis sync, phase lock, following error protection

Minimum Required PDO Mapping (CSP)

RxPDO (Master → Drive)

ObjectNameTypePurpose
0x6040ControlwordUINT16State machine control
0x6060Modes of OperationINT8Set CSP (=8)
0x607ATarget PositionINT32Position command (inc)
0x60B2Torque OffsetINT16Optional: feed-forward

TxPDO (Drive → Master)

ObjectNameTypePurpose
0x6041StatuswordUINT16State feedback
0x6064Position Actual ValueINT32Position feedback (inc)
0x606CVelocity Actual ValueINT32Velocity feedback
0x6061Modes of Op DisplayINT8Confirm CSP active

Recommended Diagnostic PDO

Strongly Recommended (Debug Essential)

ObjectNameDirectionPurpose
0x603FError CodeTxFirst-look fault diagnosis
0x60FDDigital InputsTxLimit/Home switch status
0x6077Torque Actual ValueTxLoad/friction monitoring

Optional (Enhanced Control)

ObjectNameDirectionPurpose
0x607FMax Profile VelocityTxVerify speed limit
0x60F4Following Error ActualTxReal-time error

DC Synchronization

Free Run vs DC Sync0

ModeDescriptionUse Case
Free RunAsync, PDO interval ≥250μsSimple applications
DC Sync0Synchronized clocksMulti-axis (recommended)

For dual-axis LMSA13L: Use DC Sync0 for precise synchronization.

DC Configuration in TwinCAT

  1. EtherCAT Master → Advanced Settings → Distributed Clocks
  2. Enable DC for each slave
  3. Set Sync0 cycle time = NC Task cycle (e.g., 1ms)

Unit Conversion (Critical)

PDO position values are in increments (inc), not mm.

Calibration Procedure

  1. Jog axis at low speed for known distance (e.g., 100mm)
  2. Read 0x6064 delta (actual increments)
  3. Calculate: inc_per_mm = delta_inc / 100
  4. Configure NC scaling factor

Important Objects

ObjectUnitNotes
0x607AincTarget position
0x6064incActual position
0x60FFinc/sTarget velocity
0x607Finc/sMax velocity limit
0x6083inc/s²Acceleration

Object Dictionary Structure

In EtherCAT (CoE = CANopen over EtherCAT), each slave has a built-in "data dictionary":

FieldDescription
Index (16-bit)Main category, e.g., 0x6040
SubIndex (8-bit)Sub-item, e.g., 0x6040:01
NameParameter name, e.g., Controlword
AccessPermission: R=Read, W=Write
TypeData type (UINT, DINT...)

ESI File Management

Import Procedure

  1. Copy HIWIN_MIKROSYSTEM_ED1F_20250107.xml to: C:\TwinCAT\3.1\Config\Io\EtherCAT\
  2. Keep only ONE version (avoid conflicts)
  3. TwinCAT → I/O → Devices → Reload Device Descriptions
  4. Scan for devices

Troubleshooting

  • "Device not found" → Check ESI file location
  • Version mismatch → Remove duplicate ESI files
  • Wrong PDO mapping → Verify ESI matches firmware

Available References

  • references/pdo-sdo-cia402.md - Comprehensive explanation of PDO, SDO, CiA402 relationships
  • references/dc-synchronization.md - Free Run vs DC synchronization concepts
  • references/can-canopen.md - CAN bus and CANopen differences
  • references/nq-ec8l-esi.md - Keyence NQ-EC8L ESI configuration reference
  • references/nq-ec8l-xml-analysis.md - Complete XML analysis of NQ-EC8L ESI