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

Detailed Description

Emergency (EMCY) 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.

EMCY consumer

The EMCY consumer functionality can be activated or deactivated via the preprocessor symbol COM_EMCY_CONS_SUPPORT. The EMCY consumer functionality is activated by default. Reception of an EMCY message is enabled via the function ComEmcyConsEnable() based on the node-ID of the EMCY producer. As default, no EMCY messages are received.

//-------------------------------------------------------------------------------
// enable reception of EMCY messages from devices with node-ID 1 and 3
//
@ eCOM_NET_1
Definition com_defs.h:723
ComStatus_tv ComEmcyConsEnable(uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubEnableV)

Upon reception of an enabled EMCY message the function ComEmcyConsEventReceive() is called., which only informs about the node-ID of the EMCY producer.

EMCY messages can be stored in a queue, the queue is disabled by default. The function ComEmcyConsQueueEnable() is used to enable a queue for EMCY messages. By means of the function ComEmcyConsQueueCount() the number of messages stored inside the queue can be retrieved. EMCY messages can be fetched from the queue by calling ComEmcyConsQueueFetch(). The following example shows how to read the EMCY queue inside the ComEmcyConsEventReceive() handler.

void ComEmcyConsEventReceive(uint8_t ubNetV, uint8_t ubNodeIdV)
{
uint16_t uwEmcyConsCountT = 0;
CpCanMsg_ts tsEmcyMessageT;
//---------------------------------------------------------------------------------------------------
// This handler is called upon reception of an EMCY. In this example we read EMCY messages from the
// receive queue until the queue is empty. In this example we do not care for the node-ID of the
// producer.
//
(void) ubNodeIdV;
ComEmcyConsQueueCount(ubNetV, &uwEmcyConsCountT);
while (uwEmcyConsCountT > 0)
{
//-------------------------------------------------------------------------------------------
// Clear CAN frame structure, the frame format does not matter here
//
CpMsgInit(&tsEmcyMessageT, CP_MSG_FORMAT_CBFF);
ComEmcyConsQueueFetch(ubNetV, &tsEmcyMessageT);
uwEmcyConsCountT--;
//-------------------------------------------------------------------------------------------
// Do something with the EMCY using the identifier of 082h.
//
if (CpMsgGetIdentifier(&tsEmcyMessageT) == 0x082)
{
}
}
}
ComStatus_tv ComEmcyConsQueueCount(uint8_t ubNetV, uint16_t *puwCountV)
ComStatus_tv ComEmcyConsQueueFetch(uint8_t ubNetV, CpCanMsg_ts *ptsCanMsgV)
void ComEmcyConsEventReceive(uint8_t ubNetV, uint8_t ubNodeIdV)
void CpMsgInit(CpCanMsg_ts *ptsCanMsgV, uint8_t ubFormatV)
Initialise message structure.
uint32_t CpMsgGetIdentifier(const CpCanMsg_ts *ptsCanMsgV)
Get Identifier Value.
#define CP_MSG_FORMAT_CBFF
Definition canpie.h:415
CAN message structure.
Definition canpie.h:1005
+ Include dependency graph for com_emcy.h:

Macros

#define EMCY_ERR_NONE   0x0000
 
#define EMCY_ERR_GENERIC   0x1000
 
#define EMCY_ERR_CURR_GENERIC   0x2000
 
#define EMCY_ERR_CURR_INPUT   0x2100
 
#define EMCY_ERR_CURR_DEVICE   0x2200
 
#define EMCY_ERR_CURR_OUTPUT   0x2300
 
#define EMCY_ERR_VOLT_GENERIC   0x3000
 
#define EMCY_ERR_VOLT_INPUT   0x3100
 
#define EMCY_ERR_VOLT_DEVICE   0x3200
 
#define EMCY_ERR_VOLT_OUTPUT   0x3300
 
#define EMCY_ERR_TEMP_GENERIC   0x4000
 
#define EMCY_ERR_TEMP_AMBIENT   0x4100
 
#define EMCY_ERR_TEMP_DEVICE   0x4200
 
#define EMCY_ERR_HW_GENERAL   0x5000
 
#define EMCY_ERR_MONITORING   0x8000
 
#define EMCY_ERR_COMMUNICATION   0x8100
 
#define EMCY_ERR_CAN_OVERRUN   0x8110
 
#define EMCY_ERR_CAN_ERROR_PASSIVE   0x8120
 
#define EMCY_ERR_CAN_LIFEGUARD   0x8130
 
#define EMCY_ERR_CAN_BUSOFF_RECOVER   0x8140
 
