Siemens Simatic s7-300 Ethernet connection Issues

You also need to make a connection in netpro ( specify the IP and Port on both sides.

On delphi side you need to use a array to rea the info .Have a look at the code .I used this to test ...change the IP to suit
Thanks

I was already using the UDPCLient from indy to interface with my OPC client, so I can pretty much take the OPC out then and exchange it with the TdUDPServer from indy. That makes it much simpler

Also you didn't include any sample code...
 
Double oops

Jesper

FC5/FC6 , yes could be a problem if using onboard , I don't have the specs or such a CPU ...

zOde

Now where did this code goto ....Lets try again.o_O

First time was a RAR ... We used this code to extract info from PLC to send to a pager system , we later extended to also send info to PLC

I also got some stuff on libnodave and also component for Delphi ,I have not tried the code but the demo EXE works.You can find Part1 and Part2 on my site

Greetings

Eric

o_OSome very explicit swearword ... took to long to submit and ... had to write post again
 
Last edited:
Having some trouble getting the server to connect to the PLC, Not sure exactly how to input the IP address. I have the correct port specified in the object viewer but just cant seem to figure out the syntax of specifying the IP address. Any Ideas?
 
Hi

Sorry about the delay

this is where its gets difficult: Need to know what version of Delphi you use and what component

If using D7 with Tidudpserver then its something like this :
'UDPName.SendBuffer(PLC_IP,PLC_port,PLC_array[1],Length(PLC_array));'

If using D2005 with Tidudpserver then its something like this :
'udp.OnUDPRead(Adata,Abinding);'
'ABinding.SendTo(ABinding.PLC_IP, ABinding.PLC_Port, PLC_array[1], Length(PLC_array));'

Problem is we got the soft running for a couple of years already and cause there was no need to change and/or recompile we never ported it to D2005 of D2007

Hope it helps or we try again

Eric
 
Using D5, I assume it will be the same as the D7 code since its using Indy9 and the SendBuffer Command is there instead of SendTo command. Now the PLC_Array, this is an array in which we are storing the data, correct?

I'm going to give this a quick try and see how it results.
 
zOde

Mystream := Tmemorystream.Create;
try
Mystream.LoadFromStream(Adata);
setlength(myarray ,30);
Mystream.Read(myarray[1],30);
finally
mystream.Free ;
end ;//try


You create a 'stream' and then read the first 30 bytes and then put these in the array . A stream is also non blocking,meaning when you read it doesn't become read/write protected.

var
MyStream:TMemoryStream;
TmpStr1 : String;
myarray : array of byte ;


Defined myarray as byte so
Varbyte1 := myarray[1] ;
VarByte2 := myarray[2]
.... etc

Bye

Eric
 
I understand about pulling the stream, but I'm having trouble connecting to the PLC. This is what I have to connect to the PLC.

procedure UDPConnect;
var
DataArray : array of byte ;
IpString: String;
IpPort : integer;

begin
setlength(DataArray,102);
IpPort := 23;

if FileExists(ExtractFilePath(Application.ExeName) + addressFile) then
begin
SetCurrentDir(ExtractFilePath(Application.ExeName)); //set the current directory to find the IPaddress list .txt file
AssignFile(AddListFile, addressFile);
Reset(AddListFile); //open file for reading
ReadLn(AddListFile,IpString);
MainForm.IpAddress.Caption := IpString; //display the first address from the IPaddress File
MainForm.IpAddress.Visible := true;
MainForm.UDPServ.SendBuffer(IpString,IpPort,DataArray[1],length(DataArray)); //connect to the PLC
CloseFile(AddListFile);
end;

end;


I think the variable names are pretty self explanatory, It just doesn't connect to the PLC, when I use the local IP it works but when I use the PLC IP it doesn't connect to anything. Do I have to add anything or change anything?
 
Hi

Did you make a connection in your project using netpro .The info on the PC side must correspond with the info know to the PLC , you also have to write a block with a call to FC5 ( AG_SEND) and FC6 ( AG_RECV)( from the communications library).Have a look at this link and this link

Eric
 
Hi had some good success with VB and libnodave which excell can be programmed with to pull the data out of the PLC and straight into excel with no external software or OPC over the ethernet if you are experienced with Delphi try VB not too different in structure.
 
I don't have NetPro or the S7 software, is there anyway I can do this without either?

If no other way will work. We can purchase netpro or the S7 stuff, but I need to know how much it is and what exactly to do when we get it, and where to get it from.

Hi had some good success with VB and libnodave which excell can be programmed with to pull the data out of the PLC and straight into excel with no external software or OPC over the ethernet if you are experienced with Delphi try VB not too different in structure.


I would port it over to VB as I know it better than Delphi, but we are running short on time and I have everything completed but this connection point. For me to port it to VB it would take another week or so to get it running then I would have to figure out the OPC part, or the libnodave part. So I think changing languages is out of the picture at this point.
 
Hi

I think the best way is to import the nodave lib into delphi

Eric


OK, I'm going this route now, i have libnodave downloaded and unzipped, Having trouble with installing the component, something about a couple of undeclared identifiers
 
OK, I'm going this route now, i have libnodave downloaded and unzipped, Having trouble with installing the component, something about a couple of undeclared identifiers
Solved this problem.

I have a connection and bytes read, but my array is only 15 index values long i need it to have over 100 index values, how do we do this?
 

Similar Topics

Hi to all, Our company does not usually use Siemens PLCs, but have a press with one in it. We are trying to change the IP address in our Simatic...
Replies
2
Views
1,070
Hello all, Newbie in Siemens, I want to ask if there will be any issue when I download the instance datablock of a certain Function block? Also...
Replies
6
Views
4,419
hello, I'm new in automatics, and i'm working on a speed control project for a hydraulic turbine. i'm using FB41 pid bloc, but the LMN give me 0...
Replies
3
Views
2,265
Hi guys, Tomorrow I'm heading down to take a look at an existing SCADA system that has failed, and I was wondering if anyone had some suggestions...
Replies
18
Views
12,830
Hi Guys, I am facing a problem with my Siemens Simatic S7-300,CPU 315-2 DP( 6ES7315-2AF03-0AB0 ).That is in the morning i dont know why but it...
Replies
3
Views
3,354
Back
Top Bottom