11-14-2012 12:19 PM
Hi,
I am building a VI with a case structure where cases are selected by inputting an integer to the case selector. The cases are selected depending on the range that the integer value falls in, e.g. execute the first case if value falls in 5..10 and second case if value falls in 11..15 etc. Is there a way to wire a control from the front panel to the case structure so that I don't have to go to the block diagram to adjust these values while I am doing my device development?
Thank you,
Dave
Solved! Go to Solution.
11-14-2012 01:04 PM
Build it into your logic. Use In Range and Coerce to determine when a value falls into a particular range, and use controls to determine what is the max and min of that range.
11-14-2012 03:07 PM
OK, I am trying to do that, but, I am really struggling with the logic, though.
I have a value coming in that may fall into one of three ranges, 1) OK, 2) too high, or 3)too low. I am struggling mightily to figure out how to configure the code so that it makes the determination of which case it is.... and then sends the result to a case structure for the next section of commands.... What am I overlooking to make this easy??? Here is my draft code, and you can see how I am stuck here...
11-14-2012 03:17 PM - edited 11-14-2012 03:20 PM
You have an overdetermined system. To exactly define one of three states, only two booleans are needed.
Test for too low and too high and if both are false we are automatically in range, right? 😄
Here's what you could do.
11-14-2012 06:10 PM
OK, so, that "Boolean to number" function is something I was unfamiliar with.j Pretty snappy thing you did there! Can you help me understand how it works.
I see from the Detailed Help that FalseFalse-0, TrueFalse-1, FalseTrue-2, and TrueTrue-3, so, I see how the code you sent operates, thank you very much. It would have taken me a LONG time to stumble across "Boolean to number" to solve this problem. THANKS!
"If the number is signed, LabVIEW interprets the array as the two's complement representation of the number." --> from the Detailed Help.
What is a signed number? I see there are four types identified as signed as listed in the Numeric Data Types Table, I8, I16, I32, I64, and there are 4 types of unsigned, U8, U16,U32, U64. Is there some meaning of signed and unsigned or is this an arbitrary definition? Seems systematic, but, I can't find knowledge about it.
If it's not too much trouble, can you also tell me what is the meaning of " the two's complement representation of the number"? When they refer to the "two's" are they simply referring to the two boolean values, FF, FT, TF, or TT?
Bingo! Thank you!
11-14-2012 07:04 PM - edited 11-14-2012 07:10 PM
We are converting to U32, which is not a signed number and we don't need to worry. (press ctrl+h and hover over the wire to see)
Two's complement specifies a convention on how negative integers are represented in binary. You can read all about it here.
You select the proper integer data type according to what you need. The more bits you have, the more possible numbers you can represent (e.g. U8 only has 8 bits and only gives you 0..255). You need a signed number if you also need to represent negative numbers, but that cuts your positive range in half for the same number of bits (e.g. I8 gives you -128..127 instead). (see also)