mikeshub / Pololu_Open_IMU

24 stars 19 forks source link

Lots of Drift,YPR #6

Open duckman01 opened 8 years ago

duckman01 commented 8 years ago

Hi Mike, have been playing with your open and a V3. I have very large drift in Yaw and the pitch and roll are increasing (this is with the IMU sitting stationary) I did find that my Z axias was -15726 +17611 = +1885/2 = +942, X = -59, Y = -277 . I have tried with and without Merlins cal defines. I have also played with the accel scale factors, which enabled the roll or the pitch to stop increamenting but not both. I have also tried changing the Mag gaus (is there a LSB offset to put in?) as well as the Accel g Were did you get the Accel scale factor from? as it seems different from the data sheet, but this all could be due to me as l have limited programming skills. What l did like was that compared to The Pololu AHRS which my V3 had up to +-15 yaw difference on some headings when tilted, with your code this was down to +-2, but the Yaw would start stable for a second or 2 then start drifting along with the Roll and Pitch. Any guidance would be appreciated. Regards Kevin

duckman01 commented 8 years ago

Adding to the above, can you confirm that l need to #define scale factor, line 77 - 79 and the correct method of doing this, as l put a figure which seems incorrect Xaxis max 16209- -59(offset) =16150 9.8/16150 = 6.068111455 but get error, expected '}' before numeric constant. edit as above correction, l believe the scale factor should be 0.00060240963 ( 6.0240963 should have been -4 error) and l put it in at the above line (the max with offset should have been 16209 - -59=`16268) 9.8(speed of gravity?)/ 16268 = 06.0240963 -4 error. 0.00060240963 *16268 = 9.8 then uncomment #define use user cal //the scale factor is the 9.8/(max - offset)

define ACC_SCALE_X 0.00060240963//ACC_SCALE_FACTOR_D_6

define ACC_SCALE_Y 0.00059146599//ACC_SCALE_FACTOR_D_6

define ACC_SCALE_Z 0.00058791769//ACC_SCALE_FACTOR_D_6

moeburn commented 7 years ago

Did you ever figure it out? I have perfect drift-free outputs on the official Pololu code, but it's very slow, noisy, and laggy to respond to movements. This guy's (mikeshub) code is extremely fast, but I'm getting constant drift on all 3 axes. I have figured out how to use his calibration for both the magnetometer, and the accelerometer, and I confirmed that I have them completely perfectly calibrated because I took the calibrated magneto and accel outputs (but not the AHRS outputs) while rotating the device around a bunch, and put them on a scatter plot - once I had the correct calibration values, the scatter plot would look like a perfect centered circle.

So I know I have the calibration down perfect. But it didn't make any difference at all to the constant drift! All three AHRS outputs - roll pitch and yaw - are just constantly either increasing or decreasing, even though the device itself is perfectly steady, sometimes at a rate of 0.1 to 0.5 degrees per second. That's not useable in any situation. And how the heck is the yaw value drifting at all? It's supposed to be tied to the magnetometer! I even went out and bought a second v3 just to be sure I didn't have a broken device, but nope, same issue. I've tried this on both an Arduino Micro and Arduino Uno, using multiple USB cables, computers, and rooms of the house, with no luck.

I think this might actually be an issue with timing. I have read that the Mahoney filter (which is what mikeshub's code uses) is extremely sensitive to timing issues, and if it thinks it is getting data faster or slower than your device can output or process data, it will lead to these weird drift effects. Please let me know either here or at moeburn@gmail.com if you ever figure out how to get this guy's code (or anyone else's other than Pololu's official code) working!