Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

CanOpen and EMCY using CIA405.RECV_EMCY

DavidBo
2019-12-06
2021-04-28
  • DavidBo - 2019-12-06

    I cannot receive EMCY objects in my application but the CODESYS IDE does receive them I can see it in the status window of the device, so EMCY is of course enabled. I have the following program:

    PROGRAM POU_EMCY
    VAR
    EMCY_NW: CIA405.RECV_EMCY;
    xReq_EMCY: BOOL:=TRUE;
    xConfirm_EMCY: BOOL;
    EMCY_INFO : CIA405.EMCY_ERROR;
    EMCY_NodeID: USINT;

    END_VAR

    IF EMCY_NW.ERRORINFO.EMCY_ERROR_CODE <> 0 THEN
    xReq_EMCY:=FALSE; //Here I have a breakpoint but it never catches anything
    END_IF

    EMCY_NW( NETWORK:=1,
    ENABLE:=xReq_EMCY,
    TIMEOUT:=0,
    CONFIRM=>xConfirm_EMCY,
    ERROR=>,
    DEVICE=>EMCY_NodeID,
    ERRORINFO=>EMCY_INFO);

    Why do I not receive any EMCY messages in my application? I us PDO and do SDO_write without any problems.

     
  • laruso - 2021-04-28

    You need to first trigger the function with its input "enable". Then you can use the output "ERRORINFO.EMCY_ERROR_CODE".

    In your example code the "ERRORINFO.EMCY_ERROR_CODE" will stay 0 because it is the initial value and the function is not executed.

    You can have a look into the example project "CANopen example" from CODESYS Store.

     

Log in to post a comment.