Page tree
  • Create a "Standard project” and select CODESYS Control Win V3 as the device.
  • Define the target system by means of Network scan.




  • Activate the Diagnosis for devices.




  • Insert an EtherCat Master Ethernet adapter and specify the interface to be used.

    If a target system has not been defined yet, then the error message "Gateway not configured" is displayed.





  • Insert a slave below the EtherCat Master or scan the bus.




  • Edit the PLC_PRG POU as follows:


    Declaration

    VAR
        xDisable        : BOOL;
        xEnable         : BOOL;
        xReconfigure    : BOOL;
        itfNodeSlave    : DED.INode;
        fbReconfigure   : DED.Reconfigure;
    	eState          : IoDrvEthercatLib.ETC_SLAVE_STATE;
    END_VAR

    Implementation

    itfNodeSlave := EK1100;
    
    IF xDisable THEN
        xDisable := FALSE;
        itfNodeSlave.Enable := FALSE;
        xReconfigure := TRUE;
    END_IF
    
    IF xEnable THEN
        xEnable := FALSE;
        itfNodeSlave.Enable := TRUE; 
        xReconfigure := TRUE;
    END_IF
    
    fbReconfigure(xExecute := xReconfigure, itfNode := EtherCAT_Master);
    
    IF fbReconfigure.xDone THEN
        xReconfigure := FALSE;
    END_IF
    
    EK1100(); // Necessary for the status to be updated
    eState := EK1100.wState;


  • Start the project and test the functionality by deactivating and activating the slave.



  • No labels