@Mr. Freeman: You don't use any actual integration function. I use Timer 2 on an interrupt, so I know exactly how much time has passed. This is my delta t. From there I essentially do a Riemann Sum approximation, which has so far turned out to be highly accurate. Kevin Watson's gyro code uses this same technique.
Also, there is no accelerometer default code, hence my trouble. I've had all the physics and everything in that StangPS animation worked out for weeks. If you look at Kevin's gyro code, I have duplicated and modified each individual function to deal with a single axis of the accelerometer at a time (you call each function twice, once for each axis). I also added another function to take the second integral.
This is that function:
Code:
long Get_Accel_Dist (char axis) {
long accel_dist = (axis == ACCEL_X_PORT) ? accel_x_dist : accel_y_dist;
// Return calculated distance to the caller
return (((accel_dist * ACCEL*SENSITIVITY * 5L) / (ADC_RANGE * ADC_UPDATE_RATE * ADC_UPDATE_RATE)) * ACCEL_CAL_FACTOR);
}
The second line is just an in-line conditional.
The Get_Accel_Velo() function is mostly the same, except you only multiply by ADC_UPDATE_RATE once. This is comparable to Kevin's Get_Gyro_Angle() function.
[edit]
@GRS: This mouse sensor sounds pretty cool, do you have any more information on how to implement it? Also, since the gyro code is very reliable (at least over a 15-second period), I would much rather use that than gear tooth sensors for tracking yaw. If our robot gets knocked, the GTS won't register any change, resulting is drastic error.
After reading those two threads posted above, I'm questioning whether the accelerometer will actually be accurate enough. So it would seem that my other options are gear tooth sensors (which are unable to account for unexpected lateral motion), and an optical mouse sensor (which I have no idea how to use).
[edit] This year's gyro is > 3 times more sensitive than what we've been given in the past. I'm hoping this will allow me to retain a certain amount of precision with a stronger noise filter. My filter right now however is just a dead band similar to the gyro's. Are there better techniques for eliminating noise?