CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_emcy.h File Reference

Detailed Description

Emergency objects are triggered by the occurrence of a device internal error situation and are transmitted from an emergency producer on the device. Emergency objects are suitable for interrupt type error alerts. An emergency object is transmitted only once per error event. As long as no new errors occur on a device no further emergency objects must be transmitted. The emergency object may be received by zero or more emergency consumers. The reaction on the emergency consumer(s) is not specified (see CiA 301).

EMCY error codes for possible error conditions of the CANopen device are registered inside the EMCY error state machine by means of the CosEmcyErrorRegister() function. Once a error condition is registered, it can be set by CosEmcyErrorSet() and cleared by CosEmcyErrorClr(). Setting and clearing the individual registered error conditions will trigger the transmission of the EMCY object service as well as altering the value of the error register (index 1001h). It is possible to clear all registered error conditions by calling CosEmcyErrorReset().

Registered error conditions

The following error conditions are already registered by the the protocol stack during initialization:

Error Condition Assigned EMCY code Set by stack Cleared by stack
eEMCY_301_COMMUNICATION EMCY_ERR_COMMUNICATION Yes Yes
eEMCY_301_CAN_ERROR_PASSIVE EMCY_ERR_CAN_ERROR_PASSIVE Yes Yes
eEMCY_301_CAN_OVERRUN EMCY_ERR_CAN_OVERRUN Yes No
eEMCY_301_CAN_BUSOFF_RECOVER EMCY_ERR_CAN_BUSOFF_RECOVER Yes Yes
eEMCY_301_CAN_TX_COB_COLLISION EMCY_ERR_CAN_TX_COB_COLLISION Yes No
eEMCY_301_CAN_LIFEGUARD EMCY_ERR_CAN_LIFEGUARD Yes No
eEMCY_301_MAINS_VOLTAGE EMCY_ERR_VOLT_GENERAL No No
eEMCY_301_DEVICE_TEMPERATURE EMCY_ERR_TEMP_DEVICE No No
eEMCY_301_SYNC_LENGTH EMCY_ERR_PROTOCOL_SYNC_LENGTH Yes No
eEMCY_301_PROTOCOL_PDO EMCY_ERR_PROTOCOL_PDO Yes No

Adding application specific EMCY codes

Application specific error conditions can be added inside the file cos_emcy_user.h

enum CosEmcyUser_e
{
#if COS_PROFILE_NUMBER == 0
eEMCY_USER_START = eEMCY_301_MAX,
#else
eEMCY_USER_START = eEMCY_PROFILE_MAX,
#endif
//----------------------------------------------------------------
// Add your user specific error conditions here
//
eEMCY_USER_EXAMPLE_1,
//----------------------------------------------------------------
// Do not remove this symbol, it defines the last entry
//
eEMCY_USER_MAX
};
@ eEMCY_301_MAX
Definition cos_emcy.h:401

The registration of application specific error conditions can be done inside the CosMgrOnStart() function.

+ Include dependency graph for cos_emcy.h:

Macros

#define EMCY_ERR_NONE   ((uint16_t) 0x0000)
 
#define EMCY_ERR_GENERIC   ((uint16_t) 0x1000)
 
#define EMCY_ERR_VOLT_GENERAL   ((uint16_t) 0x3000)
 
#define EMCY_ERR_TEMP_GENERAL   ((uint16_t) 0x4000)
 
#define EMCY_ERR_TEMP_DEVICE   ((uint16_t) 0x4200)
 
#define EMCY_ERR_HW_GENERIC   ((uint16_t) 0x5000)
 
#define EMCY_ERR_SW_GENERIC   ((uint16_t) 0x6000)
 
#define EMCY_ERR_MONITORING   ((uint16_t) 0x8000)
 
#define EMCY_ERR_COMMUNICATION   ((uint16_t) 0x8100)
 
#define EMCY_ERR_CAN_OVERRUN   ((uint16_t) 0x8110)
 
#define EMCY_ERR_CAN_ERROR_PASSIVE   ((uint16_t) 0x8120)
 
#define EMCY_ERR_CAN_LIFEGUARD   ((uint16_t) 0x8130)
 
#define EMCY_ERR_CAN_BUSOFF_RECOVER   ((uint16_t) 0x8140)
 
#define EMCY_ERR_CAN_TX_COB_COLLISION   ((uint16_t) 0x8150)
 
#define EMCY_ERR_NRL_PASSIVE_USE_DCL   ((uint16_t) 0x8180)
 
#define EMCY_ERR_NRL_PASSIVE_USE_RCL   ((uint16_t) 0x8181)
 
#define EMCY_ERR_PROTOCOL   ((uint16_t) 0x8200)
 
#define EMCY_ERR_PROTOCOL_PDO   ((uint16_t) 0x8210)
 
#define EMCY_ERR_PROTOCOL_PDO_EXCEED   ((uint16_t) 0x8220)
 
#define EMCY_ERR_PROTOCOL_PDO_MPDO   ((uint16_t) 0x8230)
 
#define EMCY_ERR_PROTOCOL_SYNC_LENGTH   ((uint16_t) 0x8240)
 
