Quote:
Originally Posted by DominickC
Yes, that's exactly what I want! I've taken a look at the attached VI and I'm pretty lost.
I see where I am able to define my distances, and my outputs. I assume that the first distance (10) corresponds to the first row of outputs (1, 3, 5). From there, you lose me.
|
You understood it correctly. The distances constants correspond to the outputs constants. To clarify, I could compile them into a table:
------------------------------------------
|Distance range | Out 1 | Out 2 | Out 3|
|below 20 | 1 | 3 | 5 |
|20 to 30 | 2 | 6 | 8 |
|above 30 | 5 | 8 | 9 |
------------------------------------------
I'm tunneling the measured distance and the array of distances into a for loop. The tunnel for the distance array is an auto-indexing tunnel -- basically instead of outputting the array it outputs the value in the array that corresponds to the current iteration. Within the for loop I'm using a shift register to keep track of an index. If the measured distance is less than the distance at the current index I replace the remembered index with the current index, but if the measured distance is greater than the distance at the current index I keep the remembered index. When the loop completes, the shift register contains the largest index with a distance less than the measured distance. I then extract the output from the outputs array at that index.
For background information on for loops, auto-indexing, and shift registers in LabVIEW see this NI site:
http://zone.ni.com/reference/en-XX/h...op_structures/