Author Topic: One HMI & Two PLC’s simultaneously on MODBUS TCP  (Read 2118 times)

peterjung

  • Newbie
  • *
  • Posts: 15
    • View Profile
One HMI & Two PLC’s simultaneously on MODBUS TCP
« on: February 08, 2016, 10:47:04 PM »
Can anyone please advise if it is possible to have a single control (PB, etc.) from a single HMI that can write to the same address in two different PLC’s (different IP addresses) simultaneously?

In addition can I have two display controllers (i.e. digital panel meter) display values from each PLC simultaneously on the same HMI?

I am using MODBUS TCP comms.

Thanks in advance!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: One HMI & Two PLC’s simultaneously on MODBUS TCP
« Reply #1 on: February 09, 2016, 04:02:48 AM »
For a single button to write to 2 PLCs you would need to do it in code instead of using PLCAddressClick. For example:

- Add 2 drivers to the form and set the IP address of each driver for it's corresponding PLC
- Add a Button to the form
- Double click the button to get back to the code
- Add code like this:
ModbusTCPCom1.Write("40001",1)
ModbusTCPCom2.Write("40001",1)


To make different panel meters get its data from different PLCs, just set the ComComponent property to the driver instance you want it to use.

peterjung

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: One HMI & Two PLC’s simultaneously on MODBUS TCP
« Reply #2 on: February 09, 2016, 08:09:58 AM »
Archie

OK, thanks for the pointers.  Not too up with VB but I will give it a shot.

Thanks again!

peterjung

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: One HMI & Two PLC’s simultaneously on MODBUS TCP
« Reply #3 on: February 11, 2016, 01:55:41 AM »
Hi Archie

I got this to work after a bit of messing around:

Private Sub MomentaryButton1_Click(sender As Object, e As EventArgs) Handles MomentaryButton1.Click

        ModbusTCPCom1.Write("01025", 1)
        ModbusTCPCom2.Write("01025", 1)
        Delay(3)
        ModbusTCPCom1.Write("01025", 0)
        ModbusTCPCom2.Write("01025", 0)

    End Sub


As I wanted it to act like a pulse I added the Delay and writing to zero.  For the Delay I found a useful bit of code to make a wait function on Youtube at:

https://www.youtube.com/watch?v=JnYm1jBgRbI

Sub Delay(ByVal dblSecs As Double)

Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
Dim dblWaitTil As Date
Now.AddSeconds(OneSec)
dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
Do Until Now > dblWaitTil
Application.DoEvents() ' Allow windows messages to be processed
Loop

End Sub


Seems to work ok!

Thanks again for your help!