Seeking a Code-Based Solution for EtherCAT Slave Dropout or Master Errors in Production (Beyond Software Hot Reset)

yuan
2025-07-18
2026-02-14
  • yuan - 2025-07-18

    I need official assistance with the following issue:
    During EtherCAT communication, if a slave station drops off the network or the master station encounters an error, the problem can currently only be resolved by performing a software-based hot reset. In actual production environments, this approach is unacceptable. Is there a method to resolve these issues programmatically, through code?

     
  • zeljko2212 - 2026-02-14

    PROGRAM RES_ECAT
    VAR
    xMP1: INT;
    xRESTART: BOOL;
    xFinish: BOOL;
    xStop: BOOL;
    pSlave: POINTER TO ETCSlave;
    TP1 : TP;
    STS11: WORD;
    pSlave6: POINTER TO IoDrvEthercatDriverLib.ETCSlave;
    MP1: INT;
    TON1 : TON;
    xSTAT: BOOL;
    TP_1 :standard.TP;
    END_VAR

    TON1(IN:= NOT TON1.Q, PT:= T#300mS );
    TP_1(IN:= ton1.Q, PT:= t#2s );

    EtherCAT_Master.xRestart := xRESTART;
    EtherCAT_Master();

    EtherCAT_Master();
    xFinish := EtherCAT_Master.xConfigFinished;

    EtherCAT_Master.xStopBus := xSTOP;
    EtherCAT_Master();

    pSlave := EtherCAT_Master.FirstSlave;
    WHILE pSlave <> 0 DO
    pSlave^();
    IF pSlave^.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
    xRESTART := FALSE;
    ELSE
    xRESTART := TP_1.Q;
    END_IF
    pSlave := pSlave^.NextInstance;
    END_WHILE

     

Log in to post a comment.