Author Topic: Analogue Value Display can't read more than one id from modbustcp  (Read 753 times)

rizqiion224

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hi, so i was using separate driver with same ip addres, but different id, then i tried to read address from each driver at the same time, but what i got is no response from plc, or com error, is there any solution with multi unit id when using modbustcpcom?

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Analogue Value Display can't read more than one id from modbustcp
« Reply #1 on: August 05, 2020, 04:55:05 AM »
Having one AnalogValueDisplay control with its PLCAddressValue set to "40001" and a button which changes the single driver's UnitId with every click, this code was working with MODRSsim2 simulating 3 slaves:

Code: [Select]
    Private count As Integer = 1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        count += 1

        If count = 1 Then
            ModbusTCPCom1.UnitId = 1
        ElseIf count = 2 Then
            ModbusTCPCom1.UnitId = 2
        ElseIf count = 3 Then
            ModbusTCPCom1.UnitId = 3
            count = 0
        End If
    End Sub

You could try setting the driver's DisableSubscriptions to True before changing the UnitId, and then setting it to False like this:

Code: [Select]
    Private count As Integer = 1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        count += 1

        ModbusTCPCom1.DisableSubscriptions = True

        If count = 1 Then
            ModbusTCPCom1.UnitId = 1
        ElseIf count = 2 Then
            ModbusTCPCom1.UnitId = 2
        ElseIf count = 3 Then
            ModbusTCPCom1.UnitId = 3
            count = 0
        End If

        ModbusTCPCom1.DisableSubscriptions = False
    End Sub
« Last Edit: August 05, 2020, 04:58:55 AM by Godra »

rizqiion224

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Analogue Value Display can't read more than one id from modbustcp
« Reply #2 on: August 07, 2020, 01:50:46 AM »
It worked, but i change the click with timer tick every 1s, thanks mate