CANopen Master Documentation
Version 6.06.04
Loading...
Searching...
No Matches
Add-on Safety

The add-on module Safety allows the integration of the SRDO service as specified in EN 50525-5.

CANopen defines communication profiles based on ISO 11898-1. The basic profiles are defined in EN 50325-4. The SRCP (Safety-related communication profile and protocols, i.e. CANopen Safety) is based on the basic profiles in EN 50325-4 and the SCL (Safety Communication Layer, EN 61784–3) specification.

The SRCP is based on the producer/consumer model. The pairing of producers and consumers is an important part of the relationship that provides the high integrity needed for SRLD (Safety-related logical device). The SCL is specified using SR (Safety-related) data objects (SRDOs). These objects are serving as the interface between the SR application objects and the link layer connections. An SRDO ensures the integrity of the safety data transfers.

Module version

The module version is defined by COM_SAFETY_VERSION_MAJOR and COM_SAFETY_VERSION_MINOR.

Configuration

The module is configured by setting of the following symbols inside the com_conf.h file:

COM_SRDO_NUMBER

number of supported SRDOs

COM_SRDO_TRM_FIFO_SIZE

FIFO size for transmission of SRDOs

Interface to application

Use the header file com_safety.h to get access to the Add-on Safety API.

#include "com_safety.h"
CANopen Master Functional Safety .

Configuration Example

In order to configure the objects of a SR device the following commands have to be executed:

  • Initialize a SRDO data structure
  • Read the actual SRDO data structure of the SR device
  • Modify SRDO data structure (optional)
  • Write modified SRDO data structure to SR device (optional)
  • Calculate the CRC signature of the SRDO data structure
  • Write CRC signature to SR device
  • Write configuration valid to SR device

Please note that all these steps have to be executed in Pre-Operational state of the SR device. All functions which access the object dictionary of the SR device via SDO (e.g. ComSafetyGetConfiguration(), etc.) are non-blocking, hence the application has to wait until the SDO data transfer has finished before the next command can be executed. This can be achieved either by implementation of an application specific FSA using the ComObjectEventReady() event or by polling the status value of ComSafetyGetSdoStatus().

The following code example depicts the configuration procedure.

static ComSrdo_ts tsSrdoS; // SRDO data structure
uint16_t uwSignatureT; // SRDO CRC signature
enum ComSdoStat_e teStatusT; // SDO communication status
//-----------------------------------------------------------------------------
// Initialize the SRDO data structure:
// SR device has node-ID 3, setup SRDO number 1
//
ComSafetySrdoInit(eCOM_NET_1, 3, 1, &tsSrdoS);
//-----------------------------------------------------------------------------
// Read the actual SRDO data structure:
// SR device has node-ID 3, setup SRDO number 1
//
//-----------------------------------------------------------------------------
// Wait until the SDO data transfer is completed
//
do {
ComSafetyGetSdoStatus(eCOM_NET_1, 3, 1, &teStatusT);
} while (teStatusT < eCOM_SDO_STAT_SUCCESS);
//-----------------------------------------------------------------------------
// Now the SRDO data structure 'tsSrdoS' holds the data of
// the SR device: Calculate the CRC signature of SRDO
//
uwSignatureT = ComSafetyGetCrcValue(&tsSrdoS);
//-----------------------------------------------------------------------------
// Write CRC signature to SR device
//
ComSafetySetSignature(eCOM_NET_1, 3, 1, uwSignatureT);
//-----------------------------------------------------------------------------
// Wait until the SDO data transfer is completed
//
do {
ComSafetyGetSdoStatus(eCOM_NET_1, 3, 1, &teStatusT);
} while (teStatusT < eCOM_SDO_STAT_SUCCESS);
//-----------------------------------------------------------------------------
// Write configuration valid to SR device
//
//-----------------------------------------------------------------------------
// Wait until the SDO data transfer is completed
//
do {
ComSafetyGetSdoStatus(eCOM_NET_1, 3, 1, &teStatusT);
} while (teStatusT < eCOM_SDO_STAT_SUCCESS);
@ eCOM_NET_1
Definition com_defs.h:723
uint16_t ComSafetyGetCrcValue(ComSrdo_ts *ptsSrdoV)
ComStatus_tv ComSafetySetConfigurationValid(uint8_t ubNetV, uint8_t ubNodeIdV)
ComStatus_tv ComSafetySetSignature(uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubSrdoNumberV, uint16_t uwSignatureV)
ComStatus_tv ComSafetyGetConfiguration(uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubSrdoNumberV)
ComStatus_tv ComSafetySrdoInit(uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubSrdoNumberV, ComSrdo_ts *ptsSrdoV)
ComStatus_tv ComSafetyGetSdoStatus(uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubSrdoNumberV, enum ComSdoStat_e *pteStatusV)
ComSdoStat_e
SDO transfer status.
Definition com_sdo_cln.h:77
@ eCOM_SDO_STAT_SUCCESS
Definition com_sdo_cln.h:100
SRDO structure.
Definition com_safety.h:189

CANopen Safety files

com_safety.h

CANopen Safety add-on module