From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

How to make Boolean to Numeric

Solved!
Go to solution

Hello!

 

How do I change this code, so that if state one is true, then output number 1. Then if state two is true then output 2 in numeric.

 

Thanks in advance.

0 Kudos
Message 1 of 7
(1,826 Views)

What if both inputs are TRUE?  And what about H3?  Maybe a simple truth table would help narrow down exactly what you are trying to do.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(1,811 Views)

Given three switches, there can be a total of eight possible states. You only have 6 LEDs.

Please clarify the problem and provide a full truth table as requested.

 

Also note that you probably could dramatically simplify your code by using arrays as controls and indicators.

 

0 Kudos
Message 3 of 7
(1,801 Views)

@altenbach wrote:

Given three switches, there can be a total of eight possible states. You only have 6 LEDs.

Please clarify the problem and provide a full truth table as requested.

 

Also note that you probably could dramatically simplify your code by using arrays as controls and indicators.

 


One possible interpretation...

 

altenbach_0-1608140179745.png

 

0 Kudos
Message 4 of 7
(1,789 Views)

Okay, maybe I expressed myself wrong. It is true that there are 8 possible states, but they are not intresting in what im trying to do. The thing i want to do is output a number instead of a led light. So the led in the top "tillstånd 1" should output 1 in a numeric number.

0 Kudos
Message 5 of 7
(1,781 Views)

Wire a numeric indicator to the output of "boolean array to number". Right?

Message 6 of 7
(1,775 Views)
Solution
Accepted by topic author Westen

If only one LED can be TRUE, do "search array" for true and display the index (-1 if all are off).

Depending on how you want to count, add a +1 if needed.

Message 7 of 7
(1,773 Views)