Data Exchange between Siemens and Schneider via Modbus TCP
It has been a few years since the first article on Modbus TCP communication with a simulator was published, so I will not repeat all the steps, as that article can serve as a guide. This time the example will be more practical, as we will communicate a 1511 CPU with a Schneider PLC, using the PLC Simulator, which we have already seen supports communications, unlike SoMachine up to this point.
The documentation is easy to understand; however, if we need to highlight any parameter, we will do so, because what changes regarding the MB_CLIENT function is that in this version we need to create a variable of type TCON_IP_v4 for the CONNECT parameter, where the following information is included:
-ID: Must be unique and cannot be repeated.
-ConnectionType: For Modbus TCP communications, it must be 11.
-ActiveEstablished: We set it to 1 to establish the connection with the Server.
-ADDR: We define the Server's IP address, and by default, RemotePort is 502.
The function we use is MB_CLIENT, just like before; here we have an image of the two versions.
And here is the Instance DB where we have all the information, and if we observe the Array, in the first 10 records starting from 1, we have the values we read from the Schneider PLC.
Here we see that there is a connection that the simulator does not specify the name for, but which corresponds to the 1511 CPU, with IP address 192.168.1.100, and we see how we have read the value of these variables.
However, if we now change MB_MODE to 116, it is the function to write Holding Register; we are going to write to the Schneider PLC TSX 57.
And once the REQ is executed, we observe how we have written the variables.
This information belongs to the help of the function and the allowed values for the MB_MODE parameter depending on what we are interested in (READ - WRITE HOLDING REGISTERS)
09-05-2019