02-05-2009 07:19 PM
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
02-05-2009 08:53 PM - edited 02-05-2009 08:54 PM
02-05-2009 09:07 PM
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).
02-05-2009 10:27 PM
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
02-06-2009 12:16 AM
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
02-06-2009 12:34 AM
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.
02-06-2009 12:57 AM
Here's the tested solution (it was the select function):
02-09-2009 01:20 PM
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
02-09-2009 01:54 PM
Can't do 8.5, but here's an image (I copied it into Paint).