LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a "Smart" OR Gate

Solved!
Go to solution

Hi all!

 

My goal is to create the function of an OR gate that doesn't necessarily require both inputs as long as one is true.  ie:

 

X----|```)---1

1----|__)

 

Currently, LabView waits for both inputs before outputting the result, however it is clear that if one is true, this shouldn't be necessary.  Does anyone have any idea how I can  create something like this?  Thank you!

 

Best,

Patrick

0 Kudos
Message 1 of 26
(4,370 Views)
Solution
Accepted by hockeystar31

Put the Or gate into a subvi, and set the two input with default values of false. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Message 2 of 26
(4,358 Views)

Remmeber to make both input recommanded only and not required.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 26
(4,356 Views)

Thanks!

0 Kudos
Message 4 of 26
(4,335 Views)

No problem!!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 26
(4,330 Views)

I would also suggest making the VI inline. If you do not know what this means, check the LabVIEW Help.

0 Kudos
Message 6 of 26
(4,321 Views)

How does making a subVI answer the original question?  He asked how his code could proceed past the OR as soon as either input is true, without waiting to calculate the value of the other input.  No LabVIEW function will proceed until data is available all of its inputs, regardless of whether it's a subVI.

 

If what you want is to evaluate the two inputs independently and proceed as soon as either one is true, use "Wait on Notification" in place of the OR.  Wire both booleans into Send Notification in parallel, so that both boolean conditions can be evaulated concurrently.  Depending on the desired behavior, you could either set the notification only when it evaluates to true, or you could put the Wait on Notification in a loop such that it will return to waiting if the first notification is false.

 

short-circuit OR.png

Message 7 of 26
(4,308 Views)

wow, I didn't see the question that way.  I thought all he wanted was a don't care input.  He tried to draw it in the first post.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 26
(4,297 Views)

Actually, I thought he was also asking that as well. It seemed to me that he was asking for the equivalent of the short-circuit evaluation that occurs in text-based code where you can take advantage of not needing to evaluate the second half of a condition if the first part happens to provide the necessary value to allow the Boolean (whatever it may be) to give you the result. To be honest, I'm not sure how nathan came to the conclusion he did.

0 Kudos
Message 9 of 26
(4,263 Views)

I thought he was asking for something like short-circuit evaluation, but without needing to worry about the order of evaluation.  It's easy to duplicate short-circuit evaluation of OR in LabVIEW, of course: evaluate the first expression, put the second in a case structure and only execute it if the first result is false - but the way I read it, that wasn't exactly what the poster wanted.  Patrick wrote "Currently, LabView waits for both inputs before outputting the result, however it is clear that if one is true, this shouldn't be necessary.  Does anyone have any idea how I can create something like this?"  So that's the question I was trying to answer.  I can't see how jyang72211's response is actually helpful, because why would you need a one-input OR?  It sounds like we're in agreement about the short-circuit evaluation - did you mean me, or jyang72211, when you wrote that you couldn't understand how I came to that conclusion?  I understand that my solution doesn't provide short-circuit evaluation - both expressions are evaluated - but it does allow the code to proceed immediately if one of the two results is true and the other has not yet completed.

0 Kudos
Message 10 of 26
(4,258 Views)