Author Topic: Message Display by Value question  (Read 4683 times)

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Message Display by Value question
« on: April 02, 2018, 02:45:58 PM »
I am new to both advanced HMI and VB. I am confused with how to use Message Display by Value.
1,Is that thing only support analog input? When I use Digital input, it appears invalid return.
2,In some cases, I need use several PLC address as input. But most components are only support one PLC address input. How can I input several PLC program to control like basic indicator?


Thanks for your reply!

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #1 on: April 02, 2018, 02:58:58 PM »
For 2, are you referring to expressions when you say several PLC program to control basic indicator?  For example, if TagA & TagB & NOT TagC then green light, if not then red light?  If that's what you are after then no, AHMI doesn't allow expressions.  You will need to write your own code to do that, which is easy enough.  It just can't be done in the PLC address property.  If that's not what you meant, maybe explain in better detail.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Display by Value question
« Reply #2 on: April 02, 2018, 03:02:22 PM »
1-Is that thing only support analog input? When I use Digital input, it appears invalid return.
When you say analog input, I will assume you mean an integer value. Any control with the PLCAddressKeypad property will accept numeric input, such as the BasicLabel. Put a valid PLC address in that property, then when you run the application, you can click the control to get a pop up keypad.

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #3 on: April 02, 2018, 03:06:52 PM »
Thank you for your reply!

What I want is that when coil1&coil2 are 1, the indicator becomes red. When both are 0, it becomes green. I am not familiar with VB program. And when I want to read detailed code of AHMI, I found it is private. So I cannot follow the programmed programs.

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #4 on: April 02, 2018, 03:21:51 PM »
1-Is that thing only support analog input? When I use Digital input, it appears invalid return.
When you say analog input, I will assume you mean an integer value. Any control with the PLCAddressKeypad property will accept numeric input, such as the BasicLabel. Put a valid PLC address in that property, then when you run the application, you can click the control to get a pop up keypad.

Yes. When I use X0(in my PLC is 12049) as input, the message shows invalid return! True(False). That's why I ask this Message display by value component only take the analog input.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Display by Value question
« Reply #5 on: April 02, 2018, 04:16:48 PM »
1-Is that thing only support analog input? When I use Digital input, it appears invalid return.
When you say analog input, I will assume you mean an integer value. Any control with the PLCAddressKeypad property will accept numeric input, such as the BasicLabel. Put a valid PLC address in that property, then when you run the application, you can click the control to get a pop up keypad.

Yes. When I use X0(in my PLC is 12049) as input, the message shows invalid return! True(False). That's why I ask this Message display by value component only take the analog input.
I'm still not sure if I am answering your question correctly. At first when you said analog input, I assumed you meant to write an analog value into the PLC. Now it sounds like you mean input from the perspective of the control.

For MessageDisplayByValue, you need an integer value, otherwise you would only have the possibility of 1 message.

How are your messages represented in your PLC? Is there an individual bit for each message? Does each message have a corresponding numerical value?

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #6 on: April 02, 2018, 04:22:51 PM »
Thank you for your reply!

What I want is that when coil1&coil2 are 1, the indicator becomes red. When both are 0, it becomes green. I am not familiar with VB program. And when I want to read detailed code of AHMI, I found it is private. So I cannot follow the programmed programs.
If you aren't familiar with VB then I suggest you do the code in the plc. I usually create a routine in the plc used for HMI animation. I will do this even in the HMI software allows for scripts and expressions. It's a little more work and memory, but it's usually easiest for all involved.

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #7 on: April 02, 2018, 06:07:53 PM »
Thank you for your reply!

What I want is that when coil1&coil2 are 1, the indicator becomes red. When both are 0, it becomes green. I am not familiar with VB program. And when I want to read detailed code of AHMI, I found it is private. So I cannot follow the programmed programs.
If you aren't familiar with VB then I suggest you do the code in the plc. I usually create a routine in the plc used for HMI animation. I will do this even in the HMI software allows for scripts and expressions. It's a little more work and memory, but it's usually easiest for all involved.

Thanks for your suggestion.

I have done it with PLC. But at last, I want to use AHMI read array from textfile and allow me to do more things. So I want to learn how to design a component by myself. Though I am not familiar with VB, it is not bad for me to learn it.

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #8 on: April 02, 2018, 06:13:21 PM »
1-Is that thing only support analog input? When I use Digital input, it appears invalid return.
When you say analog input, I will assume you mean an integer value. Any control with the PLCAddressKeypad property will accept numeric input, such as the BasicLabel. Put a valid PLC address in that property, then when you run the application, you can click the control to get a pop up keypad.

Yes. When I use X0(in my PLC is 12049) as input, the message shows invalid return! True(False). That's why I ask this Message display by value component only take the analog input.
I'm still not sure if I am answering your question correctly. At first when you said analog input, I assumed you meant to write an analog value into the PLC. Now it sounds like you mean input from the perspective of the control.

