Step 1: The Hardware
the acceleration sensor senses the acceleration (speeding-up and slowing-down) of the robot, creates a voltage output (Vout=Vbias+acceleration*number) which is measured by the and the analog/digital converter in the DSP. In the DSP its already represented as numbers. Sample rate can be 200-600Hz. I have used the MMA6270Q sensor from www.freescale.com, and the TMS320F2811 DSP from www.ti.com .
We have studiet in the first year at the university, that the integral of the acceleration over time is equal to the actual speed, and the integral of the speed is the actual path/distance from the starting point. I have used the DSP to do this double numeric integral to produce this distance.
so, how it works:
1. we send a command to the DSP that the robot has to go forward 350 milimeters.
2. the DSP converts it into another number, as a final distance limit (N_limit)
3. the DSP checks the actual output value of the sensor, to set it as a base/bias for the next calculations (N_bias)
4. the DSP/robot turns on the motors, and starts going forward. also starts calculating the acceleration (N_in-I_bias)*number, and the numeric integrals and the actual distance (N_actual)
5. the DSP compares the N_actual to the N_limit at every new sampling period. If N_actual is greather, then turn off the motors and the robot stops.