Comments (22)
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:
from gy521.
@mw66
Thanks for reporting this issue, not seen this drift in my tests so far.
I have not enough information to analyze this problem
As the other library seems to work well - can you provide a link? Might give a clue what they do differently.
In the data you provided I see a repeating pattern that every 3 or 4 measurements the data changes a bit.
This is not strange as e.g. getYaw() returns an internal variable that only is updated after a call to read().
As read() is throttled, not all reads are factual reads to keep the load on the device within certain limits.
This GY521_THROTTLE_TIME is default 10 milliseconds.
You might try to switch of the throttling by setThrottle(false) and see if that improves your readings.
But I have another data conversion issue:
Your other issue, could it be that you need to calibrate ? line 200-210
You state you have output 28 at 90 degrees.
What value do you get at zero degrees?
from gy521.
I got ~+/- 0.xx at zero degrees.
from gy521.
Can you run - GY521_test_1.ino for a few minutes?
you may change these line to be all float's to get a bit more detail (I'll make an issue to patch the example)
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();
from gy521.
Capture another try, number going down this time:
CNT PITCH ROLL YAW
1040 0.268 2.047 0.001
1041 0.268 2.047 0.001
1042 0.636 2.528 0.001
1043 0.636 2.528 0.001
1044 0.636 2.528 0.001
1045 0.636 2.528 0.001
1046 0.636 2.528 0.001
1047 359.995 3.084 0.001
1048 359.995 3.084 0.001
1049 359.995 3.084 0.001
CNT PITCH ROLL YAW
1050 359.995 3.084 0.001
1051 0.336 2.654 0.001
1052 0.336 2.654 0.001
1053 0.336 2.654 0.001
1054 0.336 2.654 0.001
1055 0.948 2.108 0.000
1056 0.948 2.108 0.000
1057 0.948 2.108 0.000
1058 0.948 2.108 0.000
1059 0.948 2.108 0.000
CNT PITCH ROLL YAW
1060 0.706 2.335 359.999
1061 0.706 2.335 359.999
1062 0.706 2.335 359.999
1063 0.706 2.335 359.999
1064 0.611 2.540 359.998
1065 0.611 2.540 359.998
1066 0.611 2.540 359.998
1067 0.611 2.540 359.998
1068 0.620 2.600 359.998
1059.996
1074 0.306 2.285 359.996
1075 0.306 2.285 359.996
1076 0.722 1.748 359.995
1077 0.722 1.748 359.995
1078 0.722 1.748 359.995
1079 0.722 1.748 359.995
from gy521.
looks like:
setThrottle(false)
fix the drifting problem, now the numbers are stable.
from gy521.
The raw measurements look indeed stable - maybe longer run needed to be sure.
looks like:
setThrottle(false)
fix the drifting problem, now the numbers are stable.
It might be that the default throttle time is too large (10 milliseconds), need to investigate how it would affect the math.
from gy521.
Actually I concluded to quickly, it still drift slowly, but not as steady in one direction as not setting setThrottle(false)
.
with setThrottle(false)
, longer output:
CNT PITCH ROLL YAW
15300 358.378 359.556 0.346
15301 358.414 359.785 0.345
15302 358.751 359.422 0.346
15303 358.763 359.415 0.346
15304 358.566 359.638 0.346
15305 358.440 359.743 0.345
15306 358.672 359.528 0.346
15307 358.598 359.509 0.346
15308 358.286 359.817 0.346
15309 358.459 359.618 0.347
CNT PITCH ROLL YAW
15310 358.452 359.706 0.347
15311 358.498 359.341 0.347
15312 358.498 359.636 0.347
15313 358.679 359.504 0.348
15314 358.401 359.779 0.348
15315 358.670 359.529 0.348
15316 358.573 359.623 0.348
15317 358.595 359.394 0.348
15318 358.783 359.413 0.348
15319 358.867 359.310 0.348
...
CNT PITCH ROLL YAW
48170 348.432 357.415 1.723
48171 348.701 357.050 1.723
48172 348.600 357.196 1.723
48173 348.437 357.374 1.723
48174 347.974 357.733 1.722
48175 348.146 357.647 1.722
48176 348.115 357.695 1.722
48177 348.110 357.199 1.722
48178 348.486 357.243 1.722
48179 348.973 356.692 1.721
CNT PITCH ROLL YAW
48180 348.947 356.909 1.721
48181 348.215 357.329 1.722
48182 348.255 357.405 1.722
48183 348.592 357.262 1.722
48184 348.044 357.813 1.723
48185 347.883 357.908 1.723
PITCH 358.378 => 347.883
ROLL 359.556 => 357.908
YAW 0.346 => 1.723
Is there any caching going on? why the math error accumulate?
from gy521.
Can you run - GY521_test_1.ino for a few minutes? you may change these line to be all float's to get a bit more detail (I'll make an issue to patch the example)
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();
here is the output with floats:
GY521_LIB_VERSION: 0.5.1
start...
ACCELEROMETER GYROSCOPE TEMPERATURE
ax ay az gx gy gz T
0 0.06 -0.01 -1.07 -5.73 -1.62 -0.71 17.19
1 0.06 -0.01 -1.06 -5.48 -1.58 -0.50 17.09
2 0.06 -0.00 -1.06 -5.91 -1.53 -0.50 17.09
3 0.06 -0.01 -1.06 -5.76 -1.66 -0.55 17.19
4 0.06 -0.01 -1.06 -5.83 -1.73 -0.66 17.19
5 0.06 -0.01 -1.06 -5.89 -1.61 -0.57 17.24
6 0.06 -0.01 -1.06 -5.76 -1.37 -0.67 17.24
7 0.06 -0.01 -1.07 -5.91 -1.68 -0.45 17.19
8 0.06 -0.01 -1.07 -5.80 -1.34 -0.83 17.19
9 0.06 -0.01 -1.05 -5.59 -1.63 -0.65 17.14
ACCELEROMETER GYROSCOPE TEMPERATURE
ax ay az gx gy gz T
10 0.06 -0.01 -1.06 -5.77 -1.47 -0.56 17.19
11 0.06 -0.01 -1.07 -5.85 -1.66 -0.60 17.14
12 0.06 -0.01 -1.06 -5.73 -1.53 -0.53 17.14
13 0.06 -0.01 -1.05 -5.88 -1.48 -0.53 17.19
14 0.06 -0.00 -1.06 -5.80 -1.56 -0.73 17.19
15 0.06 -0.01 -1.07 -5.80 -1.68 -0.50 17.09
16 0.06 -0.01 -1.06 -5.82 -1.44 -0.67 17.19
17 0.06 -0.01 -1.06 -5.84 -1.53 -0.27 17.19
18 0.06 -0.02 -1.06 -5.98 -1.65 -0.62 17.19
19 0.07 -0.01 -1.07 -5.69 -1.60 -0.52 17.19
...
ACCELEROMETER GYROSCOPE TEMPERATURE
ax ay az gx gy gz T
360 0.06 -0.01 -1.06 -5.93 -1.60 -0.46 17.89
361 0.06 -0.01 -1.07 -5.93 -1.54 -0.76 17.94
362 0.06 -0.01 -1.07 -5.86 -1.54 -0.54 17.89
363 0.06 -0.01 -1.06 -6.00 -1.48 -0.72 17.99
364 0.06 -0.01 -1.06 -5.79 -1.44 -0.47 17.99
365 0.06 -0.01 -1.07 -5.80 -1.60 -0.56 17.94
366 0.07 -0.01 -1.07 -5.72 -1.56 -0.61 17.94
367 0.06 -0.01 -1.06 -5.83 -1.82 -0.56 17.94
368 0.06 -0.01 -1.06 -5.81 -1.41 -0.51 17.89
369 0.06 -0.01 -1.06 -5.71 -1.47 -0.46 18.04
ACCELEROMETER GYROSCOPE TEMPERATURE
ax ay az gx gy gz T
370 0.06 -0.01 -1.06 -5.70 -1.45 -0.57 17.94
371 0.06 -0.01 -1.06 -5.78 -1.73 -0.32 17.94
372 0.06 -0.00 -1.06 -5.84 -1.63 -0.63 17.99
373 0.06 -0.01 -1.08 -5.85 -1.62 -0.40 17.99
374 0.06 -0.01 -1.07 -5.79 -1.63 -0.60 17.99
375 0.06 -0.01 -1.06 -5.63 -1.36 -0.52 17.85
376 0.06 -0.01 -1.07 -5.78 -1.66 -0.82 17.89
377 0.07 -0.01 -1.07 -5.84 -1.84 -0.53 17.89
378 0.06 -0.00 -1.06 -5.54 -1.60 -0.61 17.94
379 0.06 -0.00 -1.06 -5.77 -1.64 -0.50 17.85
ACCELEROMETER GYROSCOPE TEMPERATURE
ax ay az gx gy gz T
380 0.07 -0.01 -1.06 -5.93 -1.59 -0.73 17.85
381 0.06 -0.01 -1.06 -5.80 -1.52 -0.53 17.94
382 0.05 -0.01 -1.06 -5.66 -1.75 -0.68 17.99
from gy521.
Looks stable to me now, some random noise.
from gy521.
Looks stable to me now, some random noise.
PITCH 358.378 => 347.883
~10 degree, still random noise?
from gy521.
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 should have been more explicit on that.
I need to investigate why the raw values are stable and the PITCH ROLL YAW are drifting.
Hope to find some time coming days or next week to recreate the issue.
from gy521.
Note:
Combine GY521_test_1.ino with pitch roll yaw demo, ==> put the data in a spreadsheet format.
new demo sketch GY521_debug.ino or so.
from gy521.
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 --
from gy521.
Added the above sketch to the version 0.5.2 PR.
from gy521.
@mw66
Did some investigation of the status of the GY521 code and the Pitch Roll Yaw part is not correct and needs a lot of work.
I will make this explicit in the readme file of the 0.5.2 version.
Must find a long timeslot to dive into and redo the math needed.
Sorry for the inconvenience.
from gy521.
Can you generate e.g. 10-20 lines ?
Here you are:
12344 0.080 -0.027 -1.069 -5.824 -1.389 -0.420 16.954 216.632 166.603 298.401 -1.4 -4.3 -85.5
12345 0.083 -0.016 -1.063 -5.794 -1.473 -0.679 17.095 216.602 166.535 298.390 -0.9 -4.5 -85.5
12346 0.083 -0.016 -1.063 -5.794 -1.473 -0.679 17.095 216.602 166.535 298.390 -0.9 -4.5 -85.5
12347 0.090 -0.019 -1.072 -5.702 -1.427 -0.695 17.095 216.567 166.443 298.379 -1.0 -4.8 -85.1
12348 0.078 -0.020 -1.064 -5.847 -1.588 -0.802 17.001 216.577 166.387 298.372 -1.1 -4.2 -85.7
12349 0.078 -0.020 -1.064 -5.847 -1.588 -0.802 17.001 216.577 166.387 298.372 -1.1 -4.2 -85.7
12350 0.080 -0.021 -1.062 -5.756 -1.405 -0.511 17.048 216.551 166.299 298.364 -1.1 -4.3 -85.5
12351 0.080 -0.021 -1.062 -5.756 -1.405 -0.511 17.048 216.551 166.299 298.364 -1.1 -4.3 -85.5
12352 0.085 -0.030 -1.065 -5.779 -1.733 -0.626 17.001 216.515 166.194 298.354 -1.6 -4.5 -85.2
12353 0.087 -0.021 -1.056 -5.893 -1.282 -0.557 17.048 216.497 166.160 298.349 -1.1 -4.7 -85.1
12354 0.081 -0.023 -1.062 -5.901 -1.573 -0.603 16.954 216.498 166.103 298.343 -1.2 -4.3 -85.5
12355 0.081 -0.023 -1.062 -5.901 -1.573 -0.603 16.954 216.498 166.103 298.343 -1.2 -4.3 -85.5
12356 0.081 -0.017 -1.072 -5.649 -1.443 -0.511 17.001 216.477 166.032 298.335 -0.9 -4.3 -85.6
12357 0.081 -0.017 -1.072 -5.649 -1.443 -0.511 17.001 216.477 166.032 298.335 -0.9 -4.3 -85.6
12358 0.088 -0.021 -1.061 -5.840 -1.656 -0.702 16.954 216.436 165.936 298.324 -1.1 -4.7 -85.1
12359 0.088 -0.021 -1.061 -5.840 -1.656 -0.702 16.954 216.436 165.936 298.324 -1.1 -4.7 -85.1
12360 0.077 -0.021 -1.061 -5.939 -1.458 -0.603 16.954 216.438 165.846 298.315 -1.1 -4.1 -85.7
12361 0.077 -0.021 -1.061 -5.939 -1.458 -0.603 16.954 216.438 165.846 298.315 -1.1 -4.1 -85.7
12362 0.080 -0.023 -1.064 -5.802 -1.573 -0.664 16.906 216.408 165.754 298.304 -1.2 -4.3 -85.5
12363 0.080 -0.023 -1.064 -5.802 -1.573 -0.664 16.906 216.408 165.754 298.304 -1.2 -4.3 -85.5
12364 0.088 -0.022 -1.058 -5.863 -1.359 -0.618 17.001 216.370 165.667 298.295 -1.2 -4.7 -85.1
12365 0.088 -0.022 -1.058 -5.863 -1.359 -0.618 17.001 216.370 165.667 298.295 -1.2 -4.7 -85.1
12366 0.081 -0.024 -1.064 -5.924 -1.405 -0.863 16.954 216.362 165.571 298.281 -1.3 -4.4 -85.4
12367 0.081 -0.024 -1.064 -5.924 -1.405 -0.863 16.954 216.362 165.571 298.281 -1.3 -4.4 -85.4
12368 0.079 -0.023 -1.065 -5.962 -1.527 -0.656 17.048 216.344 165.480 298.270 -1.3 -4.2 -85.6
12369 0.081 -0.021 -1.068 -5.855 -1.305 -0.725 16.954 216.329 165.433 298.263 -1.1 -4.3 -85.5
12370 0.081 -0.021 -1.068 -5.855 -1.305 -0.725 16.954 216.329 165.433 298.263 -1.1 -4.3 -85.5
12371 0.085 -0.021 -1.069 -5.863 -1.473 -0.580 16.954 216.298 165.346 298.254 -1.1 -4.5 -85.3
12372 0.085 -0.021 -1.069 -5.863 -1.473 -0.580 16.954 216.298 165.346 298.254 -1.1 -4.5 -85.3
12373 0.078 -0.019 -1.061 -5.786 -1.443 -0.611 17.001 216.290 165.262 298.245 -1.0 -4.2 -85.7
12374 0.080 -0.024 -1.071 -5.832 -1.366 -0.504 17.095 216.276 165.200 298.240 -1.3 -4.3 -85.6
12375 0.080 -0.024 -1.071 -5.832 -1.366 -0.504 17.095 216.276 165.200 298.240 -1.3 -4.3 -85.6
12376 0.084 -0.020 -1.063 -5.832 -1.427 -0.603 16.954 216.243 165.122 298.231 -1.1 -4.5 -85.3
12377 0.081 -0.019 -1.067 -5.977 -1.573 -0.603 17.001 216.236 165.070 298.225 -1.0 -4.4 -85.5
12378 0.081 -0.019 -1.067 -5.977 -1.573 -0.603 17.001 216.236 165.070 298.225 -1.0 -4.4 -85.5
12379 0.073 -0.018 -1.061 -5.908 -1.466 -0.756 17.001 216.231 164.985 298.213 -0.9 -3.9 -86.0
12380 0.073 -0.018 -1.061 -5.908 -1.466 -0.756 17.001 216.231 164.985 298.213 -0.9 -3.9 -86.0
12381 0.085 -0.023 -1.055 -5.840 -1.458 -0.626 17.001 216.183 164.886 298.204 -1.2 -4.6 -85.2
12382 0.085 -0.023 -1.055 -5.840 -1.458 -0.626 17.001 216.183 164.886 298.204 -1.2 -4.6 -85.2
12383 0.084 -0.019 -1.074 -5.969 -1.435 -0.733 17.048 216.167 164.805 298.192 -1.0 -4.5 -85.4
12384 0.084 -0.019 -1.074 -5.969 -1.435 -0.733 17.048 216.167 164.805 298.192 -1.0 -4.5 -85.4
12385 0.080 -0.018 -1.067 -5.954 -1.374 -0.634 17.001 216.152 164.718 298.182 -0.9 -4.3 -85.6
12386 0.080 -0.018 -1.067 -5.954 -1.374 -0.634 17.001 216.152 164.718 298.182 -0.9 -4.3 -85.6
Thanks for looking into this issue.
from gy521.
@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:
from gy521.
@mw66
Thanks for the table, looking per column the standard deviation is small which indicates the values are stable.
Within the accuracy of the decimals printed I could reconstruct the three angle columns (last three).
For PRY I need more time to dive into the math, expect it will take a lot of time to understand.
(as there are many other issues and work etc to be done).
alas it is on my todo list for 2024.
from gy521.
@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:
The words of jrowberg is about the math I need to dive into.
To be continued
from gy521.
@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:
ElectronicCats/mpu6050#74The 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).
from gy521.
Checking other peoples code is good to do after studying the math, just copying it without understanding is risky.
from gy521.
Related Issues (20)
- Examples use GetAngle instead of GetAccel HOT 2
- Enabling the interruptions HOT 6
- Calibration never zeros out HOT 7
- Add multiWire support
- improve performance + precision
- improve precision HOT 1
- swire support HOT 27
- Invalid data without Reset while initializing the begin HOT 9
- version number incorrect in .h and .cpp (minor)
- getting position from distance = acceleration * time HOT 7
- Raw data HOT 1
- getYaw, getPitch and getRoll go past 360 degrees HOT 19
- small bugfix in readCalibration HOT 3
- How can I get data from 2 sensors? HOT 4
- Shifted pitch and yaw measurement HOT 19
- use float variables in example GY521_test_1.ino HOT 1
- refactor GY521_readCalibration_2 (generate calibration code snippet) into a proper calibrate() function, as part of GY521 init HOT 9
- Feature request: API for low-pass filter HOT 4
- add getAddress() function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gy521.