cancel
Showing results for 
Search instead for 
Did you mean: 

CANOpen (CiA 418 and 419) Emergency error codes(EMCY)

AlbinJoshy
Associate

Hello Team,

I am trying to integrate the CANOpen protocol Emergency error codes (EMCY) based on CiA 301, 418(battery module) and 419(battery charger) standards in the STM32L496VG controller. I could see the standard error codes in CiA 301, but I would like to know how to include custom error codes within the standard error codes mentioned below.

Error codesDescription
0000hError reset or no error
1000hGeneric error
2000hCurrent – generic error
2100hCurrent, CANopen device input side – generic
2200hCurrent inside the CANopen device – generic
2300hCurrent, CANopen device output side – generic
3000hVoltage – generic error
3100hMains voltage – generic
3200hVoltage inside the CANopen device – generic
3300hOutput voltage – generic
4000hTemperature – generic error
4100hAmbient temperature – generic
4200hDevice temperature – generic
5000hCANopen device hardware – generic error
6000hCANopen device software – generic error
6100hInternal software – generic
6200hUser software – generic
6300hData set – generic
7000hAdditional modules – generic error
8000hMonitoring – generic error
8100hCommunication – generic
8110hCAN overrun (objects lost)
8120hCAN in error passive mode
8130hLife guard error or heartbeat error
8140hRecovered from bus off
8150hCAN-ID collision
8200hProtocol error - generic
8210hPDO not processed due to length error
8220hPDO length exceeded
8230hDAM MPDO not processed, destination object not available
8240hUnexpected SYNC data length
8250hRPDO timeout
9000hExternal error – generic error
F000hAdditional functions – generic error
FF00hDevice specific – generic error

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

An answer from Google to the question: "implement a custom error code in CANopen":

To implement a custom error code in CANopen, you need to leverage the Emergency message functionality and define your specific error codes within the manufacturer-specific error field (MEF) of the Emergency message. Here's a breakdown of how to do it: 
 
1. Understanding CANopen Emergency Messages:
  • Purpose:
    CANopen Emergency messages are used to signal error conditions to other nodes in the network. 
     
  • Structure:
    The Emergency message format includes:
    • Error Code (EEC): The first two bytes of the message contain standard CANopen error codes, indicating the general type of error. 
       
    • Error Register: The third byte represents the specific error register (e.g., 0x1011). 
       
    • Manufacturer-Specific Error Field (MEF): The remaining bytes (4-7) are reserved for manufacturer-specific error information. This is where you define your custom error codes. 
       
2. Defining Custom Error Codes:
  • MEF Mapping:
    Within the MEF (bytes 4-7 of the Emergency message), you'll define your custom error code(s). This allows you to differentiate between various error conditions specific to your device.
  • Documentation:
    Create clear documentation that maps your custom error codes to the corresponding error conditions in your device. This is crucial for debugging and understanding error reports. 
     
3. Implementing the Error Reporting:
  • Error Condition Detection:
    Within your application, you'll need to detect the specific error conditions you want to report.
  • CANopen Node Stack Function:
    You'll use a CANopen stack's function (e.g., CO_errorReport() in CANopenNode) to report the error.
  • Emergency Message Generation:
    The CANopen stack will handle the creation of the Emergency message, including filling in the standard error code, error register, and your custom error code in the MEF. 
     
4. Example Scenario:
Let's say you're building a CANopen device that controls a motor, and you want to report a "Motor Overcurrent" error. 
 
  • Error Code (EEC):
    You might use the standard error code 0x5000 (Device Hardware, according to CANopenNode) to indicate a hardware-related error. 
     
  • Error Register:
    You might set the error register to 0x1011 (Device Hardware Error Register). 
     
  • MEF (Custom Error Code):
    You could define 0x1000 as your custom error code for "Motor Overcurrent" within the MEF. 
     
  • Emergency Message:
    The complete Emergency message would then be: 0x50 00 11 10 01 00 00 00 (where 0x5000 is the standard error code, 0x1011 is the error register, and 0x1000 is your custom error code). 
     
5. Interpreting the Emergency Message:
  • Error Code Interpretation: When a CANopen node receives this Emergency message, it will interpret the standard error code 0x5000 and the error register 0x1011, then it will look for the custom error code 0x1000 in the MEF to identify the specific "Motor Overcurrent" error. 
     
In Summary:
Implementing custom error codes in CANopen involves defining specific error codes within the MEF of Emergency messages, associating them with your device's error conditions, and using CANopen stack functions to report these errors. This allows for a more granular and informative error reporting system. 
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
mƎALLEm
ST Employee

An answer from Google to the question: "implement a custom error code in CANopen":

To implement a custom error code in CANopen, you need to leverage the Emergency message functionality and define your specific error codes within the manufacturer-specific error field (MEF) of the Emergency message. Here's a breakdown of how to do it: 
 
1. Understanding CANopen Emergency Messages:
  • Purpose:
    CANopen Emergency messages are used to signal error conditions to other nodes in the network. 
     
  • Structure:
    The Emergency message format includes:
    • Error Code (EEC): The first two bytes of the message contain standard CANopen error codes, indicating the general type of error. 
       
    • Error Register: The third byte represents the specific error register (e.g., 0x1011). 
       
    • Manufacturer-Specific Error Field (MEF): The remaining bytes (4-7) are reserved for manufacturer-specific error information. This is where you define your custom error codes. 
       
2. Defining Custom Error Codes:
  • MEF Mapping:
    Within the MEF (bytes 4-7 of the Emergency message), you'll define your custom error code(s). This allows you to differentiate between various error conditions specific to your device.
  • Documentation:
    Create clear documentation that maps your custom error codes to the corresponding error conditions in your device. This is crucial for debugging and understanding error reports. 
     
3. Implementing the Error Reporting:
  • Error Condition Detection:
    Within your application, you'll need to detect the specific error conditions you want to report.
  • CANopen Node Stack Function:
    You'll use a CANopen stack's function (e.g., CO_errorReport() in CANopenNode) to report the error.
  • Emergency Message Generation:
    The CANopen stack will handle the creation of the Emergency message, including filling in the standard error code, error register, and your custom error code in the MEF. 
     
4. Example Scenario:
Let's say you're building a CANopen device that controls a motor, and you want to report a "Motor Overcurrent" error. 
 
  • Error Code (EEC):
    You might use the standard error code 0x5000 (Device Hardware, according to CANopenNode) to indicate a hardware-related error. 
     
  • Error Register:
    You might set the error register to 0x1011 (Device Hardware Error Register). 
     
  • MEF (Custom Error Code):
    You could define 0x1000 as your custom error code for "Motor Overcurrent" within the MEF. 
     
  • Emergency Message:
    The complete Emergency message would then be: 0x50 00 11 10 01 00 00 00 (where 0x5000 is the standard error code, 0x1011 is the error register, and 0x1000 is your custom error code). 
     
5. Interpreting the Emergency Message:
  • Error Code Interpretation: When a CANopen node receives this Emergency message, it will interpret the standard error code 0x5000 and the error register 0x1011, then it will look for the custom error code 0x1000 in the MEF to identify the specific "Motor Overcurrent" error. 
     
In Summary:
Implementing custom error codes in CANopen involves defining specific error codes within the MEF of Emergency messages, associating them with your device's error conditions, and using CANopen stack functions to report these errors. This allows for a more granular and informative error reporting system. 
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.