I want to find...

Search

Shares

Table of Content

EthercatDevice.setDc()

[Ethercat Device]

Description

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.
dc_structure

Syntax

int setDc(uint32_t cycletime0_ns, int32_t shifttime_ns = 0, uint32_t cycletime1_ns = 0);

Parameters

  • [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 Value

Return an error code. If the returned value is zero, it indicates a successful execution of this function.

Comment

The function must be called after EthercatMaster::begin() and before EthercatMaster::start(). This function is blocking and cannot be called within the Cyclic Callback.

Example

#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.

Leave a Comment

Scroll to Top