#define EMCY_ERR_CAN_TX_COB_COLLISION   0x8150
 
#define EMCY_ERR_PROTOCOL   0x8200
 
#define EMCY_ERR_PROTOCOL_PDO   0x8210
 
#define EMCY_ERR_PROTOCOL_PDO_EXCEED   0x8210
 
#define EMCY_ERR_DEV_GENERAL   0xFF00
 

Functions

ComStatus_tv ComEmcyConsEnable (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubEnableV)
 
void ComEmcyConsEventReceive (uint8_t ubNetV, uint8_t ubNodeIdV)
 
ComStatus_tv ComEmcyConsGetId (uint8_t ubNetV, uint8_t ubNodeIdV, uint32_t *pulIdV)
 
ComStatus_tv ComEmcyConsIsEnabled (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t *pubEnableV)
 
ComStatus_tv ComEmcyConsSetId (uint8_t ubNetV, uint8_t ubNodeIdV, uint32_t ulIdV)
 
ComStatus_tv ComEmcyConsQueueClear (uint8_t ubNetV)
 
ComStatus_tv ComEmcyConsQueueCount (uint8_t ubNetV, uint16_t *puwCountV)
 
ComStatus_tv ComEmcyConsQueueDisable (uint8_t ubNetV)
 
ComStatus_tv ComEmcyConsQueueEnable (uint8_t ubNetV)
 
ComStatus_tv ComEmcyConsQueueFetch (uint8_t ubNetV, CpCanMsg_ts *ptsCanMsgV)
 
ComStatus_tv ComEmcyEnable (uint8_t ubNetV, uint8_t ubEnableV)
 
ComStatus_tv ComEmcyGetId (uint8_t ubNetV, uint32_t *pulIdV)
 
ComStatus_tv ComEmcyGetInhibit (uint8_t ubNetV, uint32_t *pulTimeV)
 
ComStatus_tv ComEmcyIsEnabled (uint8_t ubNetV, uint8_t *pubEnableV)
 
ComStatus_tv ComEmcySend (uint8_t ubNetV, uint16_t uwEmcyCodeV, uint8_t *pubManCodeV)
 
ComStatus_tv ComEmcySetId (uint8_t ubNetV, uint32_t ulIdV)
 
ComStatus_tv ComEmcySetInhibit (uint8_t ubNetV, uint32_t ulTimeV)
 

Function Documentation

◆ ComEmcyConsEnable()

ComStatus_tv ComEmcyConsEnable ( uint8_t  ubNetV,
uint8_t  ubNodeIdV,
uint8_t  ubEnableV 
)
Parameters
ubNetV- CANopen Network channel
ubNodeIdV- Identifier of CANopen device
ubEnableV- Enable/Disable EMCY service
Returns
Value of enumeration ComErr_e

This function enables (ubEnableV = 1) or disables (ubEnableV = 0) the EMCY consumer service for a Node ID given by ubNodeIdV. Valid values for node-ID are limited by the COM_NODE_MAX symbol in com_conf.h.

◆ ComEmcyConsEventReceive()

void ComEmcyConsEventReceive ( uint8_t  ubNetV,
uint8_t  ubNodeIdV 
)
Parameters
ubNetV- CANopen Network channel
ubNodeIdV- Identifier of CANopen device

The function is called by the CANopen Master stack upon reception of an EMCY message. The EMCY message has to be enabled by ComEmcyConsEnable() in advance.

◆ ComEmcyConsGetId()

ComStatus_tv ComEmcyConsGetId ( uint8_t  ubNetV,
uint8_t  ubNodeIdV,
uint32_t *  pulIdV 
)

Set EMCY consumer service identifier.

Parameters
ubNetV- CANopen Network channel
ubNodeIdV- Node Identifier of CANopen device
pulIdV- pointer to identifier of EMCY
Returns
Value of enumeration ComErr_e

◆ ComEmcyConsIsEnabled()

ComStatus_tv ComEmcyConsIsEnabled ( uint8_t  ubNetV,
uint8_t  ubNodeIdV,
uint8_t *  pubEnableV 
)

Enable EMCY service.

Parameters
ubNetV- CANopen Network channel
ubNodeIdV- Identifier of CANopen device
pubEnableV- pointer to Enable/Disable EMCY service
Returns
Value of enumeration ComErr_e

◆ ComEmcyConsQueueClear()

ComStatus_tv ComEmcyConsQueueClear ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e

The function removes all messages inside the EMCY receive queue.

◆ ComEmcyConsQueueCount()

