Ik ben bezig om de gegevens die ik uit een smart KWH meter heb verkregen over te zetten naar een Siemens S7-300 PLC.
dit gebeurd via een PC kaart CP5611 rechtstreeks op MPI
de lokale MPI staat ingesteld op 0 (PC MPI adres).
de PLC heeft een MPI adres 2.
via het hoofd programma roep ik eerst de Init deel aan van de unit (zie hieronder)
daarna open ik de verbinding met de PLC en daarna schrijf ik de gegevens in een bestaande DB in de PLC en vervolgens sluit ik de verbinding weer met de PLC.
alles gaat goed zonder meldingen in het programma, echter ontvangt de PLC geen data en ook de gevraagde PLC naam verkrijg ik niet.
hieronder hoe ik dit gedaan heb (communicatie Unit) , zou iemand mij kunnen helpen wat hier nu precies fout gaat?
(n.b. APLCCom is een class waarin LibNoDave commando's bevinden rechtreeks via LibNodaveComponent unit (TNoDave).
AL_GData is een record die alle benodigde data omvat vanuit de KWH meter)

procedure TPLC.Init(AComData: TComData);
begin
ComData.ComPort := AComData.ComPort;
ComData.LocalMPi := AComData.LocalMPi;
ComData.RemoteMPI := AComData.RemoteMPI;
ComData.S7Handle := 0;
APLCCom.COMPort := IntToStr(ComData.ComPort);
APLCCom.CPURack := 0;
APLCCom.CPUSlot := 2;
APLCCom.MPILocal := ComData.LocalMPi;
APLCCom.MPIRemote := ComData.RemoteMPI;
APLCCOM.Protocol := DaveProtoS7Online;
APLCCom.MPISpeed := DaveSpeed187K;
end;



procedure TPLC.ReadPLC_DB(DBNo: Integer; out AL_GData: TL_G);

function ReadRealFromDB(ADBNo, Adr: Integer): Real;
var
Buffer: Real;
begin
Result := -1e0;
if _IOError <> PLC_NoError then Exit;
APLCCom.DBNumber := ADBNo;
APLCCom.ReadBytes(APLCCom.Area, ADBNo, Adr, 32, @Buffer);
if APLCCom.LastError = 0 then
Result := Buffer
else
_IOError := PLC_NoRead;
end;

function ReadIntFromDB(ADBNo, Adr: Word): Integer;
var
Buffer: Integer;
begin
Result := -1;
if _IOError <> PLC_NoError then Exit;
APLCCom.ReadBytes(APLCCom.Area, ADBNo, Adr, 16, @Buffer);
if APLCCom.LastError = 0 then
Result := Buffer
else
_IOError := PLC_NoRead;
end;

var
R: Real;
I: Integer;
begin
if Not isActive then
begin
_IOError := PLC_NotActive;
end;
With AL_GData do
begin
T1 := ReadRealFromDB(DBNo, 0);
T2 := ReadRealFromDB(DBNo, 4);
T3 := ReadRealFromDB(DBNo, 8);
T4 := ReadRealFromDB(DBNo, 12);
TActive := ReadIntFromDB(DBNo, 16);
V := ReadRealFromDB(DBNo, 18);
A := ReadRealFromDB(DBNo, 22);
G := ReadRealFromDB(DBNo, 26);
PIn := ReadRealFromDB(DBNo, 30);
POut := ReadRealFromDB(DBNo, 34);
end;
end;

function TPLC.WritePLC_DB(DBNo: Integer; AL_GData: TL_G): Boolean;

procedure WriteRealToDB(ADBNo, Adr: Word; R: Real);
var
Buffer: Array[0..5] of byte absolute R;
begin
if _IOError <> PLC_NoError then Exit;
APLCCom.WriteBytes(APLCCom.Area, ADBNo, Adr, 32, @Buffer);
if APLCCom.LastError <> 0 then
_IOError := PLC_NoWrite;
end;

procedure WriteIntToDB(ADBNo, Adr: Word; I: Integer);
var
Buffer: Array[0..3] of Byte absolute I;
begin
if _IOError <> PLC_NoError then Exit;
APLCCom.WriteBytes(APLCCom.Area, ADBNo, Adr, 16, @Buffer);
if APLCCom.LastError <> 0 then
_IOError := PLC_NoWrite;
end;

begin
Result := False;
if not isActive then
begin
_IOError := PLC_NotActive;
Exit;
end;
With AL_GData do
begin
WriteRealToDB(DBNo, 0, T1);
WriteRealToDB(DBNo, 4, T2);
WriteRealToDB(DBNo, 8, T3);
WriteRealToDB(DBNo, 12, T4);
WriteIntToDB(DBNo, 16, TActive);
WriteRealToDB(DBNo, 18, V);
WriteRealToDB(DBNo, 22, A);
WriteRealToDB(DBNo, 26, G);
WriteRealToDB(DBNo, 30, PIn);
WriteRealToDB(DBNo, 34, POut);
end;
Result := _IOError = PLC_NoError;
end;

function TPLC.GetActive: Boolean;
begin
Result := isActive;
end;

function TPLC.GetPLCName: String;
begin
Result := '';
if APLcName <> '' then
Result := APLCName
else
_IOError := PLC_NoIdent;
end;

function TPLC.OpenS7: Boolean;
begin
_IOError := 0;
PLC_Error := 0;
APLCCom.Connect;
if APLCCom.LastError <> 0 then
begin
_IOError := PLC_NotFound;
Exit;
end;
APlcName := APLCCom.PLCName;
isActive := True;
Result := _IOError = 0;
end;

function TPLC.CloseS7: Boolean;
begin
if isActive then
begin
APLCCom.Disconnect;
if APLCCom.LastError <> 0 then
_IOError := PLC_NoSuchConnection
else isActive := False;
end;
Result := _IOError = 0;
end;