#define EMCY_ERR_PROTOCOL_RPDO   ((uint16_t) 0x8250)
 
#define EMCY_ERR_DEV_GENERAL   ((uint16_t) 0xFF00)
 

Enumerations

enum  CosEmcy301_e {
}
 
enum  CosEmcy_e { eEMCY_COS_MAX = eEMCY_301_MAX }
 

Functions

Status_tv CosEmcyErrorClr (uint8_t ubErrConditionV)
 
Status_tv CosEmcyErrorRegister (uint8_t ubErrConditionV, uint16_t uwErrCodeV, uint8_t ubErrRegisterV, uint8_t ubErrCompareV)
 
void CosEmcyErrorReset (void)
 
Status_tv CosEmcyErrorSet (uint8_t ubErrConditionV, uint8_t *pubCustomerCodeV)
 
void CosEmcySend (uint16_t uwEmcyCodeV, uint8_t *pubCustomerCodeV)
 

Enumeration Type Documentation

◆ CosEmcy301_e

EMCY error index.

The following enumeration values correspond to an EMCY error index used the the error state machine. The value is used by the function CosEmcyErrorRegister():

Enumerator
eEMCY_301_COMMUNICATION 

Generic communication error

eEMCY_301_CAN_ERROR_PASSIVE 

CAN in error passive

eEMCY_301_CAN_OVERRUN 

CAN overrun

eEMCY_301_CAN_BUSOFF_RECOVER 

CAN recovered from bus-off condition

eEMCY_301_CAN_TX_COB_COLLISION 

CAN identifier collision

eEMCY_301_CAN_LIFEGUARD 

CAN heartbeat error

eEMCY_301_MAINS_VOLTAGE 

Supply voltage error

eEMCY_301_DEVICE_TEMPERATURE 

Temperature error

eEMCY_301_SYNC_LENGTH 

Length of SYNC

eEMCY_301_PROTOCOL_PDO 

PDO Protocol

eEMCY_301_MAX 

Last entry

◆ CosEmcy_e

enum CosEmcy_e

EMCY error index.

The following enumeration calculates the highest supported error condition used the the error state machine. The value is used by the function CosEmcyErrorRegister().

Enumerator
eEMCY_COS_MAX 

Maximum number of supported error conditions in EMCY state machine

Function Documentation

◆ CosEmcyErrorClr()

Status_tv CosEmcyErrorClr ( uint8_t  ubErrConditionV)
Parameters
[in]ubErrConditionVError condition, defined by CosEmcy_e
Returns
eCOS_ERR_NONE in case of success or a code defined CosErr_e on error.
See also
CosEmcyErrorSet()

The function clears an error condition defined by ubErrConditionV from pending state. An EMCY reset message will be transmitted via CAN bus. If other errors are still pending, then the corresponding EMCY messages will be send afterwards.

◆ CosEmcyErrorRegister()

Status_tv CosEmcyErrorRegister ( uint8_t  ubErrConditionV,
uint16_t  uwErrCodeV,
uint8_t  ubErrRegisterV,
uint8_t  ubErrCompareV 
)
Parameters
[in]ubErrConditionVError condition, defined by CosEmcy_e
[in]uwErrCodeVCorresponding Emergency Error Code
[in]ubErrRegisterVCorresponding bit in error register (object 1001h)
[in]ubErrCompareVCompare manufacturer specific error data
Returns
eCOS_ERR_NONE in case of success or a code defined CosErr_e on error.

This function registers an error condition defined by ubErrConditionV to the EMCY error state machine. Only registered error conditions can be handled by CosEmcyErrorSet() and CosEmcyErrorClr(). If ubErrCompareV is to 1, the function CosEmcyErrorSet() will compare manufacturer specific error data with previously set data. In case of a difference a EMCY message is sent, otherwise the transmission is omitted.

◆ CosEmcyErrorReset()

void CosEmcyErrorReset ( void  )

The function resets all errors inside the Emergency state machine. If errors are present, an EMCY reset message (EMCY_ERR_NONE) is sent on the bus.

◆ CosEmcyErrorSet()

Status_tv CosEmcyErrorSet ( uint8_t  ubErrConditionV,
uint8_t *  pubCustomerCodeV 
)
Parameters
[in]ubErrConditionVError condition, defined by CosEmcy_e
[in]pubCustomerCodeVPointer to manufacturer specific error data
Returns
eCOS_ERR_NONE in case of success or a code defined CosErr_e on error.
See also
CosEmcyErrorClr()

The functions sets an error condition defined by ubErrConditionV to pending state. If the error was not in pending state, an EMCY message with the corresponding code is sent on the bus.

◆ CosEmcySend()

void CosEmcySend ( uint16_t  uwEmcyCodeV,
uint8_t *  pubCustomerCodeV 
)
Parameters
[in]uwEmcyCodeVEmergency Error Code
[in]pubCustomerCodeVCustomer specific code

This function is called internally by the EMCY error state machine. It is not recommended to call this function directly by the application program.

The parameter uwEmcyCodeV defines the EMCY error code. The pointer pubCustomerCodeV refers to an array of 5 byte which contains customer specific information. The pointer pubCustomerCodeV can be 0L.