LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing a boolean value based on two buttons

I know that this is a ridiculously simple question, but I've been having trouble with it.

 

How would you set a boolean value based on the input from two other boolean values? Essentially what I want, in pseudocode, is this:

 

boolA = true

 

if (boolB)

     boolA = false

 

if (boolC)

     boolA = true

 

It should be really simple to do, but I can't figure it out. The problem is getting it to stay false, for example, after boolB goes back to false, and not just to have it only momentarily go to false. I want it to stay false until boolC goes to true, regardless of what boolB does after that. Any advice?

 

Thanks,

Logan Williams

0 Kudos
Message 1 of 9
(3,407 Views)
Message Edited by Ravens Fan on 02-05-2009 09:54 PM
0 Kudos
Message 2 of 9
(3,398 Views)

Would an implies vi do the trick for you?

 

From the LabVIEW help:

 

Implies

Negates x and then computes the logical OR of y and the negated x. Both inputs must be Boolean or numeric values. If x is TRUE and y is FALSE, the function returns FALSE. Otherwise, it returns TRUE.

 

y would be BoolC and x would be BoolB  (if BoolB is true and BoolC is false, the output would be false). 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 3 of 9
(3,394 Views)

I would say implies is close to what was asked for.  However, the only issue is that for the case where both B and C are false, the logic shows that there is no change to A.  It is initially True, but if it happens to be False because of further changes, there is nothing in the If statements to change the logic.  And that is what is asked for.  That the Result stays False even when B goes back to False.  But the Implies function says that  F and F must be True.

 

As described

B         C         Result A

T          T          T (because C is evaluated 2nd)

T          F          F

F          T          T

F          F          x (initially T, but the code shown and what is asked for is actually no change from previous state)

  

Implies Truth Table

B         C         Result A

T          T          T

T          F          F

F          T          T

F          F          T

 

0 Kudos
Message 4 of 9
(3,383 Views)

Yeah, that was the one condition I wasn't sure about.

 

How about and'ing the output of the implies with the original value of boolA?

 

Implies Result     Result A (original)     Result A (output)

T

F

T
F

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 5 of 9
(3,374 Views)

Whoops...  

No, that won't work.

 

But this will.... (sorry, don't have LabVIEW on this PC):

 

Feed the implies into the True Pin of the True/False selector (brain freeze, can't remember name, but there are two of them in Ravens Fan example).

 

Feed boolA into the false pin.

 

Or boolB and boolC and feed that into the selector pin.

 

Sorry if this isn't quite clear...  can't remember the stupid name for that function.

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 6 of 9
(3,369 Views)

Here's the tested solution (it was the select function):

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 7 of 9
(3,359 Views)

Thank you for your help. Can you save it as a LabVIEW 8.5 file? It won't let me open an 8.6 file.

 

Thanks,

Logan

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

Can't do 8.5, but here's an image (I copied it into Paint).

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 9 of 9
(3,316 Views)