Author Topic: Polling Registers ModbusTCP 3.99a  (Read 1861 times)

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Polling Registers ModbusTCP 3.99a
« on: November 17, 2015, 09:45:48 PM »
Archie, I would like to know if its possible to poll a different number of registers on each form with the ModbusTCP driver with each read.  For instance, my project has two forms both polling the same device.  Page1 can block read multiple register at a time.  However the address range for the second page only allows polling one register at a time or else I get an error from the device.  The second page consist of 60 BasicLabels.  Can this be done?...I fear the answer is no since the code is in ModbusBase, is it realistic to add 60 ModbusTCP drivers to the form and assign it to each BasicLabel? What line is this in ModbusBase?  Thank you!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: Polling Registers ModbusTCP 3.99a
« Reply #1 on: November 17, 2015, 10:44:50 PM »
What is the error you are getting? There must be some kind of limitation with the device. You can go to line 532 in ModbusBase.vb and experiment with the group size by changing the value of 20 in this code:
Code: [Select]
                    While (index + ItemCountToGroup + 1) < SubscriptionList.Count AndAlso _
                        SubscriptionList(index + ItemCountToGroup).Address.ReadFunctionCode = SubscriptionList(index + ItemCountToGroup + 1).Address.ReadFunctionCode AndAlso _
                        SubscriptionList(index + ItemCountToGroup).Address.BitsPerElement = SubscriptionList(index + ItemCountToGroup + 1).Address.BitsPerElement AndAlso _
                        ((SubscriptionList(index + ItemCountToGroup + 1).Address.Element + SubscriptionList(index + ItemCountToGroup + 1).Address.NumberOfElements) - SubscriptionList(index).Address.Element) < 20 AndAlso
                        SubscriptionList(index + ItemCountToGroup).Address.Address.Substring(0, 1).ToUpper = SubscriptionList(index + ItemCountToGroup + 1).Address.Address.Substring(0, 1).ToUpper

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Polling Registers ModbusTCP 3.99a
« Reply #2 on: November 17, 2015, 11:19:12 PM »
Yes it is an intentional limitation of the device to prevent from access to more than 1 RW register at a time.  The "read only" can be block read with no problems. Is it possible to change the # of registers read at a time for each form?  Thx

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: Polling Registers ModbusTCP 3.99a
« Reply #3 on: November 18, 2015, 12:16:27 AM »
You can create a new property by adding this code to ModbusBase.vb :
Code: [Select]
    Private m_MaxReadGroupSize As Integer = 20
    Public Property MaxReadGroupSize As Integer
        Get
            Return m_MaxReadGroupSize
        End Get
        Set(value As Integer)
            m_MaxReadGroupSize = value
        End Set
    End Property

Then change the value of 20 from the previous post to m_MaxReadGroupSize

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Polling Registers ModbusTCP 3.99a
« Reply #4 on: November 18, 2015, 12:45:42 AM »
Awesome!  I will give this a try and let you know.  Thanks