Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Slowpaddle

Pages: [1]
1
I did that and it works fine. I thought disabling the subscriptions meant disconnecting altogether.

Anyway, thanks for the help.

2
Overview: I have an ESP-01 programmed using the ModbusIP_ESP8266.h library. The AHMI can read and write the registers without issue. I am using 12 basic buttons to set the register bits and 12 pilot lamps to give register state feedback. But there is something that's confusing me about the connection.

I have two buttons that Enable and Disable the ModbusTCPCom1 connection.

Enable = ModbusTCPCom1.DisableSubscriptions = False
Disable = ModbusTCPCom1.DisableSubscriptions = True

Oddly though, after I disable the subscriptions the program is still able to communicate with the external device when I use the basic buttons to change register values. The pilot lamps however do not respond to the changes.

Can anyone here explain why this happens?

I hope I gave enough detail. If not I can give more. Thanks.

3
Support Questions / Re: ModbusTCP : Unable to write to a register
« on: September 15, 2021, 08:35:36 PM »
Just to add, I am using V3.99v if that helps.

Tried this as well to see if an error was thrown. Alas, nothing.

Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            ModbusTCPCom1.Write("40003", 2)
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show("Couldn't write to PLC. Error: " & ex.Message)
        End Try
    End Sub

4
Support Questions / ModbusTCP : Unable to write to a register
« on: September 15, 2021, 07:38:49 PM »
This is my first post so forgive me if I mess this up.

I am using ModbusTCP to communicate with an Arduino via Ethernet using mudbus.h. (The correct spelling) I can read and write bit values and read register values without any issues. But for some reason I cannot write data to a register.

I would like to read a text file and send the values to two registers when the program starts. These values represent offset values for two TOF sensors connected to the Arduino.

I am hoping to be able to use them to line up my two Y Axis stepper motor positions on my CNC gantry and use the offsets to allow for any mounting errors.

Code: [Select]
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        If My.Computer.FileSystem.FileExists("C:\axis_offsets.txt") Then

            Dim reader As New System.IO.StreamReader("C:\axis_offsets.txt")

            Dim MyValue1, MyValue2 As String

            MyValue1 = reader.ReadLine()
            Dim CurrentValueInt1 As Integer = CInt(MyValue1)

            MyValue2 = reader.ReadLine()
            Dim CurrentValueInt2 As Integer = CInt(MyValue2)

            reader.Close()

            ModbusTCPCom1.Write("40003", CurrentValueInt1)
            ModbusTCPCom1.Write("40004", CurrentValueInt2)

        Else
            Dim writer As New System.IO.StreamWriter("C:\axis_offsets.txt", False)
            writer.WriteLine(0)
            writer.WriteLine(0)
            writer.Close()
        End If
    End Sub

This button click code will not work either.

Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ModbusTCPCom1.Write("40003", 2)
        ModbusTCPCom1.Write("40004", 2)
    End Sub

If I could figure out a way to use an ESP8266 with AHMI, I'd give it a go. Save me the problem of storing offsets on my computer and saving them on the ESP8266.

I'm a recently retired Industrial Electrician (Canada) so maybe I'm just getting old and missed something simple?

Thank you for any help one of you can provide. It would be deeply appreciated.

Pages: [1]