News:

  • August 14, 2026, 11:47:56 PM

Login with username, password and session length

Author Topic: Modbus Question  (Read 13080 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Modbus Question
« on: September 26, 2019, 10:35:46 AM »
When you do an MWX or MRX, does it close the connection immediately after the instruction success? Is there a status bit to know when the connection is closed?

 
« Last Edit: September 26, 2019, 10:38:14 AM by ATU »

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: Modbus Question
« Reply #1 on: September 26, 2019, 10:44:02 AM »
I assume you mean MODBUS over TCP.  If so, no the connection does not get closed immediately, it waits for a period of time to see if more communications will be sent.  There is however a maximum number of TCP connections that can be kept open at one time.  If a new connection is formed when at limit, the oldest connection will be closed. 

AFAIK, there isn't a connection closed status.
« Last Edit: September 26, 2019, 10:45:37 AM by ADC Product Engineer »

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Modbus Question
« Reply #2 on: September 26, 2019, 10:53:47 AM »
Yes Modbus over TCP. My HMI also has a limited number of connections. I have 4 BRX CPU's writing to the same MB Address and Port.  Using Peerlink bits to coordinate who gets to write. Before I give permission, I would like to know when each BRX has completed its transmission and the port is closed. If I pull up a Device Status window, I see an OPEN/CLOSED status for the State. I would really like to have that status bit available.

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: Modbus Question
« Reply #3 on: September 26, 2019, 11:04:12 AM »
Servers typically control the number of connections.  There really isn't a method for the client to know that it has been closed.  You would need to track this manually.

Peerlink has some structures to show when data has been updated.  Se DMD0300 in the software help file for a list.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Modbus Question
« Reply #4 on: September 26, 2019, 11:07:15 AM »
I don't think that is available for the Modbus/TCP Client.  However, you can programmatically force the Modbus/TCP client device to close its connection with a specific slave by performing an MRX/MWX to another slave.

Have a Stage program that does all the normal read/writes to the HMI, then JMP to a SG that does an MRX back to yourself (the PLC).  This will close the TCP connection to the HMI.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Modbus Question
« Reply #5 on: September 26, 2019, 11:09:52 AM »
I will try that, thanks.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Modbus Question
« Reply #6 on: September 26, 2019, 11:32:11 AM »
I will try that, thanks.

It's a hack, but in one way, it lets you control the "timeout".  If it was 60 seconds, that non-existent bit would remain ON for 60 seconds.  Now, you can control the connection to disconnect immediately. programmatically, from the HMI.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Modbus Question
« Reply #7 on: September 26, 2019, 01:29:33 PM »
if you use 1 device driver  in the BRX to communicate with the HMI but on 2 different ports, say 502 and 503. When you execute an MWX on 502 to the HMI and then run another MWX to 503,  does it close the connection with 502 immediately?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Modbus Question
« Reply #8 on: September 26, 2019, 01:42:05 PM »
I don't know.  I would guess yes, for the same reason why if the IP Address was different, it would close the TCP connection on the first.