From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Front panel control with 3 states?

Solved!
Go to solution

I've effectively done this with a Boolean Control and some code.  Indeed, my favorite Boolean Control to use for this is the Boolean Indicator (the round dark-green button that "lights up" when pressed to be bright green).  I'm not looking at existing code right now (I did this several years ago, am sitting in an airport, so this is coming off the top of my head) ...

  • Create a Boolean Indicator (round button), make it the size/shape (round or oval) you want, and change it to a Control.  Make the Control a "Latch when Released" Control (typical Boolean Pushbutton Mechanical Action).
  • Create an Enum, call it "Tri-State", assign it "State 0", "State 1", and "State 2").
  • Decide on the Transition Rules.  Here I'm going to start in State 0, move to State 1, move to State 2, move to State 0, etc.
  • Use the Property Node for the Control to color it according to the State.  I recommend making all 4 colors the same "Selected" color you want for each State.  Thus if State 0 is "off", State 1 is "ready", and State 2 is "Active", you might choose Grey for State 0, bright Yellow for State 1, and bright Red for State 2.
  • The Event Loop for the Control will call an Action Engine (or be part of a Queued State Machine/QMH) to cycle through the States and change the Color Property for the Button.

This solution uses code, but it is fairly straight-forward.  Furthermore, you can easily create a Quad-State (or even more) Button.

 

I've also used this scheme to code Status Registers, particularly for multiple units, such as the condition of a dozen sensors (Off, Initializing, Active, Shutting Down, Error).  I create an Array of Booleans (1D or 2D), which when combined with resizing the Indicators, makes a compact display, and signal the Status by "coloring" the Control.  [Oops -- I realize I just mis-spoke -- you can't set individual properties of Boolean Controls in an array.  So How Did I Do That?  Hmm, I think I may have made an array of tiny Color Boxes, and simply set the individual Indicator to the Color I chose for that Status].

 

Bob Schor

0 Kudos
Message 11 of 14
(2,332 Views)

To make an array of things where I want to be able to make individual elements different colors, I make an array of the clusters; the cluster containing the control that I want, set to transparent, and behind it a color box.

"If you weren't supposed to push it, it wouldn't be a button."
Message 12 of 14
(2,325 Views)
Solution
Accepted by topic author EduNI

I've used a radio control with 'tailored' controls for just that purpose.  It is NOT a tristate LED but I think it's better.  A tristate LED used as a control to select On, Off and Don't care (as you indicated) would not be intuitive to the user. I like my solution much better - but I'm a little biased 🙂


I'm not sure why the Radio Button didn't make it into the Silver palette. You can find Radio Button controls on the Modern, Classic and System palette under Boolean controls.  The Modern and System radio button are , "misplaced" in that their types are uInt32 however not boolean. The Modern and System radio buttons have an advantage over the Classic radio button in that you can add as many 'radio  knobs' as you like. The greatest advantage, one which I've leveraged, is that you can replace the control to whatever you like. You can even mix them! For my solution I dropped a radio button from the Modern palette, right clicked on the radio knobs and replaced with square buttons. I then set the colors in such a way to illustrate On (bright green), Off (dark green), and Don't Care (dark grey).  This, with proper labels, clearly indicates to the user the usage of the control and the chosen state.

Input Condition Select.PNG

Message 13 of 14
(2,282 Views)

There is nothing misplaced about the Modern and System radio buttons datatype.  A single radio button, by itself, does have a boolean datatype.  If you are looking at the radio buttons group, which has more than one radio button, this datatype cannot be represented by a 0 or 1 alone so, yes, it does have a uInt datatype.  


Edit: I now see what you mean by misplaced, being in the boolean pallete rather than the numeric pallete.  

 

What would you want the Silver radio button to look like?  You can make one by replacing the radio buttons in any of the other versions with Silver LEDs.

Example_VI.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 14 of 14
(2,274 Views)