07-28-2020 11:47 AM
Hello NI Labview community,
I need help to convert the temp to either Celsius or Fahrenheit. The VI code should include a case structure, string subset, number to fractional string, and fractional number to string converter.
For example, the user enters 24.0C the program converts it to Fahrenheit and if the user enters 75F it should convert that to Celsius and display the result.
The front panel should look like this.
07-28-2020 12:02 PM
This sounds like homework.
Have you started programming it yourself?
Where are you stuck?
07-28-2020 12:44 PM
I'm stuck with how to connect the input string to the function node and display the result with the text.
07-28-2020 12:44 PM
Using string subset will be very limiting. You will only be able to enter temperatures that are 4 characters long. I would use something like "match pattern" instead. You can even find how many places are past the decimal point and make the output temperature have the same precision as the input temperature.
However there is a bug, when I enter in -40 F or C it doesn't perform a conversion, it just outputs -40 again. Can you figure out why? 🙂
07-28-2020 12:46 PM
@jason888 wrote:
I'm stuck with how to connect the input string to the function node and display the result with the text.
Read the help documentation. (Ctrl+h) will bring up the hover window, then you can click for more detailed help. You will find that the variable "F" does not belong in an expression node.
07-28-2020 01:18 PM - edited 07-28-2020 01:23 PM
@Gregory wrote:
Read the help documentation. (Ctrl+h) will bring up the hover window, then you can click for more detailed help. You will find that the variable "F" does not belong in an expression node.
Actually, almost any character will work, including uppercase F. 😄
There is an almost unlimited possibility for variables, with the only restriction that it cannot be "pi" and there cannot be more than one variable name per node. Even the following works fine.
07-28-2020 01:36 PM - edited 07-28-2020 01:39 PM
If you can assume that the input is well formed (no extra characters or spaces), You could do the following (It would be easy to expand the output format to include more text):
(Also make a default case that outputs NaN for unexpected inputs)
07-28-2020 01:38 PM - edited 07-28-2020 01:40 PM
@altenbach wrote:
@Gregory wrote:
Read the help documentation. (Ctrl+h) will bring up the hover window, then you can click for more detailed help. You will find that the variable "F" does not belong in an expression node.Actually, almost any character will work, including uppercase F. 😄
Oh man, I've got a whole omelette on my face. Thanks for pointing this out!