Author Topic: HMI Command To PLC #2 Based on Signal From PLC #1  (Read 5967 times)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
HMI Command To PLC #2 Based on Signal From PLC #1
« on: September 23, 2015, 08:33:18 PM »
I am experimenting & trying to find the limits/possibilities of AdvancedHMI. I have a test setup of 2 computers & a tablet running A-HMI connected to 4 PLC's: SLC5/05 over Ethernet, SLC5/04 with NetENI over Ethernet (Which message between themselves) and 2) SLC5/03's connected through Ethernet COM ports.

A-HMI reads & controls all 4 PLC's OK.
 
Is there any way that A-HMI can receive a signal from the 5/05 on one Ethernet driver (the main PLC in this test set-up) and command the COM based PLC's through the 2 DF-1 drivers?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #1 on: September 23, 2015, 09:28:53 PM »
Do you mean something like a communication bridge where a bit/value in 1 PLC would get relayed over to a bit/value in another PLC through AdvancedHMI?

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #2 on: September 23, 2015, 09:53:37 PM »
Yes, If A-HMI see's a bit ON (or OFF) from the 5/05, I want to send a click-bit automatically to either of the 5/03 PLC's over a DF-1 driver, which the 5/05 can't message to. Is this possible? If so, what about moving an analog value from the 5/05 to a 5/03?

Everything I've seen on the objects you can only select one communications driver, so I was wondering if one object for a DF-1 driver can look at the status of another object for the Ethernet driver.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #3 on: September 23, 2015, 10:11:10 PM »
I would do this with a DataSubscriber

- Add a DataSubscriber to the form
- Set the ComComponent to the source PLC
- Set PLCAddressValue to the source register
- Double click the DataSubscriber to get to the DataChanged event handler
- Enter this code:

DF1Com1.Write("B3/0",e.values(0))

The DF1Com1 would be the driver pointing to the target PLC and B3/0 would be changed to the target register.
« Last Edit: September 23, 2015, 10:14:18 PM by Archie »

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #4 on: September 23, 2015, 11:18:55 PM »
Archie,

Thanks. I'll try that tomorrow, if I don't hit the Powerball tonight (so I'm 105% sure I'll be doing it tomorrow).

abslcplc

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #5 on: September 24, 2015, 09:26:27 PM »
Archie, (sending this from my day jobs account)

Did I put the line in the correct area? Or do I replace all the email coding with this line? I only have one DataSubsciber so I don't know why the code has two listed.

Tried it as shown here & when the screen comes up VS crashes with an error pop-up wanting to quit the program.

+ Private Sub DataSubscriber1_DataChanged_1(sender As Object, e As Drivers.Common.PlcComEventArgs)
       
+  Private Sub DataSubscriber2_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs)
       
-    Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        DF1Com5.Write("B13:1/15", e.Values(0))
    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #6 on: September 24, 2015, 09:32:45 PM »
That looks correct, but lets put some error traps:


Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
  Try
        DF1Com5.Write("B13:1/15", e.Values(0))
  Catch ex as exception
       MsgBox(ex.message)
  End Try
End Sub

abslcplc

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #7 on: September 24, 2015, 09:47:47 PM »
Now it doesn't crash, but I get a pop-up that the "Input String was not in a correct format."

I can close the pop-up & continue but the 5/05's status is not making it to the 5/03 - and I am communicating with both PLC's on the same screen, showing valid status & values from both.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #8 on: September 24, 2015, 11:15:59 PM »
I'm guessing it doesn't like something about e.values(0)

Change the message to this

msgbox(ex.message & "-" & e.values(0))

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #9 on: September 25, 2015, 09:06:49 PM »
Archie,

Now it pops-up "Input String was not in a correct format-True"

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #10 on: September 25, 2015, 09:25:37 PM »
So now this should take care of it
Code: [Select]
Try
   if e.values(0)="True" then
        DF1Com5.Write("B13:1/15", 1)
   else
        DF1Com5.Write("B13:1/15", 0)
   end if
  Catch ex as exception
       MsgBox(ex.message)
  End Try

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #11 on: September 25, 2015, 09:46:15 PM »
Archie,

Works great!

Now I just hope I don't get carried away & put 20 -30 DataSubscriptions in, already got 20 integers & 32 bits being messaged through the Ethernet between the 5/05 & the 5/04 - hope I can keep the controls to the 5/03's to a respectable number.

EDIT: Plus I found I have to have each DataSubscription on every screen, or if I'm on a screen that doesn't have one the bit on the 5/03 stays at it's last state (ON & won't turn off) until I get back to a screen that has the D.S.
« Last Edit: September 25, 2015, 09:50:41 PM by AabeckControls »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #12 on: September 25, 2015, 09:51:30 PM »
In order to make it more efficient, I would write the complete B13 word instead of individual bits. For example, subscribe to the word in the source PLC, then write to B13:1. Then the target PLC would get all 16 bits in a single write.

If you do that, then first code sample I posted would work. I put in a fix for the next version that will also let the first code sample work when writing to a bit.

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #13 on: September 25, 2015, 10:23:22 PM »
Archie, 

Now I got a headache  - I went through & pasted the DataSubscription on every screen, then pasted the code above into every screen;s code. Did a rebuild & got errors for every page I didn't have the DF1Com5 driver already on.

Then when I tried to reopen MainForm to copy the DF1 driver it showed the exception screen & when I clicked Ignore the screen appeared with no FormChangeButtons - and Visual Studio crashed (twice.)

When I restarted VS & reopened the project if I didn't close the screen that opened automatically VS would crash. Now I can keep VS open, but every screen has no FormChangeButtons - with the error "The variable FormChangeButton__ is either undeclared or was never assigned.

FormChangeButton.vb is listed in the solution window, but not the Toolbox anymore. Tried Adding an Existing component & adding it from the original download folder, but it just overwrote the one in the Solution window.

Going to overwrite the project with a networked archive from a couple days ago & restart this.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: HMI Command To PLC #2 Based on Signal From PLC #1
« Reply #14 on: September 25, 2015, 10:26:43 PM »
When VS gets quirky, the first thing to do is close VS, then delete these folders:

\AdvancedHMI\bin
\AdvancedHMI\obj
\AdvancedHMIControls\bin
\AdvancedHMIControls\obj
\AdvancedHMIDrivers\bin
\AdvancedHMIDrivers\obj

If your PC is setup to show hidden file, then also delete AdvancedHMI.sou

After doing that, open the solution and perform a Rebuild All.

A note of caution, never do a Rebuild All if you have a form open in design view.