Skip to main content

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 needModeDocumentation on this site
Single-axis start, jog, 1/4 turn (single-axis commissioning, not synchronized axes)CSP single-axisHCFA X3E · 500 µs
Point-to-point, with the drive generating the trapezoid itselfPP (0x6060 = 1)Open source STF-EC_CSP_PP, Ezi-SERVO2_CSP_PP
Multiple axes moving together at fixed ratios, gantry 1:1, reverse followingElectronic gearing / synchronized axesSynchronized axes / electronic gearing
Gantry side correction, anti-skewSame virtual master axis + in-cycle correctionGantry dual-drive differential
Follow the master phase per a cam tableElectronic camMulti-axis electronic cam
Linear / circular multi-axis pathCSP interpolationOpen source Panasonic_CNC_Interpolation
Conveyor following + probe pickingMaster-slave synchronizationOpen source Panasonic_ConveyorSync
Single-axis CSP + non-servo counter moduleCSP single-axis + input PDOOpen source FurutaPendulum
Tool changer / digital handshakeState machine + IOOpen source RobotToolChanger
XYZ pick-and-placeCSP + interpolation3-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 lineCorrect practiceConsequence of violating it
Do not write 0x001F in CSPKeep the control word at 0x000F; update the target only through 0x607A each cyclebit4 (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 stateOperation-enabled (sw & 0x6F): 0x40 / 0x21 / 0x23 / 0x27; fault (sw & 0x4F) == 0x08; NotReady (sw & 0x4F) == 0x00Judging the operation state with 0x4F misreads a normal state as not operational, so the enable handshake oscillates back and forth
Target equals actual while disabledWhen disabled / handshaking / faulted / QuickStop / NotReady, always set TargetPosition = PositionActualValueAt the enable instant the target is still at the old value and the motor jerks
Fault reset through process dataSend 0x86 for one tick in the PDO callback; use 0x0006 at all other timesThe state machine desynchronizes, the drive latches 0x7500, and repeated resets make it worse
QuickStopActive has exactly one exitWhen (sw & 0x6F) == 0x07, send 0x0000 (T12 = Disable Voltage) to return to SwitchOnDisabled, then go back to 0x00060x0006 is undefined in that state and the axis stays stuck in QuickStopActive forever
Write every axis in the same callbackFinish all axes inside one ProcessDataCyclicSync and submit them in the same PDO frameAxes end up one tick apart and the synchronized motion is torn apart
Never use Sleep/while as the cycleReal-time control hooks only ProcessDataCyclicSyncThe cycle becomes indeterminate, jitter grows and DC synchronization is lost
A single-axis example is not synchronized axesThe single-axis CSP page (HCFA X3E) is only for commissioning one axisEach 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:

SampleWhat it covers
HCFA_X3E_QuarterTurnSingle-axis CSP, 500 µs, 1/4-turn cadence (single-axis commissioning, not synchronized axes)
Ezi-SERVO2_CSP_PPSingle-axis CSP / PP dual mode
STF-EC_CSP_PPMulti-axis stepper CSP / PP; the axis count comes from the config.deni scan result
STF-EC_SyncAxisVirtual master axis + electronic gearing (500 µs by default, adjustable 125–10000 µs)
STF-EC_ECamElectronic cam, DC Sync0 1 ms
Panasonic_CNC_InterpolationMulti-axis CSP linear / circular interpolation
Panasonic_ConveyorSyncConveyor master-slave synchronization + probe picking
FurutaPendulumSingle-axis CSP + non-servo counter module, 500 µs
RobotToolChangerTool changer + safety interlocking + slave-loss reconnect