Menu

VB.net Implementation

Anonymous
2020-07-21
2020-08-11
  • Anonymous

    Anonymous - 2020-07-21

    Hi,

    I am trying to use your DLL in a VB.net application to read and write via modbus to a Schnieder distributed IO device. I have used your sample modbusTCP client app and it successfully returns the input status by reading the holding registers. I call the ReadHoldingRegisters function (modbusclient.ReadHoldingRegisters(5392, 16) in this instance to read address 45392 which is a 16 input module) and I only ever get back an array of all 0s.

    My test code is as follows:

    Public Class Form1
    Public Shared modbusclient As New EasyModbus.ModbusClient("192.168.1.101", 502)

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        modbusclient.Connect()
        System.Threading.Thread.Sleep(1000)
    
        If (modbusclient.Connected = True) Then
            Dim Inputs(15) As Integer
            Array.Copy(modbusclient.ReadHoldingRegisters(5392, 16), Inputs, 16)
            modbusclient.Disconnect()
            TextBox1.Text = Inputs(0)
        End If
    
    End Sub
    

    End Class

    When I trigger this via a push button on the form and setup a breakpoint after that line, the array shows as all 0's when the LSB (first) bit should be 1 as the input is switched on.

    Any ideas?
    Do you have sample VB code using this library for reference?

     
    • Rossmann Engineering

      Hi I don't fully understand your code. But you definitelly have to check the mapping of your device, that has to match with your Modbus reading. It sounds to me that your trying to read a Holding Register to determine the state of a digital input, or did I missunderstand something?

       

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.