//妈了个蛋蛋帖子竟然不能少于10个汉字
i_Prestored_NodeAdr[1]:=1;
i_Prestored_NodeAdr[2]:=3;
i_Prestored_NodeAdr[3]:=4;
i_Prestored_NodeAdr[4]:=14;
i_Prestored_NodeAdr[5]:=15;
B_com_OK:=_EC_MBXSlavTbl[i_Prestored_NodeAdr[1]] and _EC_MBXSlavTbl[i_Prestored_NodeAdr[2]] AND _EC_MBXSlavTbl[i_Prestored_NodeAdr[3]]
AND _EC_MBXSlavTbl[i_Prestored_NodeAdr[4]] AND _EC_MBXSlavTbl[i_Prestored_NodeAdr[5]] ;
R_TRIG1(CLK:=Enable);
ton_Check(in:=state>0,pt:=t#3m,et=>Check_time_et);
IF ton_Check.Q THEN
state:=0;
END_IF;
canshu3.Index:=16#2032;
canshu3.Subindex:=0;
canshu3.IsCompleteAccess:=FALSE;
(******************************循环读取P0-50*****************************)
IF B_com_OK THEN
CASE state OF
0:
i_dev:=0;
ERR_Num:=0;
ok_num:=0;
IF R_TRIG1.Q THEN
state:=10;
i_dev:=1;
END_IF;
TON1(In:=FALSE,pt:=t#50ms);
Exe_Read:=FALSE;
10:
i_dev_NodeAdr:=i_Prestored_NodeAdr[i_dev];
Exe_Read:=TRUE;
//state:=20;
TON1(In:=EC_COESDOread_1.Busy=FALSE,pt:=t#500ms);
IF ton1.Q THEN
state:=20;
TON1(In:=FALSE,pt:=t#50ms);
END_IF;
20:
TON1(In:=TRUE,pt:=t#500ms);
//R_TRIG2(clk:=TON1.Q);
IF TON1.Q THEN
//TON1(In:=wanc1=FALSE,pt:=t#300ms);
IF wanc1 THEN
state:=30;
TON1(In:=state<>20,pt:=t#50ms);
ELSE
state:=31;
TON1(In:=state<>20,pt:=t#50ms);
END_IF;
wanc1:=FALSE;
Exe_Read:=FALSE;
TON1(In:=state<>20,pt:=t#50ms);
END_IF;
30:
Exe_Read:=FALSE;
ok_num:=ok_num+1;
IF i_dev<5 then
i_dev:=i_dev+1;
state:=10;
ELSE
i_dev:=1;
state:=10;
END_IF;
TON1(In:=FALSE,pt:=t#50ms);
31:
Exe_Read:=FALSE;
IF ERR_Num<5 then
ERR_Num:=ERR_Num+1;
state:=10;
ELSE
ERR_Num:=0;
IF i_dev<5 then
i_dev:=i_dev+1;
state:=10;
ELSE
i_dev:=1;
state:=10;
END_IF;
TON1(In:=FALSE,pt:=t#50ms);
END_IF;
END_CASE;
ELSE
Err:=FALSE;
END_IF;
EC_COESDOread_1(execute:=Exe_Read,
NODEADR:=i_dev_NodeAdr,
SDOOBJ:=canshu3,
TIMEOUT:=0,
READDAT:=ReadData[i_dev]);
//DONE=>wanc1);
Exe_Read:=FALSE;
IF EC_COESDOread_1.Done THEN
wanc1:=TRUE;
END_IF;
Err:=ReadData[1]<>0 OR ReadData[2]<>0 OR ReadData[3]<>0 OR ReadData[4]<>0 OR ReadData[5]<>0;
//报警输出
HmiExceptionShow[90]:= testabit(UINT_TO_WORD(aReadData[1]),USINT#0);
HmiExceptionShow[91]:= testabit(UINT_TO_WORD(aReadData[1]),USINT#1);
HmiExceptionShow[92]:= testabit(UINT_TO_WORD(aReadData[1]),USINT#4);
HmiExceptionShow[93]:= testabit(UINT_TO_WORD(aReadData[2]),USINT#0);
HmiExceptionShow[94]:= testabit(UINT_TO_WORD(aReadData[2]),USINT#1);
HmiExceptionShow[95]:= testabit(UINT_TO_WORD(aReadData[2]),USINT#4);
HmiExceptionShow[96]:= testabit(UINT_TO_WORD(aReadData[3]),USINT#0);
HmiExceptionShow[97]:= testabit(UINT_TO_WORD(aReadData[3]),USINT#1);
HmiExceptionShow[98]:= testabit(UINT_TO_WORD(aReadData[3]),USINT#4);
HmiExceptionShow[99]:= testabit(UINT_TO_WORD(aReadData[4]),USINT#0);
HmiExceptionShow[100]:= testabit(UINT_TO_WORD(aReadData[4]),USINT#1);
HmiExceptionShow[101]:= testabit(UINT_TO_WORD(aReadData[4]),USINT#4);
HmiExceptionShow[102]:= testabit(UINT_TO_WORD(aReadData[5]),USINT#0);
HmiExceptionShow[103]:= testabit(UINT_TO_WORD(aReadData[5]),USINT#1);
HmiExceptionShow[104]:= testabit(UINT_TO_WORD(aReadData[5]),USINT#4);
楼主最近还看过