Author Topic: Poll multiple stations from one COM port  (Read 2061 times)

ristabr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Poll multiple stations from one COM port
« on: June 25, 2016, 02:53:31 PM »
Hello,

this is my first post.
I started with one project where I have to read 50 custom modbus slave devices, each having numbers from 1 to 50. I need only one register value from device (40001). Devices are connected over RS485 network, speed is 9600. I must poll all devices in 1-2 seconds time.
I try with multiple com port driver instances with same com port number but different station numbers and failed.
I think normally this should be done with one driver but how to change station number after each poll?

Can someone please give me advice or sample code how to do that?
Thank you.

Ivan Ristic.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Poll multiple stations from one COM port
« Reply #1 on: June 25, 2016, 04:18:09 PM »
You would use a driver instance for each device. What version of AdvancedHMI are you using?

ristabr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Poll multiple stations from one COM port
« Reply #2 on: June 26, 2016, 05:06:25 AM »
Thank you for help.

I use version 399k of AHMI and Visual Studio 2013.
When I put two instances of ModbusRTUCom driver and set same port number, speed but next station number, polling is not continuous like before.
I read on this post that Mr. Shriram Pendse done same thing with one port instance.
      http://www.plctalk.net/qanda/showpost.php?p=605398&postcount=4

Thanks one more time for helping me.

ShriramPendse

  • Newbie
  • *
  • Posts: 24
  • " AUTOMATION " simplified .
    • View Profile
Re: Poll multiple stations from one COM port
« Reply #3 on: June 27, 2016, 05:44:48 AM »
In one of my applications , ADVhmi talks to 8 controllers on serial Modbus .
I never connect controls on screen to PLC registers , rather use timed read function from drivers to read and write data .

  response = {0}
        ModbusRTUCom1.StationAddress = NumericUpDown1.Value
        Try
            response = ModbusRTUCom1.Read("400001", 63)
' move response array data to controller data array
        Catch ex As Exception
        End Try
'  now change NumericUpDown1.Value to next controllers node address


 response = {0}
        ModbusRTUCom1.StationAddress = NumericUpDown1.Value
        Try
            response = ModbusRTUCom1.Read("400001", 63)
' move response array data to netx controller data array
        Catch ex As Exception
        End Try

' and so on .


Godra

  • Hero Member
  • *****
  • Posts: 1446
    • View Profile
Re: Poll multiple stations from one COM port
« Reply #4 on: June 27, 2016, 09:16:43 AM »
Shriram,

Your code could be placed in the loop but Archie would have to say whether it would work properly (I am not sure if the driver would buffer all these requests and provide proper reply to each).