Jump to content

Modbus TCP/IP - V130 as a Master With two V130 as a Slave


Recommended Posts

Hi Joe

I looked at the example, the configuration of one controller and one Master everything works, with two Slave I can't communicate at the same time.

I'll opening another socket but I got Error 5 always.

Please, send me a Small procedure how to configurat the sockets.

my IP is:

Master: 192.168.127.10

Slave 1: 192.168.127.253

Slave 2: 192.168.127.254

thanks,

Nir

Link to comment
Share on other sites

Hi

I found the problem in my aplication, I had to put another box of Modbus configuration for the other socket.

But from what I understand there are limited number of concurrent controls parallel.....only 4 slaves.

Thank you all,

Nir

Only 4 active connections socket connections. That is correct.

Link to comment
Share on other sites

  • MVP 2023

You can absolutely use a single socket for many slaves. In the Modbus IP Config block you define the IP address and ID of each slave. In your Modbus read or write block you then use an MI instead of a constant to pick the index of the slave you want to communicate with. Or you can have multiple Modbus read/write blocks; just make sure you only call one at a time and check the overall Modbus IP status bit (defined in the Config block) to verify that it's not busy doing something else.

Nir is setting his up to have simulataneous conversations. You need a separate socket for each if you want to do that. You'll have to look at your application and decide what kind of response speed you need and determine if the "slower" response time of multiplexing a single socket is acceptable.

Joe T.

Link to comment
Share on other sites

  • MVP 2023

TIm-

Yeah, I forgot to mention the Connect/Close requirement. Which I should have remembered, because the first time I played with Modbus IP I didn't realize that the Connect is required and I treated it like regular Modbus. It drove me nuts untill I looked at the V280 Modbus IP Master example. I mentioned in another post that the Modbus IP Help needs to be updated to include this "minor" requirement.

Joe T.

Link to comment
Share on other sites

Just to put some numbers to this to give the OP a sense of timing.

Using a V570 (fastest CPU) and dedicating connections to a single slave each, I can perform a full read and write cycle to 4 slaves in on average 15ms. That is, I can read and write to all four slaves in under 12.5 to 20ms.

It peaks out at 20ms and occasionally I might get one 22.5ms cycle hear or there. Not deterministic of course.

Now as an example, and I decide to multiplex one socket and talk to all four slaves that way you will find that it takes about 100ms to establish the connection. And this is for each slave. Once you are connected you will want to do a read and a write before opening the socket again. Between that and the socket close that adds about another 15ms of overhead.

So all together you will end up around 450ms for a read write cycle to all slaves by multiplexing. So multiplexing in this example is slower by a factor of about 20 times!

So, be careful doing it that way. Most of my processess cannot handle that degree of latency.

They have developed FAST socket Open/Close FBs that are much faster, but they have not officially released them yet.

It is also possible to create a socket pinwheel, although the code gets quite complex. The theory behind it is you use three sockets or so. While you are talking to slave 1 with Socket 1, you start connecting to Slave 2 with Socket 2, then maybe slave 3 with socket 3, once Slave 1 is finished Socket 1 closes with Slave 1 and then connects with Slave 4 while you're still reading from Slave 2 on the other socket. Then Socket 2 closes and connects to slave 5. Etc. You get the picture. It helps mitigate the time wasted establishing the connection.

  • Upvote 1
Link to comment
Share on other sites

  • 5 years later...
  • 2 months later...
  • MVP 2023
40 minutes ago, Armando said:

The only way is multiplexing the slaves because there is one socket for modbus tcp/ip protocol.

You have 4 sockets available and you can initialize them to any of the available protocols. Simply initialize two of them to TCP Master, set up the port numbers correctly to match the slaves, and configure MODBUS for each. Be sure to check out the example projects for the recommended method to connect and transfer data and you should be good to go.

You only need to multiplex if you require more than 4 Ethernet connections.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...