Author Topic: Need Modbus RTU slave driver  (Read 4409 times)

robkwan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Need Modbus RTU slave driver
« on: June 19, 2015, 02:16:07 PM »
AdvancedHMI newbie

I have an embedded controller connected to two Windows 7 HMIs on a single multidrop RS485 line.
The ModbusRTUCom component from AdvancedHMI is a master, it initiates the message transaction.

I need a Modbus RTU slave component on the two Windows 7 HMIs, i.e. they will listen only then reply. The embedded controller sends the request, the assigned slave ID (one of the two Windows 7 HMIs) replies.

I need direction how to implement the slave component.

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Need Modbus RTU slave driver
« Reply #1 on: June 19, 2015, 02:21:35 PM »
There currently is no Modbus slave driver for AdvancedHMI. Maybe you can find an OPC server that is a Modbus slave.

DougLyons

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Need Modbus RTU slave driver
« Reply #2 on: June 19, 2015, 09:44:22 PM »
You should be able to do this easily by just adding a Modbus Slave to your AHMI computer.
Here is one that I helped revise and it works well https://sourceforge.net/projects/modrssim2/.

Now when you set up AdvancedHMI use the normal Modbus with an IP address of the loopback (127.0.0.1).
When AdvancedHMI reads from the local Slave the values shown will be whatever has been placed there.
Now on the remote Masters write to the IP address of the AdvancedHMI computer.
Now the values you send will be stored in the Slave which will then be read by the AdvancedHMI master.

I have tested this and it worked for me. Good Luck!

Doug Lyons
« Last Edit: June 20, 2015, 07:30:01 PM by DougLyons »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Need Modbus RTU slave driver
« Reply #3 on: June 19, 2015, 10:00:52 PM »
That's a very clever solution that I never thought of. ModRSsim is a very good program that I use quite often for testing the AdvancedHMI Modbus drivers.

DougLyons

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Need Modbus RTU slave driver
« Reply #4 on: June 20, 2015, 12:17:26 AM »
My previous post was based on using Modbus TCP and I just noticed that this request was for an RTU slave driver.
To do this with the ModRSsim2 program you would have to use its Modbus RS-232 functionality.
The you could use com0com and hub4com from https://sourceforge.net/projects/com0com/.
Hub4com would be set up to have three virtual ports and the Windows hardware port is assumed to be COM1 here.

Now you would have to route from the COM1 port into the shared ModRSsim2 port(allows COM1 requests to get to ModRSsim2).
Next route from the AdvancedHMI to the ModRSsim2 port(allows AHMI requests to get to ModRSsim2).
Finally route from the ModRSsim2 port to both the AdvancedHMI and COM1 port(allows responses from ModRSsim2 to go to COM1 and AHMI).

I am not sure how "hub4com" will handle requests if they come rapidly because the message may get intermixed.
Probably a better option would be to use an Modbus RTU to/from Modbus TCP gateway.
There is one here https://sourceforge.net/projects/mbus/ but it is for Linux but might be portable to Windows.

I have not tested any of these suggestions but maybe they will give someone the idea of how this might be done.

Doug Lyons

robkwan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Need Modbus RTU slave driver
« Reply #5 on: June 22, 2015, 12:06:48 PM »
Let me clarify the OP. The OP was based on develop a Modbus RTU slave serial component, one that integrates with AdvancedHMI, like those on the AdvancedHMIDrivers toolbox. All the included drivers seem to be the ones to initial the transaction. I am uncertain if the driver class hierarchy is suitable to use for a driver that only listens and responds. Any comment on this?

The other option would be have a local array that is 1) updated by the HMI controls on changes and 2) updated by a thread that listens on the serial line. The thread (the slave) will also reply, getting the values from the local array.

The modrssim2 is another option.