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
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.
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.