LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically switch between several cases (ranges)

I'm having trouble seeing the forest throught the trees here....

I have an analog voltage input that I need to convert to pressure.  Between 0 and 10 volts, there are 25 different linear transfer functions that will be used for this conversion.  What is the best way to choose which transfer function to use?  A nest of 25 if/then cases?  An enumerated list case structure?  In text programming it would be something like:

if 0<V<0.5;
    m=1
    b=1
if 0.5<V<1;
    m=1.1
    b=1.5

end if

P=mV+b

Only there would be 25 if statements.....

Thanks in advance for any suggestions.
0 Kudos
Message 1 of 6
(3,112 Views)
A single case statement should do the trick. With a numeric wired to the case selector, you can specify a range. If you were to type in 0..4, that case would be executed for all numbers from 0 to 4, inclusive. You can have open ended ranges. Specifying something like ...5 would be any number less than or equal to 5. I would recomend that you multiply your dbl by ten and convert to an integer. Then you would have ranges of 0..4, 5..10, etc.
Message 2 of 6
(3,102 Views)
Here is an approach using the Threshold Array function. You may need to add some error checking for out of range conditions. Also be careful with the behavior of the function at the first element. Read the context help for more details. The case structure would have been my first thought, but as I was trying to decide how to select the cases, this idea came along.

Lynn
Message 3 of 6
(3,100 Views)
Thanks to both of you!  Those are great suggestions.  I didn't realize that a case structure could be wired that way and I would have never found the threshold function. 

Brad
0 Kudos
Message 4 of 6
(3,083 Views)
Hi:
 
Could you post this VI in LV 7.0 or 7.1?  Thanks
0 Kudos
Message 5 of 6
(3,024 Views)
 Here it is in  7.1:  This was posted by johnsold using the threshold method.  I have somewhere a VI that uses both the threshold method and the case structure method, I will post it later if I find it.

Brad
0 Kudos
Message 6 of 6
(2,996 Views)