Range Finder Help

My team wants to have the new range finder from this years kit of parts control the speed of a motor as we get a smaller and smaller distance from the hoops. Is this possible? By the way, I am not new to Labview, but am not anywhere near professional. Any help would be appreciated.

This is possible. The simple version of what you will need to do is this:

  1. Take the output of the range finder
  2. Scale this to the appropriate RPM of the motor for distance
  3. Feed the scaled value to a PID controlling the motor

The appropriate scaling value will depend on your specific launcher.

Getting even more basic:
Connect power to the rangefinder.
Use the AN (analog) output of the rangefinder.
Connect this to an analog input of the analog bumper on the cRio. (Be sure to connect ground to the same port!)
Read the analog port (can’t help you there) voltage.

Each 0.01 volt is an inch. So 0.65 volts is 65 inches.

Would I be able to scale this to what our team needs?

If I used an Analog Setup to use my range finder like the labview example,could I use the voltage output from the AnalogChannelGetAverageVoltage.vi and connect that into the output channel of a MotorSetOutput.vi?

The Motor Set vi uses a range of -1 (full reverse) to +1 (full forward). Transform the Analog Voltage Get vi result to turn distance (0.01 volts per inch) into whatever power you want to run the motor at. You’ll probably want something a little fancier than a simple multiplication – a basic lookup table where input is distance and output is power should be about right.

Sorry, stupid question. How do I do that?

I would suggest experimenting with your shooter to make sure that your kicker works on along a linear equation(ie. does a .01 voltage increase equal a inch), and then derive an equation to match your found voltages to get the ball in the basket.

The “Interpolate 1D” vi is an easy way to implement a lookup table. Provide it with two arrays, one of input values and one of the assocated output values. See the “1D Interpolation.vi” LabVIEW example to play with how it works.

Or, more simply:

You experiment, and find that at a distance of (0.73 volts = 73 inches), setting your motor control to +0.48 makes the shot 9 out of 10 times. You also find that at 1.45 V (145") a motor control of +0.83 is ‘perfect’.

You create a table:

Measured  Motor
Distance  Voltage
73         +0.48
145        +0.83

This is a “look up table”.

With such a table, you might be able to assume that a distance halfway between 73 and 145 (=110) should use a motor control of halfway between 0.48 and 0.83 (=0.65). Doing this kind of math to ‘guess’ at what might be a good value in between known-good values is called “interpolation”.

Or, you can just experiment every 12 " and see what you get, and use the value in the table that’s closes to the measured distance.

Be sure to take into consideration what to do if there’s a robot between you and the spot you want to measure from.