|
Communication with Siemens PLC over TCP/IP |
Iniciado por Joris DE GEYNDT, 31,ene. 2014 13:55 - 11 respuestas |
| |
| | | |
|
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 31,enero 2014 - 13:55 |
I'm using WinDev to process lab testing data, delivered by a Siemens PLC (300 series) over TCP. I do not use the OPC server software of Siemens, but I use direct communication between the Siemens PLC Ethernet module and the WinDev application. I managed to read data in, but nevertheless I would like to discuss these matters with other WinDev developers that work with Siemens devices. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 31,enero 2014 - 14:56 |
Below I give the code of a class that you can use to communicate to een Siemen PLC (read only). First some pitfalls to avoid: - be sure to open the firewall on your PC for the chosen portnumber! - both your PC and the Siemens PLC need to have a fixed IP. The PLC cannot perform a DNS request! then do this: - create an object from the class below - set PLC_ip , PC_ip and TCP_portnumber members - call ServerStart method - everything that is sent by the PLC will appear in the Trace windows.
sample code to use the class:
PLC is Class_SiemensOverIP PLC.PC_ip = "192.168.1.200" PLC.PLC_ip = "192.168.1.201" PLC.TCP_portnumber = 8000 PLC.ServerStart()
Class description:
Class_SiemensOverIP is a Class
PLC_ip is string PC_ip is string TCP_portnumber is int SocketName is string = "SiemensPLC" WaitingThreadName is string = "WaitingThread"
END
Procedure ServerStart()
IF SocketExist(SocketName) THEN ToastDisplay("Socket already in use.",toastLong,vaMiddle,haCenter,DarkRed) RESULT False END Socket.Option = SocketNagleOff IF SocketCreate(SocketName,TCP_portnumber,PC_ip) = False THEN NextTitle("Network error") Error("Check wheter the specified IP address (,"+PC_ip+") is assigned to a local network card and wheter portnumber "+TCP_portnumber+" is not already in use by another application. " + ... CR + "Error details: "+ErrorInfo()) RESULT False END SocketChangeTransmissionMode(SocketName,SocketNoEndTag) ThreadExecute(WaitingThreadName,threadNormal,":ServerWaitForConnection") RESULT True
Procedure ServerStop() IF NOT SocketExist(SocketName) THEN RESULT False END ThreadStop(WaitingThreadName) SocketClose(SocketName)
Procedure ServerWaitForConnection() SocketChangeTransmissionMode(SocketName,SocketNoEndTag) WHILE True MultitaskRedraw() Trace(SocketRead(SocketName,True)) END |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3 mensajes |
|
Publicado el 31,enero 2014 - 15:38 |
Hello Joris,
I saw your link in the french part of the forum, thank for your help. Sorry for my english language...
At the moment, I'm just checking the way to resolve my problem (TCP or Profibus). In my case, computer (Windev) needs to read data from PLC but also write data as date, time, next production id etc...
I will start this project in the next two months.. But if you find the way to write data in PLC, let's me know. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 31,enero 2014 - 16:09 |
Hi Fred,
Below is the method I used with success to write towards another server application. I suppose it should work to wrtite toward a Siemens PLC also, but I cannot test it, because I don't have a PLC with Ethernet right now. (It is a method I addes to the class desribed in my first post). If you have any result with this, please let me know!
Procedure Write2Client(msg is string)
IF SocketConnect("WriteName",TCP_portnumber,PLC_ip,2000) = False THEN ToastDisplay("Cannot connect",toastLong,vaMiddle,haCenter,DarkRed) RESULT False END SocketChangeTransmissionMode("WriteName",SocketNoEndTag) Socket.Option =SocketNagleOff SocketWrite("WriteName",msg) Trace(SocketRead("WriteName",False)) SocketClose("WriteName") |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 31,enero 2014 - 16:16 |
addendum: I found that the line
SocketChangeTransmissionMode("WriteName",SocketNoEndTag) is absolutely necessary to make the communication work. Also: Siemens uses real TCP-sessions, so you cannot use UDP. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3 mensajes |
|
Publicado el 31,enero 2014 - 17:44 |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 01,febrero 2014 - 15:23 |
Fred,
Thanks for thr link. I suppose you're right. The 'Siemens world' is quite new for me. The PLC programmer showed me how he could configur a new network connection in the PLC (Siemens 312C if I'm not mistaken), and the only option I saw was a 'TCP-connection'. But it may depend on hardware or software configuration ... First I was told that it uses the UDP-protocol, but when I tried to read data from an UDP-socket in Windev, it did'nt work. With a TCP-socket it did work. Unfortunate, our PLC programmer is not experienced with ethernet connections either, because till now, we always did use serial communication.
So at this point, it is a bit trial and error |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 12 mensajes Popularité : +1 (1 vote) |
|
Publicado el 13,febrero 2014 - 16:42 |
I can confirm that the Class (code posted above) works very well. The PLC programmer had some issues to make his PLC send over TCP, but it all works very well now.
At this stage, it is only one direction: the PLC measures some stuff and sends it periodically to a IP-address. Windev reads in a packet and divides it up in a bunch of numbers. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 1 mensaje |
|
Publicado el 26,septiembre 2017 - 13:05 |
Hello Joris , Before all ,sorry for my english because i m Belgian from the french side , and i not speak very well in english
I looking for a solution to comunicate between a s7 1200 or s7 1500 to make a HMI for Siemens without OCP server (more expensive) whit a windes solution But i make some tests but i not have a good results , i use your class SiemensOverIP , i not hve a compile errors but i not transfert a status of byte or other Words
You developate your class in 2014 , now 3 year later have you a solution and if you have a solution can you give me a copy of this code in wlangage ?
My Platform is Windev 20 thanks and best regards Thierry Damoiseau
my mail thierry.damoiseau@ulysse-engineering.be from Verviers Belgium
bye |
| |
| |
| | | |
|
| | |
| |
Publicado el 08,febrero 2019 - 08:31 |
Hi Joris, I am new to Windev and trying to get data from an Avery-Wetronix digitizer via TCP/IP. Please can you contact me by email : pdufourq@gmail.com Thank you Kind Regards Patrick |
| |
| |
| | | |
|
| | |
| |
Publicado el 19,febrero 2019 - 15:24 |
Hi everyone,
Alas I left my job as Windev developer almost 4 years ago.
I loved Windev, but it is too far away now to be of any help
Success!
Joris |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 7 mensajes Popularité : +1 (1 vote) |
|
Publicado el 15,febrero 2020 - 17:00 |
hello any one can slove this problem of communication
i need help |
| |
| |
| | | |
|
| | | | |
| | |
|