MbAdd(Execute:= i_xStart,Addr:= MbAddr,AddrTable:= MbAddTab,Done=> MbAddDone,Error=> MbAddErr,CommError=> MbAddComErr);
i_xStart:=PULSE_200MS;
R1(CLK:=i_xStart);
IF R1.Q THEN
CurStep:= 5;
END_IF
IF NOT i_xStart AND NOT MbAdd.Done THEN
CurStep:= 0;
i_xStart:= FALSE;
COMWr(Execute:= FALSE);
COMRd(Execute:= FALSE);
END_IF
CASE CurStep OF
5:
CurStep:= 10;
10: //读
COMRdFO:= 5030;
COMRdQty:= 2;
COMRdVal[1]:= 0;
COMRdVal[2]:= 0;
COMRd(Execute:= TRUE,Addr:= MbAddTab,Timeout:= i_uiMbTmOut,ObjType:= MbObj,FirstObj:= COMRdFO,
Quantity:= COMRdQty,Buffer:= ADR(COMRdVal),Error=> COMRErr,CommError=> COMRComErr,OperError=> COMROpenErr);
IF COMRd.Done THEN
COMRd(Execute:= FALSE);
Read_Data_Previous:=ROL(WORD_TO_DINT(COMRdVal[2]),16)+COMRdVal[1];
CurStep:= 20;
END_IF
20:
CurStep:= 0;
END_CASE