CiA 401 - I/O modules
CiA 401 is the CANopen device profile for generic I/O modules. It defines the standard interface for digital and analog I/O devices, is the most basic I/O device profile, and is followed by nearly every I/O module vendor.
Protocol introduction
What is CiA 401?
Protocol layering:
EtherCAT application layer
└── CoE (CANopen over EtherCAT)
├── CiA 401 (general-purpose I/O module) ← current profile
├── CiA 402 (drives and motion control)
└── other CiA device profiles
What does CiA 401 define?
Within the 0x6000-0x64FF range of the CoE object dictionary, CiA 401 defines:
- Digital input/output objects (0x6000-0x63FF)
- Analog input/output objects (0x6400-0x64FF)
- Polarity and filter configuration
- Interrupt configuration
- Sensor type definitions
Applicable devices
- Digital I/O modules (for example Beckhoff EL2008, EL1008)
- Analog I/O modules (for example Beckhoff EL3064, EL4004)
- Mixed I/O modules
- Sensor interface modules
Digital I/O objects
Digital inputs (DI)
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6000 | Read Input 8 Bit | UNSIGNED8 | RO/TXPDO | 8-bit digital input |
| 0x6001 | Read Input 16 Bit | UNSIGNED16 | RO/TXPDO | 16-bit digital input |
| 0x6002 | Read Input 32 Bit | UNSIGNED32 | RO/TXPDO | 32-bit digital input |
| 0x6003 | Read Input Bit 1-128 | ARRAY | RO/TXPDO | Single-bit access |
| 0x6005 | Read Input Byte 1-128 | ARRAY | RO/TXPDO | Byte access |
Digital input polarity and filtering
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6100 | Input Polarity 8 Bit | UNSIGNED8 | RW | 8-bit input polarity |
| 0x6150 | Input Filter Constant | ARRAY | RW | Input filter constant (µs) |
Digital outputs (DO)
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6200 | Write Output 8 Bit | UNSIGNED8 | RW/RXPDO | 8-bit digital output |
| 0x6201 | Write Output 16 Bit | UNSIGNED16 | RW/RXPDO | 16-bit digital output |
| 0x6202 | Write Output 32 Bit | UNSIGNED32 | RW/RXPDO | 32-bit digital output |
| 0x6206 | Error Mode Output 8 Bit | UNSIGNED8 | RW | Output value in error mode |
| 0x6207 | Error Value Output 8 Bit | UNSIGNED8 | RW | Output value on error |
Digital output polarity
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6300 | Output Polarity 8 Bit | UNSIGNED8 | RW | 8-bit output polarity |
Analog I/O objects
Analog inputs (AI)
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6401 | Read Analog Input 16 Bit | INTEGER16 | RO/TXPDO | 16-bit analog input |
| 0x6402 | Read Analog Input 32 Bit | INTEGER32 | RO/TXPDO | 32-bit analog input |
| 0x6420 | Analog Input Full Scale Range | RECORD | RO | Analog input full-scale range |
Analog outputs (AO)
| Index | Name | Type | Access | Description |
|---|---|---|---|---|
| 0x6411 | Write Analog Output 16 Bit | INTEGER16 | RW/RXPDO | 16-bit analog output |
| 0x6412 | Write Analog Output 32 Bit | INTEGER32 | RW/RXPDO | 32-bit analog output |
| 0x6430 | Analog Output Full Scale Range | RECORD | RO | Analog output full-scale range |
| 0x6440 | Analog Output Error Mode | ARRAY | RW | Error mode |
Code examples
Digital I/O control
// slave.CoE is CoEInstance? - null when the device has no CoE mailbox, must be checked before use
var coe = slave.CoE;
if (coe == null)
{
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 没有 CoE 邮箱"); // Slave {slave.SlaveNum} has no CoE mailbox
return;
}
// Read digital inputs: a failed SDORead returns null (never an array of length 0), so check for null before indexing
byte[]? inData = coe.SDORead(0x6000, 0);
if (inData == null || inData.Length < 1)
{
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 读 0x6000 失败"); // Slave {slave.SlaveNum} failed to read 0x6000
return;
}
byte inputs = inData[0];
Console.WriteLine($"数字输入: 0x{inputs:X2}"); // Digital inputs: 0x{inputs:X2}
// Write a digital output: returning false means a slave refusal or a mailbox failure; it must not be treated as success and continued
byte outputs = 0xFF; // All outputs high
if (!coe.SDOWrite(0x6200, 0, new byte[] { outputs }))
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 写 0x6200 失败"); // Slave {slave.SlaveNum} failed to write 0x6200
// Through the PDO (real time): Inputs is a whole-frame snapshot; Outputs is a whole-frame setter -
// The array length must equal slave.Obytes, otherwise throw InvalidOperationException (never silently truncate/pad).
// Even when changing a single mapping byte, read the whole frame first, modify it, and write the whole thing back.
byte[] pdoInputs = slave.PDO.Inputs;
byte[] pdoOutputs = slave.PDO.Outputs;
pdoOutputs[0] = outputs; // The byte offsets of 0x6200 follow the ESI / DENI PDO mapping
slave.PDO.Outputs = pdoOutputs;
Console.WriteLine($"PDO 输入 {pdoInputs.Length} B / 输出 {pdoOutputs.Length} B"); // PDO input {pdoInputs.Length} B / output {pdoOutputs.Length} B
Analog acquisition
var coe = slave.CoE;
if (coe == null)
{
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 没有 CoE 邮箱"); // Slave {slave.SlaveNum} has no CoE mailbox
return;
}
// Read the analog input (0x6401 channel 1): 16-bit signed, 2 bytes little-endian
byte[]? ai = coe.SDORead(0x6401, 1);
if (ai == null || ai.Length < 2)
{
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 读 0x6401:01 失败"); // Slave {slave.SlaveNum} failed to read 0x6401:01
return;
}
short analogValue = BitConverter.ToInt16(ai, 0);
Console.WriteLine($"模拟输入: {analogValue}"); // Analog input: {analogValue}
// Write the analog output (0x6411 channel 1)
short outputValue = 2048;
if (!coe.SDOWrite(0x6411, 1, BitConverter.GetBytes(outputValue)))
LogManager.Instance.AddLog(LogCategory.Error, $"从站 {slave.SlaveNum} 写 0x6411:01 失败"); // Slave {slave.SlaveNum} failed to write 0x6411:01