For MessageDisplayByValue, you need an integer value, otherwise you would only have the possibility of 1 message.

How are your messages represented in your PLC? Is there an individual bit for each message? Does each message have a corresponding numerical value?
So what I do is I input X0 address into PLCaddressvalue, I assume when X0 takes voltage the value should be 1 and show the message of value 1. But I found when X0 takes voltage, it returns True and False without voltage. That is the question I have. I am not sure how the component works.

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #9 on: April 02, 2018, 06:40:15 PM »
When I want to do expressions in ahmi what I usually do is use a datasubscriber2.  So, if you add 3 addresses on the data change event you can use the results in VB code. I can throw together an example if interested. The only time I've done that though is when it's inside of reusable code. I wouldn't do it for native controls, like an indicator. In that case it's still easier and better to do it in the plc.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Display by Value question
« Reply #10 on: April 02, 2018, 08:05:50 PM »
The MessageDisplayByValue is used to create a list of messages each with a unique integer value assigned to them. The PCLAddressValue is then pointed to an integer in the PLC that is used to select which message in the list to display.

If you are just looking to display a single message based on a Boolean value, then you can use any number of controls with the PLCAddressVisible property, such as the BasicLabel.

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #11 on: April 02, 2018, 08:35:30 PM »
When I want to do expressions in ahmi what I usually do is use a datasubscriber2.  So, if you add 3 addresses on the data change event you can use the results in VB code. I can throw together an example if interested. The only time I've done that though is when it's inside of reusable code. I wouldn't do it for native controls, like an indicator. In that case it's still easier and better to do it in the plc.
Thanks for your kind!


If you can throw an example, that will be perfect!

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #12 on: April 02, 2018, 09:10:01 PM »
The MessageDisplayByValue is used to create a list of messages each with a unique integer value assigned to them. The PCLAddressValue is then pointed to an integer in the PLC that is used to select which message in the list to display.

If you are just looking to display a single message based on a Boolean value, then you can use any number of controls with the PLCAddressVisible property, such as the BasicLabel.

Thanks for your answer!

I just read your sample of message display by value. It helps a lot!

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #13 on: April 03, 2018, 09:35:20 AM »
When I want to do expressions in ahmi what I usually do is use a datasubscriber2.  So, if you add 3 addresses on the data change event you can use the results in VB code. I can throw together an example if interested. The only time I've done that though is when it's inside of reusable code. I wouldn't do it for native controls, like an indicator. In that case it's still easier and better to do it in the plc.
Thanks for your kind!


If you can throw an example, that will be perfect!

Here is what I did.  I added a basic indicator to a form.  I added a datasubscriber2 to a form.  I tested with a modbus simulator using 40001, 40002, 40003.  When you add the datasubscriber you need to add your addresses to the collection.  Click on the datasubscriber and then in properties click on the collection to add.  This is the code I used.  I'm basically creating a tag database by creating result1,2,3.  On the data change event I load the values into these variables.  I also look to see if the values meet the expression I wrote.  You will need to tailor to your application.  There may be other ways, but this is how I usually do it.  I then force the basic indicator to use a specific color selection based on the expression result.  You don't need to set any PLC properties of the basic indicator if you do it like this, just the colors.

Code: [Select]
    Private result1 As Integer
    Private result2 As Integer
    Private result3 As Integer

    Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged

        If e.PlcAddress = "40001" Then
            result1 = e.Values(0)
        End If

        If e.PlcAddress = "40002" Then
            result2 = e.Values(0)
        End If

        If e.PlcAddress = "40003" Then
            result3 = e.Values(0)
        End If

        If result1 = 1 And result2 = 2 And result3 = 3 Then
            BasicIndicator2.SelectColor2 = True
        Else
            BasicIndicator2.SelectColor2 = False
        End If

    End Sub

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #14 on: April 03, 2018, 04:00:39 PM »
The MessageDisplayByValue is used to create a list of messages each with a unique integer value assigned to them. The PCLAddressValue is then pointed to an integer in the PLC that is used to select which message in the list to display.

If you are just looking to display a single message based on a Boolean value, then you can use any number of controls with the PLCAddressVisible property, such as the BasicLabel.

Thanks for your answer!

I just read your sample of message display by value. It helps a lot!

I created a control that is basically an analog display and multistate combined.  I added it to a base project, version 3.99x (I believe).  It will allow bool for states of 0 and 1.  You can download here:
https://drive.google.com/file/d/1PFDP_55PzzptuK5K3rdQtKFpAF9_ofCX/view?usp=sharing
You can test with Modbus sim.

James
« Last Edit: April 04, 2018, 09:16:56 AM by Phrog30 »