Home > Forum > IEC 61131 Programming (LogicLab) > Library for communication between systems on the Internet
- This topic has 13 replies, 2 participants and was last updated 3 years, 5 months ago da Sergio Bertana.
-
AuthorPost
-
February 13, 2016 at 8: 51 am #35941Sergio BertanaAdministrator Forum
We have made the library available eLLabDataExchLib (Manual extract) which allows data exchange between systems with the TCP / IP protocol both on the local network and via the Internet. The function block TCPDataExchServer running on a system acts as a server and accepts connections from one or more systems in which the function block is running TCPDataExchClient.
It is evident that in this scenario if the system acting as a server is connected to the Internet through a connection that provides for the public IP (Even dynamic), many systems acting as clients, connected to the Internet through private IP networks and / or NATtate can exchange data with each other by triangulating on the server system.
Therefore, in a scenario such as that of public utilities, for example water or gas distribution, where we have systems geographically scattered over the territory and connected to the Internet via connections to IP NATtato, they can exchange data with the central server and between them. It is also possible through the server to report on an operator panel or a SCADA system the data of the various connected client systems.
February 13, 2016 at 9: 22 am #39371Sergio BertanaAdministrator ForumI made a demonstration program to test the functioning of the new library (The library is included in the demonstration), the program consists of two projects TCPDEServer (Print) to be transferred to the system acting as a server and TCPDEClient (Print) to be transferred to the system (One or more) acting as a client.As you can see the server program accepts up to two client connections, in the client program an IP address is defined for the server system but also accepts a URL as seen from the line commented. Both programs that can run on one system Compact ethernet are available for download (Download TCPDataExchange).
March 19, 2016 at 9: 53 am #39470Sergio BertanaAdministrator ForumFor those who are not very familiar with text programs, I modified the example of the previous post by making it using the ladder language. For the enhancement of the data structure TCPDEXCHNODEDEFS defining the parameters of the nodes in communication I realized the function DataExchSet (Print) which allows its enhancement from ladder language.
The demonstration program to test the functioning of the new library (The library is included in the demonstration), consists of two projects TCPDEServer (Print) to be transferred to the system acting as a server and TCPDEClient (Print) to be transferred to the system (one or more) acting as a client.
As you can see the server program accepts up to two client connections, in the client program an IP address is defined for the server system but it also accepts a URL. In the example for convenience the exchange of a single BOOL variable is managed but it is possible to define arrays of variables.
The FB BufferModified it checks any changes in the data buffer in transmission to the other system and when there is a change it immediately commands the transmission of the buffer, in this way the status is sent in real time.
Both programs that can work on a Compact ethernet system are available for download (Download TCPDataExchange).
April 16, 2018 at 8: 51 am #40076Sergio BertanaAdministrator ForumThe topic is covered in more detail in this one Knowledge.
March 16, 2020 at 8: 50 am #53926AlbertoParticipantOn the system that enables the outputs, how can you (if you can) do to set support variables in place of the outputs between the two systems?
March 16, 2020 at 8: 52 am #53946Sergio BertanaAdministrator ForumThe various systems exchange a memory area, it is then up to the program that is made to decide whether to place the memory on physical I / O or on managing internal variables.
For example, you could communicate acquired variables and / or set variables on other systems connected in Modbus.
March 27, 2020 at 11: 04 am #54304Alessandro CampodonicoParticipantI am testing the library with a master PLC and 1 Slave (for now), because I should make a program of a machine (master) that transfers and receives information from some slaves, for now they will be a couple then they will increase to about 10. I would need them though some clarifications to the doubts that have come to me and that I have not been able to clarify myself.
1) In the manual attached to the latest version of logiclab on the page dedicated to TCPDEXCHNODEDEFS, inputs and outputs are highlighted that in reality I could not find, for example, AutoTxD, TxHeartbeat, RxHeartbeat in the demonstration program. Despite trying to run it.
Also I find an inconsistency in the description of RxOk | BOOL | R | Rx data Ok. Set to receive data from the other system, the data has been transferred to RxBuffer. It must be reset by the user program.
Then below we read that
RW fields must be set by the user program, R fields must not be modified by the user program, they can only be read. since RxOk is part of the "R" group I don't understand if you need to reset it or not, if so how?
2) In the FB TCPDataExchClient there is a Heartbeat input variable, set to 5 (s) from what I understand is an automatism to send a packet to check the right connection? in any case I tried to change the value, if I try to put a value lower than 5 the TCPDEXCHNODEDEFS goes into error, 5 seconds is the minimum time?
3) Again in the manual on the page concerning TCPDataExchClient it does not report Heartbeat as if it were not there, but in reality it is present in the fb.
4) It is not clear to me how to manage a communication check, the only thing that came to my mind is to check the Active variable of TCPDEXCHNODEDEFS, in true when connection established and false when connection failed is correct? are there any other methods?
5) If the parameters to be passed to the PLCs were of different sizes (word, double word and real) how should I manage the data transfer to txbuffer. I should instantiate another FB TCPDataExchClient and TCPDEXCHNODEDEFS, but not having a done output I don't know.
For now I would say enough let's see if I have other doubts.
March 27, 2020 at 11: 27 am #54349Sergio BertanaAdministrator ForumThis library is evolving, now you can find the official documentation in the manual on the support site, see these articles (TCPDEXCHNODEDEFS, TCPDataExchServer, TCPDataExchClient). I suggest you copy and paste the examples shown, as you can see using the localhost you can test the operation by running both the server and the client (1 or more) on a single system.
The bit RxOk it does not need to be reset by program, in reality it activates for a program loop every time data is received.
The variable Heartbeat it is now defined in the configuration data structure.
The variable Active present in the configuration data structure if it is active it indicates that the connection between the systems is active.
I don't understand the question about data transmission, you need to define an area to send to the other system, then in that area you can put all kinds of data you want. In my example I used an array for simplicity, but in the real case it is better to use a data structure in order to group inhomogeneous data.
November 2, 2020 at 3: 10 pm #58097AndreaParticipantI noticed that when the system starts, the TCPserver does not always activate promptly, sometimes I have to force my hand by changing state to a bit several times, it almost seems that it does not read the bit state change in the client server, after the first start it does not I'm seeing other connection problems.
I solved it temporarily by creating a kind of communication control by creating a ping pong of bits to check the actual functioning of the library to prevent me from starting a machine without the other connected.
November 2, 2020 at 3: 15 pm #58115Sergio BertanaAdministrator ForumI don't understand what you mean by "TCPServer does not activate" have you tried to see the SysLog command from Telnet to see what errors it reports?
Are you using the examples copied and pasted from our Knowledge or do you have something different?
In our example, the FB instance TCPDataExchServer it is always active and manages 2 client connections and having activated the bit AutoTxD in the data structure it sends the data to the client automatically.
November 7, 2020 at 5: 24 pm #58173sacostParticipantHello, I'm trying to test the information exchange between multiple PLCs using the TCP client and server. I followed step by step what is indicated in the articles TCPDataExchServer and TCPDataExchClient on a single SlimLine MPS053B410, I added the eLLabDataExchLib and eLLabXTargetAdjLib libraries but client and server do not connect.
I logged into telnet (Using Toolly) on the SlimLine and with the netstat command I see that the server is up (listening on the configured port) the client tries to connect but then fails:
[Admin]> netstat Id Proto Local Address Foreign Address Status [00] UDP 0.0.0.0:9999 *.* [01] TCP 0.0.0.0:23 0.0.0.0:0 LISTENING [02] TCP 0.0.0.0:21 0.0.0.0:0 LISTENING [03] TCP 0.0.0.0:502 0.0.0.0:0 LISTENING [04] TCP 0.0.0.0:80 0.0.0.0:0 LISTENING [05] TCP 192.168.1.220:23 192.168.1.31:50414 ESTABLISHED [06] TCP 192.168.1.220:502 192.168.1.31:50356 ESTABLISHED [07] TCP 192.168.1.220:53280 127.0.0.1:10000 CONNECTING [08] TCP 0.0.0.0:10000 0.0.0.0:0 LISTENING
From the syslog I have the confirmation:
[E] SFR055 [06/11/2020 12:28:54] 6640, [7] IP:127.0.0.1:10000 [W] SFR055 [06/11/2020 12:28:54] 7720, eTCPClient connect error 15 [W] SFW184 [06/11/2020 12:28:58] 6000, User program error:9941140 [W] SFW184 [06/11/2020 12:29:28] 6000, User program error:9941140 [E] SFR055 [06/11/2020 12:29:33] 6640, [5] IP:127.0.0.1:10000 [W] SFR055 [06/11/2020 12:29:33] 7720, eTCPClient connect error 15 [W] SFW184 [06/11/2020 12:29:59] 6000, User program error:9941140
I tried to change the port, heartbeat time and ip address (putting the PLC address in the client: TCPClient.SAddress:=ADR(‘192.168.1.220’); instead of 127.0.0.1 among the configuration parameters but I always have the same result, what changes is the error message on syslog:
[W] SFR055 [06/11/2020 12:40:36] 7720, eTCPClient connect error 13 [W] SFW184 [06/11/2020 12:40:36] 6000, User program error:9941140 [W] SFR055 [06/11/2020 12:41:06] 7720, eTCPClient connect error 13 [W] SFW184 [06/11/2020 12:41:06] 6000, User program error:9941140
Here it appears that the connection is not even attempted.
Another curious thing that I noticed that despite being set to TRUE SpyOn (both on the server and on the client) by telnet I have:
[Admin]> spydata Spy data not active
I feel like I'm making some gross error, but I just can't see it. Could it be some library incompatibility problem?
November 7, 2020 at 5: 37 pm #58177Sergio BertanaAdministrator ForumI'm checking the two example programs taken from TCPDataExchServer and from TCPDataExchClient I am in smartworking and I don't have an MPS053 available, so I'm testing it on an MPS054 XUnified and I don't find any operating problems. On Monday I reserve the right to do a test on an MPS053. This is the result of the NetStat command on my system.
[Admin]> netstat Id Proto Local Address Foreign Address Status [00] UDP 0.0.0.0:9999 *.* [01] TCP 0.0.0.0:23 0.0.0.0:0 LISTENING [02] TCP 0.0.0.0:502 0.0.0.0:0 LISTENING [03] TCP 0.0.0.0:80 0.0.0.0:0 LISTENING [04] TCP 0.0.0.0:21 0.0.0.0:0 LISTENING [05] TCP 192.168.0.181:502 10.242.2.2:61462 ESTABLISHED [06] TCP 192.168.0.181:23 10.242.2.2:61815 ESTABLISHED [07] TCP 0.0.0.0:10000 0.0.0.0:0 LISTENING [08] TCP 127.0.0.1:52054 127.0.0.1:10000 ESTABLISHED [09] TCP 127.0.0.1:10000 127.0.0.1:52054 ESTABLISHED
As you can see there is an active connection between port 52054 of the client and port 10000 of the server and the server still has a port 10000 listening, because in the server program 2 connections are accepted TCPServer.Connections:=2;.
In your program, on the other hand, there seems to be a connection problem, but the oddity is also on the spying that is not active. Just a check did you run the two programs clien and server in task Back. Remember that all communication operations on sockets must be performed in the background.
November 9, 2020 at 9: 45 am #58179sacostParticipantYes, certainly both programs are in the back.
Is it possible / advisable to update MPS053 for XUnified libraries?
November 9, 2020 at 9: 52 am #58182Sergio BertanaAdministrator ForumI have revealed the mystery, on ARM7 systems the localhost "127.0.0.1" is not managed, that's why you can't test the program on a single system, which is feasible on systems based on CortexM7 like the MPS54 or the new compact module MPS056 which replaces the MPS053.
Regarding upgrading an ARM7 based system to XUnified here you will find the information to upgrade, I posted the new version of the operating system. It's worth upgrading if you need to take advantage of the new features.
-
AuthorPost
- You must be logged in to reply to this topic.