Author Topic: Changing colour of 7 segment displays  (Read 1413 times)

DJShardy

  • Newbie
  • *
  • Posts: 11
    • View Profile
Changing colour of 7 segment displays
« on: October 24, 2018, 10:50:45 PM »
Hi,

I have a seven segment display that I want to change to be either red or green.

The red/green is determined by where the factory is in regard to the goal.

In the properties, I can only see the option to change colour depending on the value the seven segments is displaying. ( foreColourOverHighLimit etc.)

Is there any way I can change the colour another way. Like from a BOOL in the PLC. I can do the maths and determine if they are ahead or behind target.

Thanks!

DJShardy

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Changing colour of 7 segment displays
« Reply #1 on: October 25, 2018, 01:36:45 AM »
I assume I need to place some code in here. I have no idea what to do though. Have tried google and the forum but this hasn't come up before.


Code: [Select]
    Private Sub SevenSegment21_ForeColorChanged(sender As Object, e As EventArgs) Handles SevenSegment21.ForeColorChanged




    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Changing colour of 7 segment displays
« Reply #2 on: October 25, 2018, 03:00:33 AM »
The SevenSegment2 has the following properties for changing color based on value:

ForeColorHighLimitValue
ForeColorInLimits
ForeColorLowLimitValue
ForeColorOverHighLimit
ForeColorUnderLowLimit

These properties will let you set up to 3 colors, then 2 limit values. Essentially you have a value good, value low, and value high.

DJShardy

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Changing colour of 7 segment displays
« Reply #3 on: October 25, 2018, 05:28:53 PM »
Yes, I understand that, But What I'm trying to do is have it change to red or green based on the plant being under or over the production goal for tthe current point in time.

Eg -  Goal is 10 widgets over a 12-hour shift. If at the 6-hour mark they have completed 4 widgets the seven segment display would be red. However the next day at the 6-hour mark they have made 5 it would be green.

Is that clear?

I was wondering if its possible to use a Data subscriber & an IF Else statement to change the seven segment display properties so I can manipulate the ForeColorHigh from red to green as I need. I could keep the ForeColorHighLimitValue as 1 and just change the properties.

Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Changing colour of 7 segment displays
« Reply #4 on: October 25, 2018, 06:10:45 PM »
View the code for SevenSegement2.vb

In the Properties Region, add this line of code (case sensitive, so it must be exact):
Code: [Select]
    Public Property PLCAddressForecolorHighLimitValue As String

Build the Solution


Set ForeColorOverHighLimit to Green
Set ForeColorInLimits to Red
Set the new property of  PLCAddressForecolorHighLimitValue to a PLC address that holds the target value
Set PLCAddressValue to point to the actual value

Now when you run the application, it will track the moving target calculated in the PLC.
« Last Edit: October 25, 2018, 06:12:39 PM by Archie »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Changing colour of 7 segment displays
« Reply #5 on: October 25, 2018, 06:13:35 PM »
I was wondering if its possible to use a Data subscriber & an IF Else statement to change the seven segment display properties so I can manipulate the ForeColorHigh from red to green as I need. I could keep the ForeColorHighLimitValue as 1 and just change the properties.
Yes, you could do it that way to

DJShardy

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Changing colour of 7 segment displays
« Reply #6 on: October 25, 2018, 06:48:17 PM »
Great, This works exactly how I needed it to. Thank you.

For future reference, If I was to go the Data subscriber way. Where would I put the code for something like this?

Is there any documentation I can read?
Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Changing colour of 7 segment displays
« Reply #7 on: October 25, 2018, 07:00:02 PM »
After you add the DataSubscriber to the form, you double click it and it will take you back to the code for the DataChanged event handler. The code will be behind the form that has the DataSubscriber