CANopen Master Documentation
Version 6.06.04
Loading...
Searching...
No Matches
com_sync.h File Reference

Detailed Description

The Synchronization (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 (see object 1005h).

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

The generation of SYNC frames 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
@ eCOM_NET_1
Definition com_defs.h:723
ComStatus_tv ComSyncSetCycleTime(uint8_t ubNetV, uint32_t ulTimeV)
ComStatus_tv ComSyncSetId(uint8_t ubNetV, uint32_t ulIdV)
ComStatus_tv ComSyncEnable(uint8_t ubNetV, uint8_t ubEnableV)
+ Include dependency graph for com_sync.h:

Enumerations

enum  ComSyncMode_e {
  eCOM_SYNC_MODE_CONSUMER = 0 ,
  eCOM_SYNC_MODE_PRODUCER = 1 ,
  eCOM_SYNC_MODE_DISABLE = 2
}
 

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 ComSyncGetCycleTime (uint8_t ubNetV, uint32_t *pulTimeV)
 
ComStatus_tv ComSyncIsEnabled (uint8_t ubNetV, uint8_t *pubEnableV)
 
ComStatus_tv ComSyncSend (uint8_t ubNetV, uint8_t ubCounterV)
 
ComStatus_tv ComSyncSetCounter (uint8_t ubNetV, uint8_t ubCounterV)
 
ComStatus_tv ComSyncSetCycleTime (uint8_t ubNetV, uint32_t ulTimeV)
 
ComStatus_tv ComSyncSetId (uint8_t ubNetV, uint32_t ulIdV)
 
ComStatus_tv ComSyncSetMode (uint8_t ubNetV, uint8_t ubModeV)
 

Enumeration Type Documentation

◆ ComSyncMode_e

The enumeration defines the values for setting the SYNC service mode to either producer or consumer.

Enumerator
eCOM_SYNC_MODE_CONSUMER 

Consume SYNC service

eCOM_SYNC_MODE_PRODUCER 

Produce SYNC service

eCOM_SYNC_MODE_DISABLE 

Disable SYNC service

Function Documentation

◆ ComSyncEnable()

ComStatus_tv ComSyncEnable ( uint8_t  ubNetV,
uint8_t  ubEnableV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ubEnableVEnable/Disable SYNC producer
Returns
Value of enumeration ComErr_e
See also
ComSyncSetId()

This function enables (ubEnableV = 1) or disables (ubEnableV = 0) generation of SYNC frames. The generation of SYNC frames (i.e. SYNC producer) is disabled by default.

◆ ComSyncGetCounter()

ComStatus_tv ComSyncGetCounter ( uint8_t  ubNetV,
uint8_t *  pubCounterV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]pubCounterVPointer to SYNC counter value
Returns
Value of enumeration ComErr_e

This function reads the counter value for the SYNC service.

◆ ComSyncGetCycleTime()

ComStatus_tv ComSyncGetCycleTime ( uint8_t  ubNetV,
uint32_t *  pulTimeV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]pulTimeVPointer to cycle time variable
Returns
Value of enumeration ComErr_e
See also
ComSyncSetCycleTime()

This function reads the cycle time for the SYNC service. The value is a multiple of 1 microsecond.

◆ ComSyncGetId()

ComStatus_tv ComSyncGetId ( uint8_t  ubNetV,
uint32_t *  pulIdV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]pulIdVPointer to identifier value variable
Returns
Value of enumeration ComErr_e
See also
ComSyncSetId()

This function reads the identifier value for the SYNC service.

◆ ComSyncIsEnabled()

ComStatus_tv ComSyncIsEnabled ( uint8_t  ubNetV,
uint8_t *  pubEnableV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]pubEnableVPointer to Enable/Disable status variable
Returns
Value of enumeration ComErr_e
See also
ComSyncEnable()

This function checks if the SYNC service is enabled or disabled. The SYNC service is disabled by default.

◆ ComSyncSend()

ComStatus_tv ComSyncSend ( uint8_t  ubNetV,
uint8_t  ubCounterV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ubCounterVSYNC counter value
Returns
Value of enumeration ComErr_e

This function triggers the SYNC transmission controlled by the application. The function is only available if the symbol COM_SYNC_SUPPORT is set to a value of 2, otherwise it will will return eCOM_ERR_SERVICE_MODE.

◆ ComSyncSetCounter()

ComStatus_tv ComSyncSetCounter ( uint8_t  ubNetV,
uint8_t  ubCounterV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ubCounterVHighest counter value
Returns
Value of enumeration ComErr_e

This function changes the counter value for the SYNC service. Valid values for ubCounterV are 0 and 2 to 240. A value of 0 sets the DLC of the SYNC service to 0 (default).

The following example shows how the set the counter to a maximum (overflow) value of 10. Please note that the SYNC counter value always starts with 1.

ComSyncSetCounter(eCOM_NET_1, 10); // set SYNC counter max value to 10
ComSyncSetCycleTime(eCOM_NET_1, 10000); // start SYNC with 10 ms cycle time
ComStatus_tv ComSyncSetCounter(uint8_t ubNetV, uint8_t ubCounterV)

◆ ComSyncSetCycleTime()

ComStatus_tv ComSyncSetCycleTime ( uint8_t  ubNetV,
uint32_t  ulTimeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ulTimeVcycle time
Returns
Value of enumeration ComErr_e

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]ubNetVCANopen Network channel
[in]ulIdVIdentifier value
Returns
Value of enumeration ComErr_e

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

◆ ComSyncSetMode()

ComStatus_tv ComSyncSetMode ( uint8_t  ubNetV,
uint8_t  ubModeV 
)
Parameters
[in]ubNetVCANopen Network channel
[in]ubModeVService mode
Returns
Value of enumeration ComErr_e

This function changes the mode (producer/consumer) for the SYNC service, possible values for the parameter ubModeV are defined by the enumeration ComSyncMode_e.

ComStatus_tv ComSyncSetMode(uint8_t ubNetV, uint8_t ubModeV)
@ eCOM_SYNC_MODE_PRODUCER
Definition com_sync.h:95