7.1 KiB
Configuration over EtherCAT (CoE)
Each EtherCAT has a key-value store that is accessible via SDA register reads and writes.
A value can be a primitive type like bool, u8, and so on, or an array of values.
Not all indices are writable; some are read-only.
Many indices have the same meaning across different EtherCAT devices, but some are specific to the device. Documentation about the indices can be found in the datasheet.
Important indices we need to write are:
0x1C12RxPdo assignment0x1C13TxPdo assignment0x80..Device-specific configuration.
Other notable indices are:
0x1A..TxPdo objects (read-only, referenced in the TxPdo assignment)0x16..RxPdo objects (read-only, referenced in the RxPdo assignment)
The configuration is not persistent and will be lost if the device is powered off. We need to write it every time we start the application. This is very beneficial because we know that it's always using the default configuration unless we explicitly change it.
How to Create a New Device Configuration
Config Values
Take a look into the datasheet of a device and find a table of the 0x80.. indices.
Take a look at each value and implement the whole configuration. Copy the description of each value as well as the default value to the documentation. Also, implement the Default trait for the configuration struct using the default values from the datasheet.
/// 0x8000 CoE
#[derive(Debug, Clone)]
pub struct EL2521Configuration {
/// # 0x8010:02
/// - `true` = If the watchdog timer responds, the terminal ramps with the time constant set in object 8001:08
/// - `false` = The function is deactivated
///
/// default: `false`
pub emergency_ramp_active: bool,
/// # 0x8010:03
/// - `true` = The watchdog timer is deactivated
///
/// The watchdog timer is activated in the delivery state.
/// Either the manufacturer's or the user's switch-on value
/// is output if the watchdog overflows
///
/// default: `false`
pub watchdog_timer_deactive: bool,
// ...
}
Sometimes a device has multiple channels/pins/ports that all have the same configuration values. Abstract here.
For example, the EL2522 is the 2-channel variant of the EL2521.
#[deri