- Tue Sep 14, 2004 1:00 pm
#1731
Well there's some inherent problems with your question:
The ADXL output 'gravities' - or more accurately accelerations. You are wanting miles per hour - or velocity. To get velocity from acceleration, whip out your old physics books. You'll have to integrate accel once to velocity. Integrate again and you'll have distance.
Integrating (roughly speaking) with a PIC is not too difficult. You'll need to check the ADXL reading multiple times a second (100hz should do) and record the gravity reading (units are m/s^2 right?).
1G = 9.81m/s^2
so for every reading you take multiply by the slice of time. For example, let's say the ADXL is reporting .01G at a specific point in time:
.01G * 100Hz = .01 * (9.81m/s^2) * 1s/100 (this is 100 hz)
delta v (change in velocity) = 0.000981m/s
This is your change in velocity. You've just increased speed a bit. Add this number to an overall velocity variable over time.
There are tons of problems associated with using 8-bit micros to do floating point math and big ugly numbers that I won't go into but it can be done. Also, the ADXL has a tendancy to have reading shifts due to temperature changes. These small changes get magnified by integration.
It's a sticky situation,
-Nathan