07-31-2023 11:37 AM
Hello, I have attached what I want to implement in LabVIEW on a much larger scale, there will be dozens of controls (only 4 are shown in the code) and they will be located in different parts of the code, so dragging wires to inputs of compound OR gate will clutter the code and I already have way too many wires. In normal code, I'd write something like:
result = 0;
if boolean == 1 and numeric == 0 then result = 1
if boolean2 == 1 and numeric == 2 then result = 1
if boolean3 == 1 and numeric == 7 then result = 1
if boolean4 == 1 and numeric == 5 then result = 1
I can easily implement the "if" portion of the code with local variables, but I'm not sure how to pass that values to result LED without using OR gates.
Solved! Go to Solution.
07-31-2023 12:19 PM - edited 07-31-2023 12:39 PM
Can you "save for previous" (LabVIEW 2020 or below, and attach again)?
Easies would to use a SET with a cluster of [array of all booleans, integer] and enter all combination that result in 1. Generate a 0 or 1 depending on if the entry is found or not.
(Above assumes that 0, or 1 are the only possible output values. If some combinations can result in a 2, 3, or similar, you could use a MAP containing all non-zero entries where the value is the result.
@John32d wrote:
I can easily implement the "if" portion of the code with local variables, but I'm not sure how to pass that values to result LED without using OR gates.
Why in the world would you need local variables for any of this????
At least in the USA, OR gates are still legal. What prevents you from using them???????
07-31-2023 12:33 PM - edited 07-31-2023 12:34 PM
@altenbach wrote:
Can you "save for previous" (LabVIEW 2020 or below, and attach again)?
Here's a snippet of the original code:
I'm guessing that the Numeric should be an Integer as floating points are not exact. Here is another option using arrays:
07-31-2023 12:46 PM
Code for LabView 19 version is attached.
What prevents me from using OR gates is the complexity of the code, I'll have to drag the code across multiple screens and this makes debugging extremely difficult, I'm looking for a better way to achieve that.
07-31-2023 12:59 PM
07-31-2023 01:09 PM - edited 07-31-2023 01:19 PM
@John32d wrote:
Code for LabView 19 version is attached.
Major flaw: As has been said, doing equal comparisons with DBLs. Should they be integers?
You said you have dozens of controls, not just four. Why all these loose booleans, why not a boolean array? Where does the truth table come from? How often does it change? What are all possible values for the numeric?