Net weight
16#00005000
Gross weight
16#00005001
Max weight
16#00003002
Step value
16#00003003
Value in converter points
16#00005002
Standard load value for calibration
16#00013001
0
0
0
0
(* Program for managing card SCAIME eNod3C *)
(* Copy actual values to Tool data *)
eNodDatas.NetWeight := eNodIN.NODNet;
eNodDatas.Stability := eNodIN.NODStatus.4;
eNodDatas.ScaleERR := ((eNodIN.NODStatus AND 16#000F)<>0) OR Not CanOpenOk;
eNodDatas.Status := eNodIN.NODStatus;
eNodDatas.IsNet := eNodIN.NODNet<>eNodIN.NODBrut;
(* And to Ouput datas *)
Weight := eNodDatas.NetWeight;
Stability := eNodDatas.Stability;
ScaleERR := eNodDatas.ScaleERR;
(* Read other values not included in PDOs *)
AdresseModule := ADDM(Address);
(* Reset all if no communication *)
If Not CanOpenOk Then
Reading := False;
ReadCom[0]:=0;
WriteCom[0]:=0;
CommandStep := 0;
eNodDatas.Result := CommandMem;
End_if;
(* If not reading, send SDO request *)
If Not Reading And Not ReadCom[0].0 And RE(TOP) And CanOpenOk Then
(* Check read index *)
If (ReadIndex>9) or (ReadAdrs[ReadIndex]=0) Then
ReadIndex := 0;
End_if;
(* Send SDO message *)
Reading := True;
ReadCom[2] := 50; (* Time out 5 seconds *)
ReadBuffer[0] := 0; (* Reset last read value *)
ReadBuffer[1] := 0; (* Reset last read value *)
READ_VAR(AdresseModule,'SDO',ReadAdrs[ReadIndex],0,ReadCom,ReadBuffer);
End_if;
(* Check reading response *)
if Reading And Not ReadCom[0].0 And CanOpenOk Then
Reading := False;
If ReadCom[1]=0 Then (* No error *)
eNodDatas.ReadValues[ReadIndex] := INT_As_DINT(ReadBuffer[0],ReadBuffer[1]);
Inc(ReadIndex);
End_if;
end_if;
(* New command *)
If (eNodDatas.Command<>CommandMem) And CanOpenOk Then
If eNodDatas.Command=0 Then
(* Command has been reseted, we reset the response *)
eNodDatas.Result := 0;
CommandMem := 0;
CommandStep := 0;
Else
(* New command *)
CommandMem := eNodDatas.Command;
If CommandMem=16#00CA Then
CommandStep := 1; (* Start command sequence by sending the Standard load *)
Else
CommandStep := 3;
End_if;
End_if;
End_if;
(* Steps for manage command *)
CASE CommandStep OF
1: (* Step 1 : send normal weight by using SDO *)
WriteCom[2] := 50; (* Time out 5 seconds *)
WriteCom[3] := 4; (* 4 bytes to write *)
DINT_AS_WORD(eNodDatas.StandardLoad,TempWord0,TempWord1);
WriteBuffer[0]:=WORD_TO_INT(TempWord0);
WriteBuffer[1]:=WORD_TO_INT(TempWord1);
WRITE_VAR(AdresseModule,'SDO',16#00013001,0,WriteBuffer,WriteCom);
CommandStep:=2;
2: (* Write for the end of WRITE_VAR *)
If Not WriteCom[0].0 Then
If WriteCom[1]=0 Then
CommandStep:=3; (* OK we continue *)
Else
CommandStep:=1; (* Retry *)
End_if;
End_if;
3: (* Send command to the eNod *)
eNodOUT.NODBufferOut := CommandMem;
(* And wait for the result *)
If eNodIN.NODBufferIn>1 Then
If eNodIN.NODBufferIn=2 Then
CommandStep := 4; (* Command completed *)
else
CommandStep := 4; (* Error must be completetd here ******)
End_if;
End_if;
4: (* Send volontary an unknow command to force the 3 value in response *)
eNodOUT.NODBufferOut := 16#FF;
If eNodIN.NODBufferIn=3 Then
CommandStep := 5; (* 3 is the only value we can get for an unknow value *)
End_if;
5: (* Now we send 0 (idle) command to reset the last error *)
eNodOUT.NODBufferOut := 0;
If eNodIN.NODBufferIn=0 Then
(* Command is totaly completed here *)
CommandStep := 0;
eNodDatas.Result := CommandMem;
End_if;
END_CASE;
Command word from PC
Command result
Standard load for calibration
Net weight
Scale is stable
Scale is in error
Copy of scale measure status
Tare is not null
Copy of net weight
Copy of gross weight
Maximum measure value
Step value
Converter points
Reading of standard load