Motion control
Motion control over EtherCAT is always the same thing at heart: compute each axis target every bus cycle and send them all in the same PDO frame. Differential, synchronized, cam and interpolation all follow this path; only the way the target is computed differs.
The HCFA X3E open-source example is not synchronized axes. It is a single-axis CSP commissioning example: one servo, cycle 500 µs (2000 Hz), and the master writes 0x607A on every tick. Synchronized axes means multiple axes following the same virtual master axis, with every axis written inside the same cyclic callback.
How to choose
| What you need | Mode | Documentation on this site |
|---|---|---|
| Single-axis start, jog, 1/4 turn (single-axis commissioning, not synchronized axes) | CSP single-axis | HCFA X3E · 500 µs |
| Point-to-point, with the drive generating the trapezoid itself | PP (0x6060 = 1) | Open source STF-EC_CSP_PP, Ezi-SERVO2_CSP_PP |
| Multiple axes moving together at fixed ratios, gantry 1:1, reverse following | Electronic gearing / synchronized axes | Synchronized axes / electronic gearing |
| Gantry side correction, anti-skew | Same virtual master axis + in-cycle correction | Gantry dual-drive differential |
| Follow the master phase per a cam table | Electronic cam | Multi-axis electronic cam |
| Linear / circular multi-axis path | CSP interpolation | Open source Panasonic_CNC_Interpolation |
| Conveyor following + probe picking | Master-slave synchronization | Open source Panasonic_ConveyorSync |
| Single-axis CSP + non-servo counter module | CSP single-axis + input PDO | Open source FurutaPendulum |
| Tool changer / digital handshake | State machine + IO | Open source RobotToolChanger |
| XYZ pick-and-place | CSP + interpolation | 3-axis gantry robot |
Jitter red lines (read this before any multi-axis example)
When multi-axis synchronization shows jitter, jumps or loss of sync, check this table row by row:
| Red line | Correct practice | Consequence of violating it |
|---|---|---|
Do not write 0x001F in CSP | Keep the control word at 0x000F; update the target only through 0x607A each cycle | bit4 (0x0010) is NewSetpoint for PP/HM and is undefined under CSP; on a measured HCFA X3E, writing it continuously reports 0x7500 |
| Use the right mask when judging state | Operation-enabled (sw & 0x6F): 0x40 / 0x21 / 0x23 / 0x27; fault (sw & 0x4F) == 0x08; NotReady (sw & 0x4F) == 0x00 | Judging the operation state with 0x4F misreads a normal state as not operational, so the enable handshake oscillates back and forth |
| Target equals actual while disabled | When disabled / handshaking / faulted / QuickStop / NotReady, always set TargetPosition = PositionActualValue | At the enable instant the target is still at the old value and the motor jerks |
| Fault reset through process data | Send 0x86 for one tick in the PDO callback; use 0x0006 at all other times | The state machine desynchronizes, the drive latches 0x7500, and repeated resets make it worse |
| QuickStopActive has exactly one exit | When (sw & 0x6F) == 0x07, send 0x0000 (T12 = Disable Voltage) to return to SwitchOnDisabled, then go back to 0x0006 | 0x0006 is undefined in that state and the axis stays stuck in QuickStopActive forever |
| Write every axis in the same callback | Finish all axes inside one ProcessDataCyclicSync and submit them in the same PDO frame | Axes end up one tick apart and the synchronized motion is torn apart |
| Never use Sleep/while as the cycle | Real-time control hooks only ProcessDataCyclicSync | The cycle becomes indeterminate, jitter grows and DC synchronization is lost |
| A single-axis example is not synchronized axes | The single-axis CSP page (HCFA X3E) is only for commissioning one axis | Each axis writes its own target; they all "turn", but they are not synchronized |
Single-axis commissioning page: HCFA X3E · 500 µs is a single-axis CSP commissioning example, not synchronized axes, and cannot be extended directly into a multi-axis template. For multi-axis synchronization see Synchronized axes / electronic gearing, Multi-axis electronic cam and Gantry dual-drive differential.
The cyclic callback
Differential, gearing, cam and interpolation all compute and write their mappings inside ProcessDataCyclicSync. State events, SDO and Thread.Sleep must never serve as the motion cycle. Process data uses InputsMapping / OutputsMapping.
Common CSP cycles on Windows: the HCFA X3E single-axis example uses 500 µs; the MOONS' STF-EC synchronized axes use 500 µs by default (adjustable 125–10000 µs); the official electronic cam example uses 1 ms. The actual configuration governs, and LoopCycle must equal DC Sync0.
Complete example code
All of the following projects live in the repository at Darra_EtherCAT_开源案例/Windows/CSharp/; the GitHub directories map one-to-one and every project compiles and runs:
| Sample | What it covers |
|---|---|
| HCFA_X3E_QuarterTurn | Single-axis CSP, 500 µs, 1/4-turn cadence (single-axis commissioning, not synchronized axes) |
| Ezi-SERVO2_CSP_PP | Single-axis CSP / PP dual mode |
| STF-EC_CSP_PP | Multi-axis stepper CSP / PP; the axis count comes from the config.deni scan result |
| STF-EC_SyncAxis | Virtual master axis + electronic gearing (500 µs by default, adjustable 125–10000 µs) |
| STF-EC_ECam | Electronic cam, DC Sync0 1 ms |
| Panasonic_CNC_Interpolation | Multi-axis CSP linear / circular interpolation |
| Panasonic_ConveyorSync | Conveyor master-slave synchronization + probe picking |
| FurutaPendulum | Single-axis CSP + non-servo counter module, 500 µs |
| RobotToolChanger | Tool changer + safety interlocking + slave-loss reconnect |