Skip to main content

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)​

IndexNameTypeAccessDescription
0x6000Read Input 8 BitUNSIGNED8RO/TXPDO8-bit digital input
0x6001Read Input 16 BitUNSIGNED16RO/TXPDO16-bit digital input
0x6002Read Input 32 BitUNSIGNED32RO/TXPDO32-bit digital input
0x6003Read Input Bit 1-128ARRAYRO/TXPDOSingle-bit access
0x6005Read Input Byte 1-128ARRAYRO/TXPDOByte access

Digital input polarity and filtering​

IndexNameTypeAccessDescription
0x6100Input Polarity 8 BitUNSIGNED8RW8-bit input polarity
0x6150Input Filter ConstantARRAYRWInput filter constant (µs)

Digital outputs (DO)​

IndexNameTypeAccessDescription
0x6200Write Output 8 BitUNSIGNED8RW/RXPDO8-bit digital output
0x6201Write Output 16 BitUNSIGNED16RW/RXPDO16-bit digital output
0x6202Write Output 32 BitUNSIGNED32RW/RXPDO32-bit digital output
0x6206Error Mode Output 8 BitUNSIGNED8RWOutput value in error mode
0x6207Error Value Output 8 BitUNSIGNED8RWOutput value on error

Digital output polarity​

IndexNameTypeAccessDescription
0x6300Output Polarity 8 BitUNSIGNED8RW8-bit output polarity

Analog I/O objects​

Analog inputs (AI)​

IndexNameTypeAccessDescription
0x6401Read Analog Input 16 BitINTEGER16RO/TXPDO16-bit analog input
0x6402Read Analog Input 32 BitINTEGER32RO/TXPDO32-bit analog input
0x6420Analog Input Full Scale RangeRECORDROAnalog input full-scale range

Analog outputs (AO)​

IndexNameTypeAccessDescription
0x6411Write Analog Output 16 BitINTEGER16RW/RXPDO16-bit analog output
0x6412Write Analog Output 32 BitINTEGER32RW/RXPDO32-bit analog output
0x6430Analog Output Full Scale RangeRECORDROAnalog output full-scale range
0x6440Analog Output Error ModeARRAYRWError 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