Chained List for Checking of All Slaves

For the monitoring of individual slaves in the program the instance is called and the state is determined via wState. For simplification all masters and slaves can be determined by chained lists and all slaves can be checked by a simple WHILE loop. The properties NextInstance and LastInstance exist for both the master and the slave. These properties point to the next or previous slave. For the master there is an additional property, FirstSlave, which provides a pointer to the first slave. In accordance with the following example you can check all slaves:

Example

Declaration:

pSlave: POINTER TO ETCSlave;

Program:

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

Initially, the first slave is fetched to the master via EtherCAT_Master.FirstSlave.

In the WHILE loop the respective instance is called and wState is thus determined. The status can then be checked. The pointer to the next slave is fetched with pSlave^.NextInstance. If the list is finished, the pointer is ZERO and the loop ends.

See also