LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control to case selector

Solved!
Go to solution

Hello all,

I seem to have run into a problem and was wondering if posting here would help me frame the question and perhaps select the right approach.  

I am reading into the DAQ, Analog input values that are the following set values: 2.5, 3.0, 3.5 ... 6.5, each corresponding to a value (1, 2, 5 .. 500) that I use to modify a data stream.  [Basically, gain values of an amplifier].  

What needs to happen:

if value 2.5, divide by 1

if value 3.0, divide by 2, and so on

Case structure with enum would seem the appropriate fix?, but since I'm feeding in a control, or build an enum, I'm a bit at a loss.

Any ideas on how tackle this?

Thank you!

 

 

0 Kudos
Message 1 of 5
(2,353 Views)

What happens if the value is 2.6?

 

Use Threshold Array to determine what index you are at, and then index the multiplier out of another array.

0 Kudos
Message 2 of 5
(2,329 Views)

Your code picture has little to do with your description and does not make a lot of sense, especially since wires come out of nowhere and go nowhere because the image is truncated!

So does the value from the dynamic data correspond to the bottom row of your table?

After rounding to nearest, you get an integer, so wire that to the case structure, remembering that is twice the indicator value. In fact, even simpler would be to create a 1D array of DBL values where the index covers 0 to the highest expected integer. No case structure needed! Maybe there is even a mathematical expression that could calculate the value from the input.

 

Please attach a simplified version of your code so we can see what's in the other cases and outside the currently visible area!

Message 3 of 5
(2,306 Views)
Solution
Accepted by topic author nsamsoon
In fact, even simpler would be to create a 1D array of DBL values where the index covers 0 to the highest expected integer. No case structure needed!

Here's how that could look like:

 

LookupGain.png

0 Kudos
Message 4 of 5
(2,301 Views)

Very clever!

I was trying the idea of doing a array search over the weekend, and the output being wired to a case structure.  I like the idea of bypassing the case structure - seems more efficient. 
One thing that was still problematic however was that the initial analog input seemed to have an offset which I took care of with an offset correction.

Kudos!

 

2 1.93361 3.86722
2.5 2.3951 4.7902
3 2.8529 5.7058
3.5 3.309 6.618
4 3.766 7.532
4.5 4.2279 8.4558
5 4.69403 9.38806
5.5 5.1678 10.3356
6 5.651 11.302
6.5 6.1457 12.2914
0 Kudos
Message 5 of 5
(2,260 Views)