libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
dc.h File Reference

ethercat distributed clocks support. More...

#include <libosal/types.h>
#include <libosal/mutex.h>
#include "libethercat/common.h"
#include "libethercat/idx.h"
#include "libethercat/pool.h"
#include "libethercat/datagram.h"

Go to the source code of this file.

Data Structures

struct  ec_dc_info_slave
 
struct  ec_dc_info
 

Macros

#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_ACTIVATION   ( 0x01u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_SYNC0   ( 0x02u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_SYNC1   ( 0x04u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_AUTO_ACTIVATION   ( 0x08u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_EXT_64BIT   ( 0x10u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_START_TIME_CHECK   ( 0x20u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_NEAR_FUTURE_CONFIG   ( 0x40u )
 
#define EC_REG_DCSYNCACT__SYNC_OUT_UNIT_DEBUG_PULSE   ( 0x80u )
 
#define EC_DC_ACTIVATION_REG_SYNC0   ( 0x3 )
 
#define EC_DC_ACTIVATION_REG_SYNC1   ( 0x5 )
 
#define EC_DC_ACTIVATION_REG_SYNC01   ( 0x7 )
 

Typedefs

typedef struct ec_dc_info_slave ec_dc_info_slave_t
 
typedef enum ec_dc_mode ec_dc_mode_t
 
typedef struct ec_dc_info ec_dc_info_t
 

Enumerations

enum  ec_dc_mode { dc_mode_master_clock = 0 , dc_mode_ref_clock , dc_mode_master_as_ref_clock }
 

Functions

int ec_dc_config (struct ec *pec)
 Prepare EtherCAT master and slaves for distributed clocks.
 
void ec_dc_sync (struct ec *pec, osal_uint16_t slave, osal_uint8_t dc_active, osal_uint32_t cycle_time_0, osal_uint32_t cycle_time_1, osal_int32_t cycle_shift)
 Configure EtherCAT slave for distributed clock sync0 and sync1 pulse.
 

Detailed Description

ethercat distributed clocks support.

Author
Robert Burger <robert.burger\dlr.de>
Date
11 Nov 2016

These functions are used to enable distributed clocks support on the EtherCAT master and to configure one ore more EtherCAT slaves to enable the sync0 and/or sync1 pulse generation.

Function Documentation

◆ ec_dc_config()

int ec_dc_config ( struct ec pec)

Prepare EtherCAT master and slaves for distributed clocks.

Check all slaves if they support distributed clocks and measure delays.

DC support can be determined from EtherCAT slave's feature register (0x08). which is automatically read on EtherCAT master's INIT phase. On all slaves supporting DC's the system time is read and written to the system time offset to set slave time to 0. afterwards the port times are taken and the propagation delays are calculated and written.

This function does not enable distributed clock sync0/1 pulse generation on the slaves. this has to be done with ec_dc_sync0 or ec_dc_sync01.

Parameters
[in]pecPointer to EtherCAT master structure.
Returns
supported dc

◆ ec_dc_sync()

void ec_dc_sync ( struct ec pec,
osal_uint16_t  slave,
osal_uint8_t  dc_active,
osal_uint32_t  cycle_time_0,
osal_uint32_t  cycle_time_1,
osal_int32_t  cycle_shift 
)

Configure EtherCAT slave for distributed clock sync0 and sync1 pulse.

This function writes the cycle time, calculates the DC first start time wrt the cycle shift and enables sync0 and sync1 pulse generation on the corresponding device. It can also be use to disable DC's on the EtherCAT slave.

Parameters
[in]pecPointer to EtherCAT master structure.
[in]slaveSlave number.
[in]dc_activeDc active flag.
[in]cycle_time_0Cycle time to program to fire sync0 in [ns].
[in]cycle_time_1Cycle time to program to fire sync1 in [ns].
[in]cycle_shiftShift of first sync0 start in [ns].