Author Topic: Sum PLC Tag Values in AHMI  (Read 545 times)

Rangers

  • Newbie
  • *
  • Posts: 2
    • View Profile
Sum PLC Tag Values in AHMI
« on: October 27, 2020, 12:03:49 PM »
I would like to find the sum of tags in eight different PLCs and display the result using AHMI.  Each PLC has a daily output value that I would like to sum with the value of the remaining machines and display as "Line Output".  I am using 8 individual drivers to communicate to each PLC and display miscellaneous data for production using basic labels.  I have minimal experience with Visual Studio and have not been able to figure it out on my own.  Any help would be much appreciated. 

I know how to do this on the PLC side, but would rather accomplish it using AHMI, if possible.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5290
    • View Profile
    • AdvancedHMI
Re: Sum PLC Tag Values in AHMI
« Reply #1 on: October 27, 2020, 01:44:00 PM »
One way to do this is the handle the ValueChanged Event for each BasicLabel. In that event add all the values and put it in another Label.

Similar to this:
Code: [Select]
    Private Sub BasicLabel3_ValueChanged(sender As Object, e As EventArgs) Handles BasicLabel1.ValueChanged, BasicLabel2.ValueChanged, BasicLabel3.ValueChanged
        Try
            Dim Sum As Integer = CInt(BasicLabel1.Value) + CInt(BasicLabel2.Value) + CInt(BasicLabel3.Value)
            Label1.Text = Sum
        Catch ex As Exception

        End Try
    End Sub

Rangers

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Sum PLC Tag Values in AHMI
« Reply #2 on: October 28, 2020, 09:25:27 AM »
Archie,

This worked exactly how I wanted.  I ended up using this logic with a Timer to execute the code periodically since a machine cycle time takes several minutes.  Thanks again for the help.