Author Topic: Doing math in HMI / Internal Tags  (Read 1632 times)

Izzo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Doing math in HMI / Internal Tags
« on: January 09, 2017, 04:01:56 PM »
I started trying to create a simple andon type display with rate, count, and goal.  I was able to display my values from the PLC with no problem.  I want the font color of the count to change based on the percentage it is from the goal.  I tried to enter the expression in the limit property of the analog display with no luck.  Do I need to create an internal tag, do the math and then reference that?  Another feature I wanted was for the supervisor to be able to input a text message to the operators.  This message would in no way be part of the PLC.  The message box displayed an error without a PLC tag.  Lastly, is there a way draw lines and basic shapes.

Thanks

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Doing math in HMI / Internal Tags
« Reply #1 on: January 09, 2017, 05:46:52 PM »
Can you post a picture of your HMI screen just to see what controls you are using?

Sending a message to all operators through AHMI sounds like a tricky thing to do.
The message would have to be somehow broadcast to all computers or stored in some central location and then updated on the operators screens. Maybe OPC server might do something like that or Archie might invent some other way.
Here is a link to something similar which requires Messenger service running on all those computers:

https://technet.microsoft.com/en-us/library/bb490710.aspx

and another link:

http://stackoverflow.com/questions/7196262/how-do-i-send-messages-from-one-computer-to-another-using-vb-net


For lines and basic shapes, there are some AHMI controls available in this forum in the "Additional Components" category.
You can draw these through the code as well or just find and download VB PowerPacks compatible with the version of Visual Studio that you are using.
« Last Edit: January 09, 2017, 06:06:35 PM by Godra »

Izzo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Doing math in HMI / Internal Tags
« Reply #2 on: January 10, 2017, 07:46:25 AM »
Sorry, I explained that poorly.  The message only has to be displayed on the HMI, but can be input by the supervisor through a keyboard.  Some of our PLCs do not handle strings well so I would like the content of the message to reside in the HMI program.  Same thing with the math, I think it should be easier to do on the HMI PC vs. the PLC.  I want something similar to the attached images.

Thanks

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Doing math in HMI / Internal Tags
« Reply #3 on: January 10, 2017, 10:22:00 AM »
The latest AHMI release v3.99t has a SevenSegment2 control which can show numbers in 3 different colors (below limit, within limits and above limit).

For Messaging, I would suggest you check that second link posted in my previous post.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: Doing math in HMI / Internal Tags
« Reply #4 on: January 10, 2017, 11:02:01 AM »
Expressions cannot be put in the property fields directly. It is actually easier to do the calculation in the PLC. However with a little bit a coding, you can do calculations from multiple tags. The DataSubscriber2 can be used for this. For example, let's say you want to add MyTag1 and MyTag2 and put it in the ValueLimitUpper property of an AnalogValueDisplay:

- Add an AnalogValueDisplay to the form
- Add a DataSubscriber2 to the form
- In the properties windows, click in the PLCAddressItems property, then click the ellipsis (3 dots) button to open the Collection Editor Window
- Click the Add button and for the PLCAdress enter MyTag1
- Click the Add button again and enter MyTag2 for the PLCAddress
- Click OK to close the window
- Double click the DataSubscriber2 in the component tray. This will take you to the code view
- Enter this code:
Code: [Select]
    Private Sub DataSubscriber21_DataChanged_1(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged
        Try
            AnalogValueDisplay1.ValueLimitUpper = DataSubscriber21.PLCAddressValueItems(0).LastValue + DataSubscriber21.PLCAddressValueItems(1).LastValue
        Catch ex As Exception
        End Try
    End Sub