|
//重新启动从站
IoDrvEthercatLibinstance(xRestart:= OperationPackML.Reset AND NOT EtherCatInstance.EtherCATConnectOK
, xStopBus:= , xConfigFinished=> , xDistributedClockInSync=> , xError=> , xSyncInWindow=> );
//检测任务端口
EtherCatInstance.EtherCATConnectOK:=ETHERCAT.xConfigFinished AND
ETHERCAT.xDistributedClockInSync AND
NOT ETHERCAT.xError ;
//运行第一周期
IF NOT EtherCatInstance.EtherCATConnectSuccess AND EtherCatInstance.EtherCATConnectOK THEN
EtherCatInstance.EtherCATConnectSuccess:=TRUE;
END_IF;
EtherCatInstance.FristSlave:=ETHERCAT.FirstSlave;//主站的第一个从站
WHILE EtherCatInstance.FristSlave<>0 DO
EtherCatInstance.FristSlave^();
IF EtherCatInstance.FristSlave^.wState=ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN
EtherCatInstance.EtherCATConnectStatus[Index2]:=TRUE;
ELSE
EtherCatInstance.EtherCATConnectStatus[Index2]:=FALSE;
EXIT;
END_IF
EtherCatInstance.FristSlave:=EtherCatInstance.FristSlave^.NextInstance;
Index2:=Index2+1;
IF Index2>=cm1_uiAxNum THEN
EXIT;
END_IF
END_WHILE;
Index2:=0;
|
|