Efficent way to send data?

Hello -

I’ve hit a logistical wall here. I’m looking to read a rangefinder and bundle a defined list of numerical constants based on the range. So, for example, if the rangefinder reports 20 inches, send bundled data X, consisting of numerical constants of 1, 2, and 35. If the rangefinder reports 100 inches, send bundled data Y, consisting of numerical constants 50, 200, and 650. Then, later within my code, I want to unbundle this list and wire the outputs to their intended destinations.

**The trick is I want to be able to have 50+ ranges to check if the readout from the rangefinder is within, and 50+ different bundles with different constants wired to one unbundle later in the code. **

Any help is appreciated. Thanks!

What parts of code is your data originating from, and where is it going to? Is it going from dashboard to robot, from robot to dashboard, or between different loops in your robot code?

If it’s one of the first two, try this thread, and if it’s the last option, read into notifiers, they may be useful.

I’m calling a refnum which is set to a MaxBotics EZ1 rangefinder and calculating the voltage. This is all done within Pereodic Tasks.vi, and is triggered by a button.

The data is going nowhere (in this instance) - it’s simply being analyzed to see what numerical constants to use.

If I understand what you’re asking, you want a large constant lookup table consisting of distance ranges (10-20, 20-30, etc) and corresponding shooter-related outputs for each range. If this is what you want, I suggest you do it with two arrays: one array of doubles specifying distance and one array of clusters specifying the output. I’m attaching a VI that does this – feel free to experiment with it.

The VI I’ve attached is a constant model – that is, for any measured distance in the (customizable) range 10 to 20 it outputs the same result. If you want to reduce the amount of calibration data (and calibration time) you can program a linear model instead. The VI will need to determine the constant outputs at 10 and at 20 and interpolate along the line between them to determine the final outputs. This version of the VI will be more complicated, but it will work well with few calibration data points. If you want a challenge, this will pay off in the long run when you need to do last-minute recalibrations.

Hope this helps.

StaticLookup.vi (8.74 KB)


StaticLookup.vi (8.74 KB)

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/help/371361D-01/lvconcepts/for_loop_and_while_loop_structures/

Thanks! I was able to create the lookup table I needed!

Dom