LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you toggle between 2 numeric values using a boolean toggle switch ?

Solved!
Go to solution

Hi

 

I'm a labview novice so this might be easy to answer.

 

I would like to perform a calculation which depending on the unit on test will require a different numeric value to be used in the calc.

 

I've tried to use a boolean toggle switch to select which constant is to be used during the run mode so for example either 0.01 or 0.02 will be selected. The idea is labview will then insert the selected constant into the calculation and spit out the answer.

 

There is only one output on the boolean toggle switch and no inputs so I can't work out how to do it. If there were 2 inputs and 1 ouput it would do the job.

 

thanks

Andy

 

0 Kudos
Message 1 of 9
(8,183 Views)

Several options:

If you're tied to using a boolean, you could look at the comparison palette and the 'select' primitive. Look at the help file for details.

For more complex choices, have a look at case statements.

 

0 Kudos
Message 2 of 9
(8,180 Views)

I want to use the toggle switch on the front panel so I guess I have no choice but to use boolean, unless there are other ways.

0 Kudos
Message 3 of 9
(8,176 Views)

Example attached

0 Kudos
Message 4 of 9
(8,175 Views)

 


@Andy K wrote:

I want to use the toggle switch on the front panel so I guess I have no choice but to use boolean, unless there are other ways.


As an example, another method would be to use a numeric control. "But I don't want to manually enter the number" I hear you cry!  To overcome this you can go to the properties for the control and change the 'data entry' parameters to limit what can be entered into the control. It is not particularly elegant but it does mean that the user will see the value that is being used... you have to decide whether that is important or not for your application.

 

See the attached where I compare three options...

 

EDIT: Sorry - I screwed up the attachment (and the text. Doh!)

 

Ian

0 Kudos
Message 5 of 9
(8,167 Views)

Marty

Thanks for the vi, it does what I wanted, but now after playing more I would like it to display a name rather than the value.

 

So for example if A = 0.01 and B = 0.02 I get it to say on the front panel A or B depending on the toggle position rather than 0.01 or 0.02 as it does now.

 

The calc still needs the 0.01 or 0.02 in there to give me the answer.

 

thanks Andy

0 Kudos
Message 6 of 9
(8,151 Views)
Solution
Accepted by Andy_K

Try the attached.  I have supplied two methods.

0 Kudos
Message 7 of 9
(8,145 Views)

Andy,

 

Use a Text Ring configured to use DBL datatype and set for the appropriate number of decimal places.  Under 'Edit Items' tab deselect the 'Sequential Values'.  Now you can asign a unique DBL to each text entry.  What version of LV are you using?  I'll post an example.

 

P.S.  One advantage of this method is that you can populate this control at runtime with a list of strings and values imported from a config file.

0 Kudos
Message 8 of 9
(8,135 Views)

Marty

Your 1st solution did what I wanted, thanks for that.

 

Wayne

I'm using 2010

0 Kudos
Message 9 of 9
(8,123 Views)