News:

  • May 05, 2026, 07:02:28 AM

Login with username, password and session length

Author Topic: Modbus/TCP Server Configuration  (Read 16563 times)

Gummi Ben

  • Jr. Member
  • **
  • Posts: 18
Modbus/TCP Server Configuration
« on: May 27, 2013, 12:18:06 PM »
Hi, I'm constructing a project with Do-more CPU that connects to a remote I/O via Modbus.  I'm using the onboard ethernet plug to connect to the I/O through ethernet switch.  I saw in the help that the limit is 16 concurrent Modbus/TCP Server connections.  I was wondering what this means?  Can I only talk to 16 different devices ? Can I talk to more devices if I don't execute more than 16 MRX and MWX at the same time ?


Best regards
Guğmundur Ben

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Modbus/TCP Server Configuration
« Reply #1 on: May 27, 2013, 12:35:31 PM »
That is referring to the Modbus/TCP Server (Slave)...the end of the conversation that listens and responds to requests, and is specifying how many concurrent connections it supports. The Modbus/TCP Client (Master) is the end that does the requesting. There is no (practical) limit to those.

For best efficiency, consider creating one "Modbus TCP Client" device per remote device that you want to talk to. If the requests are very slow and infrequent, you can get away with using the built-in client device @IntModTCPClient to talk to more than one remote device...but I personally wouldn't. It's a little more work to set up clients for each, but I think the benefits outweigh the cost.

You can create additional Modbus TCP Client devices by selecting the "New Device" button on the Device Configuration page of the System Configuration.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Gummi Ben

  • Jr. Member
  • **
  • Posts: 18
Re: Modbus/TCP Server Configuration
« Reply #2 on: May 28, 2013, 05:26:56 AM »
Thanks BobO for your quick reply.  So if I wanted to read values from 20 different modbus devices, each with special IP-address, I could do that by setting up special modbus client per address.  In other words I could set upp 20 rungs that execute a MRX instruction without breaking any limits ?

Best regards
Guğmundur Ben

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Modbus/TCP Server Configuration
« Reply #3 on: May 28, 2013, 07:09:31 AM »
Yes,
Set up a device for each one in system configuration.
Reference each one with a MRX/MWX, preferably using Stage programming so that each instruction can complete without being terminated.
Write your program so that you limit the system to only having 16 of the connections open at once.
After you are finished communicating with a device use CLOSE to free up the system resources, so that you can open more connections.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
No need to use CLOSE instruction w/MRX/MWX
« Reply #4 on: May 28, 2013, 07:20:05 AM »
After you are finished communicating with a device use CLOSE to free up the system resources, so that you can open more connections.
No need to use CLOSE with MRX/MWX.  CLOSE is useful when doing custom TCP via OPENTCP or TCPLISTEN.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Modbus/TCP Server Configuration
« Reply #5 on: May 28, 2013, 08:40:18 AM »
Set up a device for each one in system configuration.
Reference each one with a MRX/MWX, preferably using Stage programming so that each instruction can complete without being terminated.

Depends. In many cases this will be true...well, the termination requirement is always true...but MRX/MXW/DLRX/DLWX all can be used from $Main with any additional code for enabling or interlocking if all you need to do is read or write recurrently.

Quote
Write your program so that you limit the system to only having 16 of the connections open at once.

This is not necessary or beneficial. The only 16 limit is related to the server side, not client, and even for the server there is no programming required or even possible.

Quote
After you are finished communicating with a device use CLOSE to free up the system resources, so that you can open more connections.

Not required.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Modbus/TCP Server Configuration
« Reply #6 on: May 28, 2013, 09:32:37 AM »
Sounds like I need to shut-up ;D

You guys are making things way to simple!
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Modbus/TCP Server Configuration
« Reply #7 on: May 28, 2013, 11:49:34 AM »
Sounds like I need to shut-up ;D

Nah. Just don't get offended if we set the record straight. You have done lots of work with custom protocols, but the rules for standard stuff like Modbus are greatly simplified...since we can. For custom stuff it will always be a bit more complicated because it must be more flexible.

You guys are making things way to simple!

Throughout my 25 years of making automation products, the single biggest design challenge I have consistently faced is in balancing flexibility against simplicity. Almost anybody can make a powerful product, fewer can make a simple product, and fewer still can balance the two. It looks good for Do-more so far, although some would argue that there is a learning curve for it, but only time will tell how effectively we struck the balance. Personally I would rather apologize for a moderate learning curve and virtually no forward limits, than to constantly defend the walls people hit by saying "...but it's easy to use!" In truth, 'easy' should be evaluated in terms of how well the job finished...not how well it started.

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Modbus/TCP Server Configuration
« Reply #8 on: May 28, 2013, 12:42:18 PM »
Exactly.  I'd rather pay the learning curve once, provided the mfgr did what they could to ease it as much as possible, then be more productive forever.

I want the software to empower me, vs. doing the work for me.

IOW, all that stuff you said, BobO!   ;D
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Modbus/TCP Server Configuration
« Reply #9 on: May 28, 2013, 12:57:17 PM »
No offense Bob, I try to give back a little of what has been given to me on the forums, and sometimes get my foot in my mouth... But always learn something :)
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com