ComStatus_tv ComEmcyConsQueueCount ( uint8_t  ubNetV,
uint16_t *  puwCountV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]puwCountVNumber of messages present in the queue
Returns
Value of enumeration ComErr_e

The function retrieves the number of pending elements inside a EMCY receive queue.

◆ ComEmcyConsQueueDisable()

ComStatus_tv ComEmcyConsQueueDisable ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComEmcyConsQueueEnable()

The function disables the EMCY receive queue on the selected CANopen network channel.

◆ ComEmcyConsQueueEnable()

ComStatus_tv ComEmcyConsQueueEnable ( uint8_t  ubNetV)
Parameters
[in]ubNetVCANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComEmcyConsQueueDisable()

The function enables the EMCY receive queue on the selected CANopen network channel.

◆ ComEmcyConsQueueFetch()

ComStatus_tv ComEmcyConsQueueFetch ( uint8_t  ubNetV,
CpCanMsg_ts ptsCanMsgV 
)
Parameters
[in]ubNetVCANopen Network channel
[out]ptsCanMsgVPointer to CAN message structure
Returns
Value of enumeration ComErr_e

The function fetches one CAN message from the EMCY receive queue.

◆ ComEmcyConsSetId()

ComStatus_tv ComEmcyConsSetId ( uint8_t  ubNetV,
uint8_t  ubNodeIdV,
uint32_t  ulIdV 
)

Set EMCY consumer service identifier.

Parameters
ubNetV- CANopen Network channel
ubNodeIdV- Node Identifier of CANopen device
ulIdV- Identifier value for Emcy
Returns
Value of enumeration ComErr_e

◆ ComEmcyEnable()

ComStatus_tv ComEmcyEnable ( uint8_t  ubNetV,
uint8_t  ubEnableV 
)

Enable EMCY service.

Parameters
ubNetV- CANopen Network channel
ubEnableV- Enable/Disable EMCY service
Returns
Value of enumeration ComErr_e

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

◆ ComEmcyGetId()

ComStatus_tv ComEmcyGetId ( uint8_t  ubNetV,
uint32_t *  pulIdV 
)

Get EMCY service identifier.

Parameters
ubNetV- CANopen Network channel
pulIdV- Pointer to identifier value
Returns
Value of enumeration ComErr_e
See also
ComEmcySetId()

This function reads the identifier value for the EMCY service.

◆ ComEmcyGetInhibit()

ComStatus_tv ComEmcyGetInhibit ( uint8_t  ubNetV,
uint32_t *  pulTimeV 
)

Get EMCY message inhibit time.

Parameters
ubNetV- CANopen Network channel
pulTimeV- Pointer to EMCY inhibit time
Returns
Value of enumeration ComErr_e
See also
ComEmcySetInhibit()

This function retrieves the inhibit time between two subsequent EMCY messages. The pointer pulTimeV points to a variable that holds the time value in multiples of one microsecond.

◆ ComEmcyIsEnabled()

ComStatus_tv ComEmcyIsEnabled ( uint8_t  ubNetV,
uint8_t *  pubEnableV 
)

Check EMCY service.

Parameters
ubNetV- CANopen Network channel
pubEnableV- Pointer to Enable/Disable status
Returns
Value of enumeration ComErr_e
See also
ComEmcyEnable()

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

◆ ComEmcySend()

ComStatus_tv ComEmcySend ( uint8_t  ubNetV,
uint16_t  uwEmcyCodeV,
uint8_t *  pubManCodeV 
)

Send EMCY message.

Parameters
ubNetV- CANopen Network channel
uwEmcyCodeV- Emergency code
pubManCodeV- Pointer to manufacturer code
Returns
Value of enumeration ComErr_e

This function sends an emergency message with the code uwEmcyCodeV and an optional manufacturer code of 5 bytes.

◆ ComEmcySetId()

ComStatus_tv ComEmcySetId ( uint8_t  ubNetV,
uint32_t  ulIdV 
)

Set EMCY service identifier.

Parameters
ubNetV- CANopen Network channel
ulIdV- Identifier value
Returns
Value of enumeration ComErr_e
See also
ComEmcyGetId()

This function changes the identifier value for the EMCY service.

◆ ComEmcySetInhibit()

ComStatus_tv ComEmcySetInhibit ( uint8_t  ubNetV,
uint32_t  ulTimeV 
)

Set EMCY message inhibit time.

Parameters
ubNetV- CANopen Network channel
ulTimeV- EMCY inhibit time
Returns
Value of enumeration ComErr_e
See also
ComEmcyGetInhibit()

This function sets the inhibit time between two subsequent EMCY messages. The parameter ulTimeV is given in multiples of 1 microsecond.