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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Question:
EtherCAT Error detection in IEC Answer:
Master:
Diagnostics Message can be read within the Master configuration tab.
Same in EtherCAT_Master.m_sLastMesage
( 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
**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:
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)
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)
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'
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
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
Question:
EtherCAT Error detection in IEC
Answer:
Master:
Diagnostics Message can be read within the Master configuration tab.
Same in EtherCAT_Master.m_sLastMesage
```
EK1100(); // Name of the slave = "EK1100"
EL1004();
EL2008();
IF NOT EK1100.wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
// do something
END_IF
( 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
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
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.
Back to FAQ overview
**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:
check online help for 'bus cycle'
Back to FAQ overview