LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-adjusting fill bars - always add up to 100

Solved!
Go to solution

My goal is to create a set of graphical controls showing that as one value increases the others must decrease, and vice versa. There will be three fill bar controls, and the sum of the three values should always add up to 100 (or less).

 

I'm sure we've all seen GUI's impliment functions similar to this, but I can't seem to find a *good* way to do it in LabVIEW.

 

I'm attaching my current unappealing rube goldberg solution, but I'm hoping someone can suggest a more elegant method (and help get rid of the rat's nest of wiring only a mother could love).Efficiency would be a plus as well, though this VI will be running in the lowest priority thread of my application.

0 Kudos
Message 1 of 4
(2,892 Views)

Hi AlexK,

 

Thanks for the post!

 

I have to say this code is looking pretty good, your using shift registors and your effectively performing the logic steps required. 

 

I for one could only recommend adding an Case structure, so if none of the values have changed, then to skip the rest of the code...

 

Kind Regards,

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 2 of 4
(2,881 Views)
Solution
Accepted by AlexK

Hi, Alex,

 

You can simplify your code a little bit if you will work with event structure (you can ger reference to the slider whic was changed, and then correct values for other two).

see attachment

 

Andrey.

PS

Upd:

Sorry, just checked - in the attached example the sliders will get negative values in some cases, but this can be easily corrected. The main idea remain the same...

Message Edited by Andrey Dmitriev on 10-22-2008 07:00 PM
Message 3 of 4
(2,879 Views)

Thank you Andrey, that is the more elegant solution I was hoping for. I had considered using the event structure but couldn't figure out how best to reference the other two slide bars. Your array solution solved that nicely.

 

Thanks!

 

[Edit: You might notice my example had the same problem with slide bar values going negative as well. It's not a problem, I can fix that.]

Message Edited by AlexK on 10-22-2008 01:03 PM
0 Kudos
Message 4 of 4
(2,869 Views)