CANopen Master Documentation
Version 6.06.04
|
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.
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) |
enum ComSyncMode_e |
ComStatus_tv ComSyncEnable | ( | uint8_t | ubNetV, |
uint8_t | ubEnableV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ubEnableV | Enable/Disable SYNC producer |
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.
ComStatus_tv ComSyncGetCounter | ( | uint8_t | ubNetV, |
uint8_t * | pubCounterV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | pubCounterV | Pointer to SYNC counter value |
This function reads the counter value for the SYNC service.
ComStatus_tv ComSyncGetCycleTime | ( | uint8_t | ubNetV, |
uint32_t * | pulTimeV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | pulTimeV | Pointer to cycle time variable |
This function reads the cycle time for the SYNC service. The value is a multiple of 1 microsecond.
ComStatus_tv ComSyncGetId | ( | uint8_t | ubNetV, |
uint32_t * | pulIdV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | pulIdV | Pointer to identifier value variable |
This function reads the identifier value for the SYNC service.
ComStatus_tv ComSyncIsEnabled | ( | uint8_t | ubNetV, |
uint8_t * | pubEnableV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | pubEnableV | Pointer to Enable/Disable status variable |
This function checks if the SYNC service is enabled or disabled. The SYNC service is disabled by default.
ComStatus_tv ComSyncSend | ( | uint8_t | ubNetV, |
uint8_t | ubCounterV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ubCounterV | SYNC counter value |
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.
ComStatus_tv ComSyncSetCounter | ( | uint8_t | ubNetV, |
uint8_t | ubCounterV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ubCounterV | Highest counter value |
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.
ComStatus_tv ComSyncSetCycleTime | ( | uint8_t | ubNetV, |
uint32_t | ulTimeV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ulTimeV | cycle time |
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:
ComStatus_tv ComSyncSetId | ( | uint8_t | ubNetV, |
uint32_t | ulIdV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ulIdV | Identifier value |
This function changes the identifier value for the SYNC service. The SYNC service must be disabled (see ComSyncEnable()) prior to changing the identifier value.
ComStatus_tv ComSyncSetMode | ( | uint8_t | ubNetV, |
uint8_t | ubModeV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ubModeV | Service mode |
This function changes the mode (producer/consumer) for the SYNC service, possible values for the parameter ubModeV are defined by the enumeration ComSyncMode_e.