LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fooled by a Knob Control

I was designing the Front Panel for a Stimulator that had a bunch of LabVIEW Knob Controls.  I used Text Labels to define a set of discrete values for these Controls, as shown in the figures below (the last one is a Snippet of the actual Controls used in a trivial VI).

Knob Control FP.pngKnob Control Detail.pngKnob Controls.png

As you can see by the middle view from the Property Sheet of the first Pulse Width Control, I set the four Values shown on the Control and set the Values returned to the same values.  So what happened when I ran this code (or when you run the Snippet)?  Well, that's shown in the first image -- Pulse Width and Pulse Freq were both zero!

 

Why?  I didn't know.  I fiddled with the Controls, then tried it again, and it worked fine!!  It turns out I forgot about "Default Values" for Controls.  Consider the Pulse Width control.  If you look at its 'Scale" Property, the Minimum is 0.2 and the Maximum is 2.0, as one would expect, but if you inspect "Data Entry", there is no restriction on the actual Values the Control can take.  One way to visuallly see what is happening is to turn on the Digital Display property (which I always turn off, because it detracts from the nice appearance of the Front Panel, leading to my initial confusion).  What it would show is a funny value os "<0>", which I now realize is a symbol for "I don't know any value, so I'm using the Default for this Numeric Control, i.e. 0".  When you turn this indicator on, and barely move the Knob, the value will "snap" from <0> to 0.2.

 

What I also do, of course, is to set the Default Value for this Control (after I wiggle it to get "real" values to appear).  I went looking in the Documentation for a mention of this "unexpected" behavior, but couldn't find it.  So be careful when designing "pretty" Front Panel Controls.

 

Bob Schor

Message 1 of 5
(2,409 Views)

Hi Bob,

 

when designing such UIs I most often implement a "use the last user selected value" feature, similar to real instruments.

This way there is no "default zero" value used...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,370 Views)

@GerdW wrote:

when designing such UIs I most often implement a "use the last user selected value" feature, similar to real instruments.

This way there is no "default zero" value used...


Very clever!  I've done something similar, namely tried to remember to set Default Values on all of my Top Level Front Panel controls (which, of course, I forgot to do on these guys), but the idea of saving (or resetting) the "initial" Values for the next run didn't occur to me.

 

I just looked, and couldn't find a way to programmatically "set" the Default Value (other than writing to a Config file on Exit and reading and using it on Entry).  Is that how you do it?

 

Bob Schor

0 Kudos
Message 3 of 5
(2,345 Views)

Hi Bob,

 

no, I did my own library for that purpose.

I have to save a lot of "initial values" on my testbenches, including a lot of control loop parameters or the selection of shown measurement channels in graphs. When the testbench software is started it retrieves the last settings.

Using this scheme I can also easily implement a feature to allow the users to save/load certain configurations by name. Infact the "last used settings" is automatically saved as configuration named "standard"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,336 Views)

Doing text scales basically turns it into a pseudo ring control, but things are apparently not fully implemented under the hood (e.g. right-click...replace...ring-control" does not retain the existing values). Curiously, there is no "Strings and values[]" property for text scales of knobs ... shouldn't there be?

 

(Offtopic: Similarly, it would be great to have text scales for graphs.)

 

On a related note, I think knobs are the worst controls for anything, see also my comment here (second reply). When given a choice of four values, I would probably use a DBL ring (or an enum or radiobutton control, indexing into an array of DBL choices)

Message 5 of 5
(2,303 Views)