[Ethercat Device]
描述
Configure DC parameters of the EtherCAT slave device. This function has three DC parameters to configure:
- DC Cycle Time 0 is used to set the cycle time for the SYNC0 signal, typically aligned with the EtherCAT communication cycle time.
- DC Cycle Time 1 is used to set the cycle time for the SYNC1 signal, which refers to the delay defined after the SYNC0 pulse. This parameter is optional.
- DC Shift Time is used to set the offset of the SYNC0 signal relative to the DC Base.

語法
int setDc(uint32_t cycletime0_ns, int32_t shifttime_ns = 0, uint32_t cycletime1_ns = 0);
參數
[in] uint32_t cycletime0_ns
DC SYNC0 cycle time in nanoseconds.[in] int32_t shifttime_ns
DC SYNC0 shift time in nanoseconds.[in] uint32_t cycletime1_ns
DC SYNC1 cycle time in nanoseconds.
回傳值
Return an error code. If the returned value is zero, it indicates a successful execution of this function.
備註
The function must be called after EthercatMaster::begin() and before EthercatMaster::start(). This function is blocking and cannot be called within the Cyclic Callback.
範例
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_Generic slave;
void setup() {
master.begin();
slave.attach(0, master);
slave.setDc(1000000);
master.start(1000000);
}
void loop() {
// put your main code here, to run repeatedly:
}Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.