Author Topic: Modbus TCP: Button to clear several coils at once  (Read 1163 times)

ronj

  • Newbie
  • *
  • Posts: 10
    • View Profile
Modbus TCP: Button to clear several coils at once
« on: September 29, 2015, 08:42:57 AM »
Hi,
I have an application using Modbus TCP to control a VSD that has separate "coils" for forward and reverse operation. To stop, I need to clear both "coils". Is there a way for a single button to write the same value (in this case reset) to more than one "coil" address?

Regards,
Ron

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Modbus TCP: Button to clear several coils at once
« Reply #1 on: September 29, 2015, 08:49:33 AM »
You can do this with a little VB code.

- Add a Button to the form from the All Windows Forms group in the ToolBox
- Double click the button to get  back to the code
- Enter code similar to this:

ModbusTCPCom1.Write("40001","0")
ModbusTCPCom1.Write("40002","1")

ronj

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Modbus TCP: Button to clear several coils at once
« Reply #2 on: September 29, 2015, 09:25:29 AM »
Hi Archie,
Your suggestion works well - thanks.
I notice it also works in the click event of a PilotLight like this:

    Private Sub PilotLight4_Click(sender As Object, e As EventArgs) Handles PilotLight4.Click
        ModbusTCPCom1.Write("00001", "0")
        ModbusTCPCom1.Write("00002", "0")
    End Sub

Is there any problem with using a PilotLight like this?

Ron

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Modbus TCP: Button to clear several coils at once
« Reply #3 on: September 29, 2015, 09:51:29 AM »
You can use any of the controls. They all have the click event that works the same.