LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A case structure with 2 input to compare

Hello LabVIEW Forum,

I'm trying to write simple code, that has to convert between different units of temperatures. I want an input where i can choose between "Celsius","Kelvin" or "Fahrenheit" an d an output where i can choose between "Celsius","Kelvin" or "Fahrenheit". Ultimately, i want a third input, which is the input temperature that should be converted to the chosen output temperature, from the chosen input temperature.

 

So for example, if i choose "Kelvin" and "0" then the output should be "-273.15" as output on the temperature scale.

 

My problem is, that I don't know how i can make a case structure take 2 inputs to compare: the temperature unit that should be converted from and the temperature unit that should be converted into.

 

How can I make a case structure take and compare 2 inputs to do the necessary conversions? Or is there a simplere and smarter way of doing this. 

I have attached my VI so far. I have 2 inputs of temperature units as "enum constants".

0 Kudos
Message 1 of 9
(4,139 Views)

I can't open a 2018 VI but I can ask a question...

 

Have you considered using two case structures, one to convert input to a stand unit and another to convert from the standard to the desired output units?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 9
(4,131 Views)

Convert from the given temperature to Kelvin using the first case structure, then convert to the desired output using a second case structure. (Ben already said that, sorry, I misunderstood).

 

 

Also, the input temperature should probably not be an integer. Make it orange!

 

(Your code does not contain any indicators, so please make it as complete as possible before attaching. It is also very impolite to leave the name at "Untitled 1.vi", because most download folder already have a file with that name. Please next time give the VI a descriptive, unique name before attaching!)

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

@Antaras wrote:

Hello LabVIEW Forum,

I'm trying to write simple code, that has to convert between different units of temperatures. I want an input where i can choose between "Celsius","Kelvin" or "Fahrenheit" an d an output where i can choose between "Celsius","Kelvin" or "Fahrenheit". Ultimately, i want a third input, which is the input temperature that should be converted to the chosen output temperature, from the chosen input temperature.

 

So for example, if i choose "Kelvin" and "0" then the output should be "-273.15" as output on the temperature scale.

 

My problem is, that I don't know how i can make a case structure take 2 inputs to compare: the temperature unit that should be converted from and the temperature unit that should be converted into.

 

How can I make a case structure take and compare 2 inputs to do the necessary conversions? Or is there a simplere and smarter way of doing this. 

I have attached my VI so far. I have 2 inputs of temperature units as "enum constants".


A case structure can't have 2 selector inputs.  You use multiple case structures for such circumstances.

The attached VI does what you want without any case structures.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 9
(4,121 Views)

You can also make a 3x3 2D array, each element containing a cluster of slope+offset for each possible conversion (diagonals are [1,1]. Use the two rings to index into the 2D array and use the obtained slope/offset to convert. 😄

0 Kudos
Message 5 of 9
(4,118 Views)

Actually you have 3x3 or 9 possible conditions to deal with here.

F to C

F to K

F to F

C to F

C to K

C to C

K to F

K to C

K to K

 

I would use an enum for each selector then use the output of each to determine what formula to use to make the conversion. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 9
(4,082 Views)

 Something like this:

ConvertTemp.png

Probably not the most efficient but it was the first thing I thought of...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 9
(4,080 Views)

@altenbach wrote:

You can also make a 3x3 2D array, each element containing a cluster of slope+offset for each possible conversion (diagonals are [1,1]. Use the two rings to index into the 2D array and use the obtained slope/offset to convert. 😄


Diagonals are (1,0)

 

While that would be a 0 case solution, the reader would hav to do math.

 

The 2 case approach would only require code in 4 of the 6 total  cases. 

 

The math version could be read at glance. The 2 case version would require poking at it.

 

Choose the red pill or the blue pill.

 

Quoting my wife "Stand back, he is going to do math."

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 9
(4,072 Views)

@Ben wrote:

Diagonals are (1,0)


Hey, somebody is paying attention 🙂 thanks for the correction.

0 Kudos
Message 9 of 9
(4,054 Views)