[EtherCAT Device CiA402]
Description
Initialize the object of this EtherCAT SubDevice class and attach it to the object of EthercatMaster class based on the ID of the SubDevice on the network.
Syntax
int attach(uint16_t slave_id, EthercatMaster *master, EthercatAttachMode mode = ECAT_SLAVE_NO);
int attach(uint16_t slave_id, EthercatMaster &master, EthercatAttachMode mode = ECAT_SLAVE_NO);
int attach(uint16_t slave_id, uint8_t drive_id, EthercatMaster *master, EthercatAttachMode mode = ECAT_SLAVE_NO);
int attach(uint16_t slave_id, uint8_t drive_id, EthercatMaster &master, EthercatAttachMode mode = ECAT_SLAVE_NO);
Parameters
[in] slave_id
The ID of the SubDevice on the EtherCAT bus. The definition of this ID is determined based on the mode parameter.[in] drive_id
The ID of CiA 402 drive in the EtherCAT SubDevice. Typically used when a single EtherCAT SubDevice has multiple CiA 402 drive axes.[in] master
The object of EthercatMaster class to which it should be attached.[in] mode
The definition of slave_id :- ECAT_SLAVE_NO
The sequence number of the EtherCAT SubDevice on the network, 0 indicates the first SubDevice, 1 indicates the second SubDevice, and so on. - ECAT_ALIAS_ADDRESS
The alias address of the SubDevice on the network, which is defined at byte offset 8 in the SII EEPROM of the SubDevice.
- ECAT_SLAVE_NO
Return Value
Return an error code. If the returned value is zero, it indicates a successful execution of this function.
Comment
This function must be called after a successful execution of EthercatMaster::begin().
WARNING: Prohibited from being called in the callback functions.
Example Code
Single-axis CiA 402 EtherCAT Servo Drive
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_CiA402 motor;
void setup() {
master.begin();
motor.attach(0, master);
}
void loop() {
// put your main code here, to run repeatedly:
}Multi-axis CiA 402 EtherCAT Servo Drive
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_CiA402 motor1;
EthercatDevice_CiA402 motor2;
EthercatDevice_CiA402 motor3;
void setup() {
master.begin();
motor1.attach(0, 0, master);
motor2.attach(0, 1, master);
motor3.attach(0, 2, master);
}
void loop() {
// put your main code here, to run repeatedly:
}Please see the EtherCAT CiA 402 User Manual for more QEC EtherCAT instructions and API usage.