-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why when I run the GY521_pitch_roll_yaw example code, all the numbers slowly increase 0 -> 359 -> 0? #47
Comments
I also tried another library, at lease the output numbers are stable, does not auto-incremental over time when the chip is not moving at all. But I have another data conversion issue: |
@mw66 In the data you provided I see a repeating pattern that every 3 or 4 measurements the data changes a bit. You might try to switch of the throttling by setThrottle(false) and see if that improves your readings.
Your other issue, could it be that you need to calibrate ? line 200-210 |
I got ~+/- 0.xx at zero degrees. |
Can you run - GY521_test_1.ino for a few minutes? int ax = sensor.getAccelX();
int ay = sensor.getAccelY();
int az = sensor.getAccelZ();
int gx = sensor.getGyroX();
int gy = sensor.getGyroY();
int gz = sensor.getGyroZ();
int t = sensor.getTemperature(); |
Capture another try, number going down this time:
|
looks like:
fix the drifting problem, now the numbers are stable. |
The raw measurements look indeed stable - maybe longer run needed to be sure.
It might be that the default throttle time is too large (10 milliseconds), need to investigate how it would affect the math. |
Actually I concluded to quickly, it still drift slowly, but not as steady in one direction as not setting with
PITCH 358.378 => 347.883 Is there any caching going on? why the math error accumulate? |
here is the output with floats:
|
Looks stable to me now, some random noise. |
PITCH 358.378 => 347.883 ~10 degree, still random noise? |
Sorry, my comment was on the Accelerometer gyroscope temperature data from the - GY521_test_1.ino. I need to investigate why the raw values are stable and the PITCH ROLL YAW are drifting. |
Note: |
Created a debug sketch that combines the raw accel + gyro + temp with the derived angle and pitch, roll yaw values. Can you generate e.g. 10-20 lines ? //
// FILE: GY521_test_debug.ino
// AUTHOR: Rob Tillaart
// PURPOSE: output raw and cooked data from sensor for analyzing.
// URL: https://github.com/RobTillaart/GY521
#include "GY521.h"
GY521 sensor(0x68);
uint32_t counter = 0;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(__FILE__);
Serial.print("GY521_LIB_VERSION: ");
Serial.println(GY521_LIB_VERSION);
Wire.begin();
delay(100);
while (sensor.wakeup() == false)
{
Serial.print(millis());
Serial.println("\tCould not connect to GY521: please check the GY521 address (0x68/0x69)");
delay(1000);
}
sensor.setAccelSensitivity(0); // 2g
sensor.setGyroSensitivity(0); // 250 degrees/s
sensor.setThrottle();
Serial.println("start...");
// set calibration values from calibration sketch.
sensor.axe = 0;
sensor.aye = 0;
sensor.aze = 0;
sensor.gxe = 0;
sensor.gye = 0;
sensor.gze = 0;
Serial.println("\n\tACCELEROMETER\t\tGYROSCOPE\t\tTEMP\tPRY\t\t\tANGLE");
Serial.println("\tax\tay\taz\tgx\tgy\tgz\tT\tPITCH\tROLL\tYAW\tX\tY\tZ");
}
void loop()
{
sensor.read();
float ax = sensor.getAccelX();
float ay = sensor.getAccelY();
float az = sensor.getAccelZ();
float gx = sensor.getGyroX();
float gy = sensor.getGyroY();
float gz = sensor.getGyroZ();
float t = sensor.getTemperature();
float pitch = sensor.getPitch();
float roll = sensor.getRoll();
float yaw = sensor.getYaw();
float x = sensor.getAngleX();
float y = sensor.getAngleY();
float z = sensor.getAngleZ();
Serial.print(counter);
Serial.print('\t');
Serial.print(ax, 3);
Serial.print('\t');
Serial.print(ay, 3);
Serial.print('\t');
Serial.print(az, 3);
Serial.print('\t');
Serial.print(gx, 3);
Serial.print('\t');
Serial.print(gy, 3);
Serial.print('\t');
Serial.print(gz, 3);
Serial.print('\t');
Serial.print(t, 3);
Serial.print('\t');
Serial.print(pitch, 3);
Serial.print('\t');
Serial.print(roll, 3);
Serial.print('\t');
Serial.print(yaw, 3);
Serial.print('\t');
Serial.print(x, 1);
Serial.print('\t');
Serial.print(y, 1);
Serial.print('\t');
Serial.print(z, 1);
Serial.println();
counter++;
// delay(1000);
}
// -- END OF FILE -- |
Added the above sketch to the version 0.5.2 PR. |
@mw66 Sorry for the inconvenience. |
Here you are:
Thanks for looking into this issue. |
@RobTillaart Just want to let you know, according to the discussion of the issue in other library, I may have a faulty chip, the data and conversation is here: |
@mw66 For PRY I need more time to dive into the math, expect it will take a lot of time to understand. |
The words of jrowberg is about the math I need to dive into. To be continued |
You may also check this library: https://github.com/gabriel-milan/TinyMPU6050 where I can get stable ~80 degree reading for 90 degree chip position, so I think there maybe a bug in i2cdevlib (and mpu6050 since it uses the former). |
Checking other peoples code is good to do after studying the math, just copying it without understanding is risky. |
I didn't move my chip, but:
it goes on and on.
The text was updated successfully, but these errors were encountered: