CANopen FD Master Library
Making your systems precise, reliable and high-quality - 5.10.01
Functions
SYNC Service

Functions

ComStatus_tv ComSyncEnable (uint8_t ubNetV, uint8_t ubEnableV)
 
ComStatus_tv ComSyncGetCounter (uint8_t ubNetV, uint8_t *pubCounterV)
 
ComStatus_tv ComSyncGetId (uint8_t ubNetV, uint32_t *pulIdV)
 
ComStatus_tv ComSyncSetId (uint8_t ubNetV, uint32_t ulIdV)
 
ComStatus_tv ComSyncSetCycleTime (uint8_t ubNetV, uint32_t ulTimeV)
 

Detailed Description

The Synchronisation (SYNC) Object is broadcasted periodically by the SYNC producer. This SYNC provides the basic network clock. The time period between the SYNCs is specified by the standard parameter communication cycle period (Object 1006h: Communication Cycle Period), which may be written by a configuration tool to the application devices during the boot-up process. There can be a time jitter in transmission by the SYNC producer corresponding approximately to the latency due to some other message being transmitted just before the SYNC. In order to guarantee timely access to the CAN bus the SYNC is given a very high priority identifier (1005h).

Devices which operate synchronously may use the SYNC object to synchronise their own timing with that of the Synchronisation Object producer. The details of this synchronisation are device dependent.

The generation of SYNC messages is disabled by default. The SYNC service identifier is set to 080h by default. The following code example shows how to change the default identifier to 181h and to generate SYNC messages with a cycle time of 10ms.

ComSyncSetId(eCOM_NET_1, 0x181); // set new identifier
ComSyncSetCycleTime(eCOM_NET_1, 10000); // set 10 ms cycle time
ComSyncEnable(eCOM_NET_1, 1); // start SYNC service

Function Documentation

◆ ComSyncEnable()

ComStatus_tv ComSyncEnable ( uint8_t  ubNetV,
uint8_t  ubEnableV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]ubEnableV- Enable/Disable SYNC service
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function enables (ubEnableV = 1) or disables (ubEnableV = 0) the SYNC service. The SYNC service is disabled by default.

◆ ComSyncGetCounter()

ComStatus_tv ComSyncGetCounter ( uint8_t  ubNetV,
uint8_t *  pubCounterV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]pubCounterV- Pointer to SYNC counter value
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function reads the counter value for the SYNC service.

◆ ComSyncGetId()

ComStatus_tv ComSyncGetId ( uint8_t  ubNetV,
uint32_t *  pulIdV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]pulIdV- Pointer to identifier value
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure
See also
ComSyncSetId()

This function reads the identifier value for the SYNC service.

◆ ComSyncSetCycleTime()

ComStatus_tv ComSyncSetCycleTime ( uint8_t  ubNetV,
uint32_t  ulTimeV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]ulTimeV- cycle time
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function changes the cycle time for the SYNC service. The parameter ulTimeV is passed as multiple of 1 microsecond.

Here is an example for setting the SYNC cycle time:

◆ ComSyncSetId()

ComStatus_tv ComSyncSetId ( uint8_t  ubNetV,
uint32_t  ulIdV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]ulIdV- Identifier value
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function changes the identifier value for the SYNC service. The SYNC service must be disabled (see ComSyncEnable()) prior to changing the identifier.