libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
|
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 |
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. | |
ethercat distributed clocks support.
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.
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.
[in] | pec | Pointer to EtherCAT master structure. |
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.
[in] | pec | Pointer to EtherCAT master structure. |
[in] | slave | Slave number. |
[in] | dc_active | Dc active flag. |
[in] | cycle_time_0 | Cycle time to program to fire sync0 in [ns]. |
[in] | cycle_time_1 | Cycle time to program to fire sync1 in [ns]. |
[in] | cycle_shift | Shift of first sync0 start in [ns]. |