CiA 402 - Servo drive profile
CiA 402 is the CANopen device profile for drives and motion control equipment, the most widely used standard for servo drives.
Protocol overview
What is CiA 402?
Protocol layering:
EtherCAT application layer
└── CoE (CANopen over EtherCAT)
├── CiA 401 (general-purpose I/O module)
├── CiA 402 (drives and motion control) ← current profile
└── other CiA device profiles
What does CiA 402 define?
CiA 402 defines the following in the 0x6000-0x67FF range of the CoE object dictionary (some cyclic synchronous objects extend to 0x68FF, for example 0x60FF target velocity):
- Standard state machine: unified state transition logic for drives
- Modes of operation: several motion control modes (position, velocity, torque and others)
- Standard objects: unified control and feedback parameters
- PDO mapping: real-time motion control data exchange
- Interoperability: drives from different vendors can be exchanged
State machine
CiA 402 defines a complete drive state machine
Main states
| State | Description | Controlword | Statusword |
|---|---|---|---|
| Not ready to switch on | Initialization state, the drive is not ready | - | xxxx xxxx x0xx 0000 |
| Switch on disabled | Drive disabled, commands can be received | - | xxxx xxxx x1xx 0000 |
| Ready to switch on | Ready to switch on, voltage not enabled | 0x06 | xxxx xxxx x01x 0001 |
| Switched on | Switched on, voltage enabled but not running | 0x07 | xxxx xxxx x01x 0011 |
| Operation enabled | Operation enabled, normal operation possible | 0x0F | xxxx xxxx x01x 0111 |
| Quick stop active | Quick stop active | 0x02 | xxxx xxxx x00x 0111 |
| Fault reaction active | Fault reaction active | - | xxxx xxxx x0xx 1111 |
| Fault | Fault state | 0x86 (bit7 rising edge, bit2=1) | xxxx xxxx x0xx 1000 |
State transition commands
| Command | Controlword | Description |
|---|---|---|
| Shutdown | 0x06 | Shut down, enter Ready to switch on |
| Switch on | 0x07 | Switch on, enter Switched on |
| Enable operation | 0x0F | Enable operation, enter Operation enabled |
| Disable voltage | 0x00 | Disable voltage, return to Switch on disabled |
| Quick stop | 0x02 | Quick stop |
| Fault reset | 0x86 | Fault reset (bit7 rising edge; bit2 must be 1 — with bit2=0, 0x80/0x00 also trigger Quick stop) |
Advancement criteria (advance on the measured 0x6041)
The controlwords in the table above are commands, not results. 0x06 → 0x07 → 0x0F must be sent step by step; after each step read 0x6041 to confirm the state has been reached before sending the next command. Do not advance open-loop on a fixed delay, and do not send all three steps in the same cycle.
| Statusword mask | State | Next step |
|---|---|---|
(sw & 0x4F) == 0x40 | Switch on disabled | Send 0x06 |
(sw & 0x6F) == 0x21 | Ready to switch on | Send 0x07 |
(sw & 0x6F) == 0x23 | Switched on | Send 0x0F |
(sw & 0x6F) == 0x27 | Operation enabled | Hold 0x0F, motion allowed |
(sw & 0x4F) == 0x08 | Fault | Clear the fault cause first, then execute fault reset |
Exit path from Quick stop active: do not send 0x06 directly. First send 0x0000 (Disable voltage) to return to Switch on disabled, then advance again through 0x06 → 0x07 → 0x0F. The SDK's Enable() follows the same path for QuickStopActive.
Fault reset: bit7 of 0x6040 is rising-edge triggered, and bit2 must be 1. Therefore do not write 0x0080 or 0x0000 — bit2=0 in both values, and they also trigger Quick stop. The correct approach is to write 0x0006 first (bit7=0, bit2=1) and then 0x0086 (bit7 rising edge, bit2=1), with the two actions in consecutive cycles. The fault reset bit only takes effect in OP process data: under PreOp / SafeOp, writing 0x6040 over SDO does not reset faults such as 0x7500.
CiA402Instance.FaultReset() already wraps 0x0006 → 0x0086 and the clearing of the 0x7500 synchronous error counter; however, it performs an SDO mailbox round trip, so it must not be called inside a PDO callback. On the real-time path, call FaultResetStep(0) / FaultResetStep(1) in two consecutive cycles instead.
Controlword and statusword
Controlword (0x6040)
| Bit | Name | Description |
|---|---|---|
| 0 | Switch on | Switch-on command |
| 1 | Enable voltage | Enable voltage |
| 2 | Quick stop | Quick stop (0=active) |
| 3 | Enable operation | Enable operation |
| 4 | Operation mode specific | New setpoint |
| 5 | Operation mode specific | Change immediately |
| 6 | Operation mode specific | Relative |
| 7 | Fault reset | Fault reset (rising edge) |
| 8 | Halt | Halt |
| 9-10 | Operation mode specific | Operation mode specific |
| 11-15 | Manufacturer specific | Manufacturer specific |
Common controlwords:
const ushort SHUTDOWN = 0x06; // 0000 0110
const ushort SWITCH_ON = 0x07; // 0000 0111
const ushort ENABLE_OP = 0x0F; // 0000 1111
const ushort DISABLE_VOLTAGE = 0x00; // 0000 0000
const ushort QUICK_STOP = 0x02; // 0000 0010
const ushort FAULT_RESET_LOW = 0x06; // 0000 0110: bit7=0, bit2=1 (reset low phase)
const ushort FAULT_RESET = 0x86; // 1000 0110: bit7 rising edge, bit2=1
Statusword (0x6041)
| Bit | Name | Description |
|---|---|---|
| 0 | Ready to switch on | Ready |
| 1 | Switched on | Switched on |
| 2 | Operation enabled | Operation enabled |
| 3 | Fault | Fault |
| 4 | Voltage enabled | Voltage enabled |
| 5 | Quick stop | Quick stop (0=active) |
| 6 | Switch on disabled | Switch on disabled |
| 7 | Warning | Warning |
| 8 | Manufacturer specific | Manufacturer specific |
| 9 | Remote | Remote mode |
| 10 | Target reached | Target reached |
| 11 | Internal limit active | Internal limit active |
| 12 | Operation mode specific | Setpoint acknowledge |
| 13 | Operation mode specific | Following error |
| 14-15 | Manufacturer specific | Manufacturer specific |
The meaning of bit12 / bit13 depends on the mode of operation:
| Mode | bit12 | bit13 |
|---|---|---|
| PP | Set-point acknowledge (the response in the bit4 handshake) | Following error |
| HM | Homing attained (homing complete) | Homing error |
| IP / CSP | Mode specific | Mode specific (usually following error) |
When judging the homing result, do not look only at bit12/bit13 of 0x6041; also read 0x6061 to confirm that the drive is still in HM mode. Once the mode has been switched, these two bits take on a different meaning.
Modes of operation
Mode definitions (Modes of operation, 0x6060)
| Value | Abbreviation | Mode | Description |
|---|---|---|---|
| 1 | PP | Profile Position Mode | Profile position mode, point-to-point motion |
| 2 | VL | Velocity Mode | Velocity mode (non-cyclic velocity command, used by some drives) |
| 3 | PV | Profile Velocity Mode | Profile velocity mode, velocity control |
| 4 | PT | Profile Torque Mode | Profile torque mode, torque control |
| 6 | HM | Homing Mode | Homing mode, establishes the position reference |
| 7 | IP | Interpolated Position Mode | Interpolated position mode, trajectory tracking |
| 8 | CSP | Cyclic Synchronous Position Mode | Cyclic synchronous position mode |
| 9 | CSV | Cyclic Synchronous Velocity Mode | Cyclic synchronous velocity mode |
| 10 | CST | Cyclic Synchronous Torque Mode | Cyclic synchronous torque mode |
| 11 | CSTCA | Cyclic Synchronous Torque with Commutation Angle | Cyclic synchronous torque with commutation angle, a vendor extension mode |
0x6060 being writable does not mean the drive supports that mode. After writing, read 0x6061 back to confirm; if the two differ, check Supported Modes in the ESI or the device manual.
Mode details
PP - Profile Position Mode
Characteristics:
- Point-to-point motion
- Internal trajectory planning
- Trapezoidal / S-curve velocity profile
Main objects:
0x607A: Target position0x6081: Profile velocity0x6083: Profile acceleration0x6084: Profile deceleration
CSP - Cyclic Synchronous Position Mode
Characteristics:
- Cyclic position command
- Trajectory planning in the master
- Highest real-time performance
- Requires DC Sync0 synchronization
Main objects:
0x607A: Target position (updated every cycle)0x60B0: Position offset (added to the target position)0x60B1: Velocity offset (used for CSP feedforward)0x60B2: Torque offset (used for CSP feedforward)0x60C2: Interpolation time period
CSP feedforward: writing 0x607A alone is not enough for CSP. Write velocity feedforward to 0x60B1, torque feedforward to 0x60B2 and fine position correction to 0x60B0; the drive adds all three offsets to the cyclic command. Whether they are supported, their units and their limits are defined by the device manual.
Interpolation cycle (0x60C2): 0x60C2:01 is the value and 0x60C2:02 is the decimal exponent, so the actual cycle = value × 10^exponent seconds (the exponent is negative, for example 1 × 10^-3 = 1 ms). It must be aligned with the master LoopCycle, for example:
| Master cycle | 0x60C2:01 | 0x60C2:02 |
|---|---|---|
| 1 ms | 1 | -3 |
| 500 µs | 50 | -5 |
| 125 µs | 125 | -6 |
After writing, read 0x60C2 and 0x6061 back to confirm. Some drives require 0x60C2 / 0x6060 to be written after the SafeOp mapping has been completed; values written in PreOp are cleared. The write timing is defined by the device manual.
Multi-axis synchronization: all axes on the same master should be computed in one and the same ProcessDataCyclicSync callback, in a fixed order within one cycle, and only then written to 0x607A. Do not attach a separate timer or an independent callback to each axis — the commands for each axis would then take effect at different moments within the cycle, and coupled axes (gears, cams, gantries) would show intermediate states. Blocking calls such as SDO, FaultReset() and Thread.Sleep are forbidden inside the callback.
CSV - Cyclic Synchronous Velocity Mode
Characteristics:
- Cyclic velocity command
- Suited to velocity following
Main objects:
0x60FF: Target velocity0x60B2: Torque offset
CST - Cyclic Synchronous Torque Mode
Characteristics:
- Cyclic torque command
- Force control applications
Main objects:
0x6071: Target torque
Common objects
Control and status
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6040 | Controlword | UNSIGNED16 | RW/RXPDO | Controlword |
| 0x6041 | Statusword | UNSIGNED16 | RO/TXPDO | Statusword |
| 0x6060 | Modes of operation | INTEGER8 | RW | Mode of operation |
| 0x6061 | Modes of operation display | INTEGER8 | RO | Actual mode of operation |
Position objects
| Index | Name | Type | Unit | Description |
|---|---|---|---|---|
| 0x6062 | Position demand value | INTEGER32 | user units | Position demand value |
| 0x6063 | Position actual internal value | INTEGER32 | internal increments | Actual position (internal) |
| 0x6064 | Position actual value | INTEGER32 | user units | Actual position |
| 0x607A | Target position | INTEGER32 | user units | Target position |
| 0x607C | Home offset | INTEGER32 | user units | Home offset |
| 0x607D | Software position limit | ARRAY | user units | Software position limit |
0x6062 / 0x6064 / 0x607A / 0x607C / 0x607D all use user units (counts, mm, rad and so on after scaling through 0x6091/0x6092/0x6093); 0x6063 is the unscaled internal encoder increment. The two values are usually not equal — never use 0x6063 directly as 0x6064, and never assume "1 count = 1 user unit".
Velocity objects
| Index | Name | Type | Unit | Description |
|---|---|---|---|---|
| 0x606B | Velocity demand value | INTEGER32 | user units | Velocity demand value |
| 0x606C | Velocity actual value | INTEGER32 | user units | Actual velocity |
| 0x60FF | Target velocity | INTEGER32 | user units | Target velocity |
| 0x6081 | Profile velocity | UNSIGNED32 | user units | Profile velocity |
| 0x6083 | Profile acceleration | UNSIGNED32 | user units/s² | Profile acceleration |
| 0x6084 | Profile deceleration | UNSIGNED32 | user units/s² | Profile deceleration |
Torque objects
| Index | Name | Type | Unit | Description |
|---|---|---|---|---|
| 0x6071 | Target torque | INTEGER16 | per mille of rated | Target torque |
| 0x6077 | Torque actual value | INTEGER16 | per mille of rated | Actual torque |
| 0x60B2 | Torque offset | INTEGER16 | per mille of rated | Torque offset |
Code examples
Servo enable sequence
// servo is a slave instance that has already entered OP
var servo = master.Slaves[0];
var drv = servo.CoE?.CiA402; // slave.CoE is CoEInstance?, use ?. to avoid a null reference
// null has two meanings: the device is confirmed not to be CiA402, or 0x1000 cannot be read right now (retried once communication recovers)
if (drv == null)
{
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {servo.SlaveNum} 的 CiA402 实例不可用"); // The CiA402 instance for slave {servo.SlaveNum} is unavailable
return;
}
int enableFailCycles = 0;
// Recommended: use the CiA402Instance property (non-blocking, called every PDO cycle)
master.Events.ProcessDataCyclicSync += (masterIndex) =>
{
// Enable() returns bool: true=reached OperationEnabled, false=still transitioning or failed
if (drv.Enable())
{
enableFailCycles = 0;
return;
}
// A false must not be swallowed silently: look at the state first and tell "transitioning" from "fault/timeout"
enableFailCycles++;
StateCiA402 state = drv.StateDrive;
if (state == StateCiA402.Fault || state == StateCiA402.FaultReactionActive)
{
// Fault is not reset automatically by Enable(); a fault reset must be executed explicitly
LogManager.Instance.AddLog(LogCategory.Error,
$"从站 {servo.SlaveNum} 故障: 0x603F=0x{drv.ErrorCode:X4}, 需先 FaultReset"); // Slave {servo.SlaveNum} fault: 0x603F=0x{drv.ErrorCode:X4}, FaultReset required first
}
else if (enableFailCycles > 100) // 1 ms cycle, still not enabled after about 100 ms
{
LogManager.Instance.AddLog(LogCategory.Error,
$"从站 {servo.SlaveNum} 使能超时: state={state}, SW=0x{drv.Statusword:X4}"); // Slave {servo.SlaveNum} enable timeout: state={state}, SW=0x{drv.Statusword:X4}
}
};
Position mode (PP)
var servo = master.Slaves[0];
var drv = servo.CoE?.CiA402;
if (drv == null) return;
// 1. Configure the mode of operation and the motion parameters (through the OD properties), then read 0x6061 to confirm
drv.OperationMode = ModeCiA402.PP;
drv.ProfileVelocity = 1000;
drv.ProfileAcceleration = 5000;
drv.ProfileDeceleration = 5000;
// 2. Check soft limits on the command side first; never hand an out-of-range target to the drive to reject or clamp
const int target = 100000;
if (target < drv.SoftwarePositionLimitMin || target > drv.SoftwarePositionLimitMax)
{
LogManager.Instance.AddLog(LogCategory.Error,
$"目标 {target} 超出软限位 [{drv.SoftwarePositionLimitMin}, {drv.SoftwarePositionLimitMax}]"); // Target {target} exceeds the soft limit [{drv.SoftwarePositionLimitMin}, {drv.SoftwarePositionLimitMax}]
return;
}
int ppStep = 0;
// 3. Enable in the PDO callback and advance the bit4/bit12 handshake
master.Events.ProcessDataCyclicSync += (masterIndex) =>
{
if (!drv.Enable()) return; // Production code must record state/alarm as in the previous section; it must not silently return
switch (ppStep)
{
case 0: // Trigger: bit4 rising edge
drv.NewSetpoint(target);
ppStep = 1;
break;
case 1: // Wait for the drive to confirm bit12 (Set-point acknowledge)
if ((drv.Statusword & 0x1000) != 0)
{
drv.ClearNewSetpoint(); // bit4 returns to 0
ppStep = 2;
}
break;
case 2: // Wait for bit12 to clear; the handshake is then done
if ((drv.Statusword & 0x1000) == 0)
ppStep = 3;
break;
case 3: // Wait for bit10 (Target reached)
if (drv.TargetReached)
{
LogManager.Instance.AddLog(LogCategory.Message, $"从站 {servo.SlaveNum} 到达目标位置 {target}"); // Slave {servo.SlaveNum} reached target position {target}
ppStep = 4;
}
break;
}
};
The PP handshake order is 0x0F → 0x1F → 等 bit12 → 0x0F → 等 bit12 清除 → 等 bit10. TargetReached (bit10) only indicates that the target has been reached and cannot replace Set-point acknowledge (bit12); using it to clear bit4 makes the drive treat the new setpoint as cancelled midway.
Cyclic synchronous position mode (CSP)
var servo = master.Slaves[0];
var drv = servo.CoE?.CiA402;
if (drv == null) return;
// 1. Configure the mode of operation and the interpolation cycle, then read back to confirm
drv.OperationMode = ModeCiA402.CSP;
drv.InterpolationTimePeriodValue = 1; // 0x60C2:01, 1 ms cycle time
drv.InterpolationTimePeriodIndex = -3; // 0x60C2:02, actual cycle = 1 x 10^-3 s
// The drv.OperationMode getter reads 0x6061; if it does not agree with CSP, stop sending positions
// 2. The first cycle target must equal the actual position to avoid a power-on jump
int target = drv.PositionActual;
const int maxDeltaPerCycle = 100; // Convert the velocity limit into a maximum increment per cycle
double angle = 0;
master.Events.ProcessDataCyclicSync += (masterIndex) =>
{
if (!drv.Enable()) return; // Production code must record state/alarm; it must not silently return
// Generate a trajectory (example: sine wave)
int desired = (int)(10000 * Math.Sin(angle));
angle += 0.01;
// Clamping on the command side: per-cycle increment + soft limits, not relying on the drive to bail you out
int delta = Math.Clamp(desired - target, -maxDeltaPerCycle, maxDeltaPerCycle);
target += delta;
if (target < drv.SoftwarePositionLimitMin || target > drv.SoftwarePositionLimitMax)
{
LogManager.Instance.AddLog(LogCategory.Error,
$"CSP 目标 {target} 超出软限位 [{drv.SoftwarePositionLimitMin}, {drv.SoftwarePositionLimitMax}]"); // CSP target {target} exceeds the soft limit [{drv.SoftwarePositionLimitMin}, {drv.SoftwarePositionLimitMax}]
return;
}
// Velocity/torque feedforward can be superimposed (0x60B1 / 0x60B2); keep them at 0 when unused
drv.TargetPosition = target;
};
Units and scaling
Position units
Position scaling is determined by the Factor Group; the common objects are:
0x6091: Gear ratio (sub-index 1 = motor revolutions, sub-index 2 = load shaft revolutions)0x6092: Feed constant (sub-index 1 = feed per revolution, sub-index 2 = load shaft revolutions)0x6093: Position factor (sub-index 1 = numerator, sub-index 2 = denominator)0x6094: Velocity encoder factor
0x6093 converts internal encoder increments into user position units. Vendors do not agree on the direction of the numerator/denominator or on how 0x6091 / 0x6092 combine with 0x6093; some drives use only 0x6093, while others fold the gear ratio and the feed constant in as well. Do not apply one universal formula:
Common implementation (illustrative only; follow the device manual):
User position = internal increments × (0x6093:01 / 0x6093:02) × (gear ratio / feed constant)
Engineering practice:
- First decide on the user unit (counts, mm, rad or degrees), then configure
0x6091/0x6092/0x6093according to the device manual. - Express the ratio with large integer numerator/denominator values (for example 0x20000 / 0x10000) to avoid rounding error from small ratio values.
- After configuration, command a known displacement (for example 10 mm) and read back
0x6064and0x6063to compare, confirming that the scaling really took effect; do not write without verifying.
Velocity units
Velocity objects (0x606B / 0x606C / 0x60FF / 0x6081) use user velocity units per second. Velocity scaling also involves 0x6094 (Velocity encoder factor) and 0x6095 / 0x6096 (Velocity factor 1/2); 0x6097 is the acceleration factor. Not every drive supports all factor objects; where an object is missing, use the equivalent parameter given in the manual.
Acceleration units
0x6083 / 0x6084 / 0x609A are in user units/s². When the position user unit is mm the result is mm/s²; when the position user unit is counts the result is counts/s². It is tied to position scaling, so after changing 0x6093 you must re-check the acceleration values.
Torque units
Thousandths of rated torque (1000 = 100%). 0x6071 / 0x6077 / 0x60B2 all use this convention.
Homing mode
Homing method (0x6098)
| Method number | Reference signal | Description |
|---|---|---|
| 1-2 | Limit switch + zero signal | Negative/positive limit direction; after hitting the limit, search for the zero pulse |
| 3-6 | Home switch + zero signal | Rising/falling edge of the home switch, with direction combinations |
| 7-14 | Home switch + zero signal | Finer combinations with direction and zero pulse |
| 17-18 | Home switch | Search for the home switch only, not the zero signal |
| 19-30 | Home switch + zero signal | Combinations of home switch and encoder zero pulse (including direction) |
| 33-34 | Zero signal | Encoder zero pulse only, negative/positive direction |
| 35 | Current position | Set the current position directly as the home position |
The homing method number itself encodes the search direction. Changing the method number changes the approach direction; you cannot change only the velocity and leave the method unchanged.
After homing, the position reference is shifted by 0x607C (home offset, user units): the sign of 0x607C determines which way the zero position moves. After changing 0x607C you must home again or rebuild the position reference; do not assume the drive recalculates automatically.
Homing velocity and acceleration
| Index | Sub-index | Name | Type | Description |
|---|---|---|---|---|
| 0x6099 | 01 | Speed during search for switch | UNSIGNED32 | Velocity while searching for the reference signal (fast) |
| 0x6099 | 02 | Speed during search for zero | UNSIGNED32 | Velocity while searching for zero (slow) |
| 0x609A | 00 | Homing acceleration | UNSIGNED32 | Acceleration and deceleration during homing |
Notes:
0x6099:01— homing search velocity, used to approach the limit switch or home switch quickly0x6099:02— homing zero velocity, used to locate the encoder zero signal precisely at slow speed0x609A— homing acceleration, controls acceleration and deceleration during homing. Applies to all homing methods
Homing sequence
var servo = master.Slaves[0];
var drv = servo.CoE?.CiA402;
if (drv == null) return;
// 1. Configure the homing parameters (through the OD properties), then read 0x6061 to confirm HM
drv.OperationMode = ModeCiA402.HM;
drv.HomingMethod = 1; // The method number decides the search direction; do not only change the speed
drv.HomingSpeedSearch = 500;
drv.HomingSpeedZero = 100;
drv.HomingAcceleration = 1000;
drv.HomeOffset = 0; // 0x607C, zero offset after homing (user units); the sign sets the direction
bool homingStarted = false;
bool homingDone = false;
// 2. Enable and run homing inside the PDO callback
master.Events.ProcessDataCyclicSync += (masterIndex) =>
{
if (homingDone || !drv.Enable()) return;
if (!homingStarted)
{
drv.StartHoming(); // 0x6040 bit4 = 1
homingStarted = true;
}
if (drv.HomingAttained)
{
homingDone = true;
LogManager.Instance.AddLog(LogCategory.Message, $"从站 {servo.SlaveNum} 回零完成, 0x6064={drv.PositionActual}"); // Slave {servo.SlaveNum} homing complete, 0x6064={drv.PositionActual}
}
else if (drv.HomingError)
{
homingDone = true;
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {servo.SlaveNum} 回零错误, 0x603F=0x{drv.ErrorCode:X4}"); // Slave {servo.SlaveNum} homing error, 0x603F=0x{drv.ErrorCode:X4}
}
};
Statusword parsing
// Recommended: use the CiA402Instance property to get the state directly
var drv = servo.CoE?.CiA402;
if (drv == null) return;
var state = drv.StateDrive;
Console.WriteLine($"驱动状态: {state.GetDescription()}"); // Drive state: {state.GetDescription()}
// Or use the static method to parse the raw status word
ushort sw = drv.Statusword;
var parsed = CiA402Instance.ParseState(sw);
Console.WriteLine($"状态字: 0x{sw:X4} → {parsed}"); // Status word: 0x{sw:X4} → {parsed}