CODESYS - the IEC 61131-3 automation software

Page 1 of 1

Author:  Supporter [ Fri Feb 28, 2014 9:34 am ]
Post subject:  Fieldbus

Fieldbus related:

EtherCat recovering from disconnection
EtherCat, How to reset the Master in IEC?
EtherCat, Error detection in IEC
EtherCat project contains additional Modbus TCP Master: update of Ethercat frames seems to be influenced by modbus update - how could this be avoided?
Modbus, Trigger variable

Author:  Supporter [ Fri Feb 28, 2014 9:35 am ]
Post subject:  EtherCat status icon not green

EtherCat revocering from disconnection

Which steps are needed to recover from disconnected slaves

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

Author:  Supporter [ Fri Feb 28, 2014 9:37 am ]
Post subject:  EtherCAT, Error detection in IEC

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

Slave State can be read within the Slave configuration tab. Diagnostics Current State
Same with SlaveName.wState (call of the slave instance is required)
EK1100(); // Name of the slave = "EK1100"
      // do something


A very good example is the ethercat example in the CODESYS store:
(* 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;
   (* Get the state of the slave *)
   (* With pSlave^.SetOpMode(ETC_SLAVE_STATE), the state can be set.*)
   pSlave := pSlave^.NextInstance;


Back to FAQ overview

Author:  Supporter [ Fri Feb 28, 2014 9:40 am ]
Post subject:  Modbus, Trigger variable

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?
Will it cause just one channel to be written?

Back to FAQ overview

Author:  Supporter [ Fri Feb 28, 2014 9:41 am ]
Post subject:  EtherCat, How to reset the Master in IEC?

How to reset the Master in IEC:

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;

Back to FAQ overview

Author:  Supporter [ Mon Mar 10, 2014 9:43 pm ]
Post subject:  Ethercat Update seems to be influenced my Modbus IO's

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

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited