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

Fieldbus

2014-02-28
2014-03-10
  • Moderator3S

    Moderator3S - 2014-02-28

    EtherCat revocering from disconnection

    Question:
    Which steps are needed to recover from disconnected slaves

    ** Answer: **
    There are two use cases:
    1. IEC application should care on restart / error handling
    xRestart on Master is needed
    2. restart of slaves is done automatically:
    The EtherCAT Master provides an option to restart the fieldbus:
    Master Configuration, Master: Checkbox: Auto restart slaves
    3. Optional Slaves are possible (this is a tag 'Optional') in the slave config

    IMG: Ethercat_RestartSlaves.jpg

     
  • Moderator3S

    Moderator3S - 2014-02-28

    Question:
    EtherCAT Error detection in IEC
    Answer:
    Master:
    Diagnostics Message can be read within the Master configuration tab.
    Same in EtherCAT_Master.m_sLastMesage

    Slave:
    Slave State can be read within the Slave configuration tab. Diagnostics Current State
    Same with  SlaveName.wState (call of the slave instance is required)
    Example:
    

    ```

    EK1100(); // Name of the slave = "EK1100"
          EL1004();
          EL2008();
          IF NOT EK1100.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
          // do something
          END_IF

    **Snippet:**Snippet:
    
    
    A very good example is the ethercat example in the CODESYS store: [http://store.codesys.com/ethercat-example.html#Support](http://store.codesys.com/ethercat-example.html#Support)
    

    ( Get some information of the slaves and master. It is possible to go through all masters and slaves
       and get information about them.
    )
    ( EtherCAT_Master is an instance of the IoDrvEtherCAT function block.)
    ( The number of active slaves )
    uiActiveSlaves := EtherCAT_Master.NumberActiveSlaves;
    ( Get the ETCMaster )
    pEtcMasterFB := EtherCAT_Master.Master;
    ( The number of SDO's )
    iSDOCnt := pEtcMasterFB^.GetNumberOfSDO;
    ( Go through all Slaves )   
    pSlave := Ethercat_Master.FirstSlave;
    WHILE pSlave <> 0 DO
       ( get the address of the current slave. This can also be found under the  device in the "Slave" tab. )
       uiSlaveAddr := pSlave^.SlaveAddr;

       pSlave^();
       ( Get the state of the slave )
       ( With pSlave^.SetOpMode(ETC_SLAVE_STATE), the state can be set.)
       IF pSlave^.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
          ;
       END_IF

       pSlave := pSlave^.NextInstance;
    END_WHILE

    ```

    Back to FAQ overview

     
  • Moderator3S

    Moderator3S - 2014-02-28

    But we can’t locate the actual Boolean Trigger variable?

    You can find the trigger var, if you change the Trigger to “Rising edge” :

    you can define any bool var and map the var like any other in/output within the IOMapping for this channel.

    What is the scope of the trigger boolean?
    Yes
    Will it cause just one channel to be written?
    Yes

    Back to FAQ overview

    IMG: 1.png

    IMG: 2.jpg

     
  • Moderator3S

    Moderator3S - 2014-02-28

    Question:
    How to reset the Master in IEC:

    Answer:
    Do not use auto restart option and IEC code at the same time.
    Use a rising trigger to reset the Master with xReset.

          Ethercat_Master.xRestart := xReset;
          Ethercat_Master();
    

    Back to FAQ overview

     
  • Moderator3S

    Moderator3S - 2014-03-10

    **In a mixed application with Ethercat and Modbus masters, you see an influence on Modbus update to Ethercat task / sending frames- How could this be avoided? **

    You need a proper seperation of the use of the modbus io's and ethercat io's according to the task which does the buscycle update:

    1. Set Ethercat master in 'PLC Settings' as' Buscycle Task' - and Ethercat io's are only used in ethercat task context (in that case in PLC_PRG)
    2. specify on Modbus master the update task for Modbus - and Modbus io's are only used in Modbus task context ( in that case in ModbusPRG)
    3. Check if these rules are ok with 'task deployment' tap - Rule: Ethercat io's are only updated in the Ethercat task - Modbus io's are only updated on the Modbus task context - this you see with the red cross on each used io.
      check online help for 'bus cycle'

    Back to FAQ overview

    IMG: BuscycleTask.jpg

    IMG: ModbusUpdateTask.jpg

    IMG: Taskdeployment.jpg

     

Log in to post a comment.