From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Allowing only one boolean variable to be true in a while loop

Solved!
Go to solution

Hi.

I have 12 true switches.

The default of them is false, and I need to somehow allow only one of them to be true every time.

To clarify, if for example i click switch no 2 (and turn it to true) at start its ok, because only one is turned on, but when i click on switch no 3 (and turn it to true) then I need it to turn down switch no 2 (switch it to false) instantly.

 

I have just start studying the software and am not all familiar with all its functions, so I would really appreciate the help.

 

Thank you 🙂

0 Kudos
Message 1 of 10
(5,608 Views)

Hello Denny,

 

You can use Radio Button with enabling the function "Allow no Selection" by right clicking on it.

for your reference I have attached vi, just go through it once.

 

Radio Button Path.png

 

 

 

 

 

 

 

 

 

 

 

Vinal Gandhi, CLA
Message 2 of 10
(5,597 Views)

Thank you very much, and can i somehow insert each value of the radio button to a boolean array?

 

I basiclly wish to insert these radio buttons into a while loop which will work until an "ok button" is pressed and then I need to find out which of these radio buttons is pressed.

 

Thank you again!

0 Kudos
Message 3 of 10
(5,563 Views)
Solution
Accepted by topic author DannyShulman

Yes Denny,

 

You can get the the actual valye of this booleans in to a array of boolean. you have to just follow the step as I have shown in this below image.

 

Radio.png  Radio button.png

Vinal Gandhi, CLA
Message 4 of 10
(5,554 Views)

Could you please elaborate the steps? all I understand from here is the for loop... i dont really know the other buttons.

 

Thank you.

0 Kudos
Message 5 of 10
(5,543 Views)
Solution
Accepted by topic author DannyShulman

Hello Denny,

 

you just download the snippet (Block Diagram image) and drop it to your VI's Block Diagram you will get the samre code in your VI, this is the one of the feature of LabVIEW.

Here I have taken "Controls []" property of radio button, which you can get it from this path at block diagram right click on radio button>> Create>> Property Node>> Controls []. Same wave you can take "Value" property box also.

 

Process.PNG

Vinal Gandhi, CLA
0 Kudos
Message 6 of 10
(5,530 Views)
Solution
Accepted by topic author DannyShulman

here is another method to react on a radio button:

radio01.png

 

the top solution creates a boolean array, the lower is how I would use the radio button: the event case just react on the change of the value and the output of the radio button control directly enters a case structure 🙂

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 7 of 10
(5,524 Views)

I really appreciate you help, but im sorry I still have difficulty understanding what to do. 

I have tried draggin the image from your second post to the white board and it just copied an url address.

Also , I have followed your instructions from your latest message, and created the contorls[] and value and now i have this:

 

1.JPG

 

and i dont know how to procced.

0 Kudos
Message 8 of 10
(5,519 Views)

 

When I try to change the name of the Radio selections ( i need to have different names) then the "no selection" connection to the value gives me an error.

 

What can I do?

 

And can you please explain me the meaning of this connection?

 

Thank you very much.

0 Kudos
Message 9 of 10
(5,504 Views)

the 'No Selection' is only valid if you have set to radio button control to 'Allow no selection'  (rigth click in the FP on the radio button frame ...)

If you rigth click the case 'name area' you can create new cases that are already correctly named. You can choose one case to be the default case, or you have to create one case for every button (plus the no selection if aktiv)

Read the LabVIEW help:

Fundamentals, Loops and Other Structures, Executing one or More Sections ... , CASE STRUCTURES: EXEC.........

 

Maybe start the tutorial(s) and/or just read all of the fundamentals 😉

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 10 of 10
(5,494 Views)