0
$\begingroup$

i am trying to make an angle meter, using the UNO and MPU6050, following joop brokking video tutorials,

when utilizing the accelerometer, the results are fine,

however when i try to use gyroscope (each one alone) do not get the expected result

when rotating the sensor from 0 to 90 degrees, the output change from 0 to 60~70 degrees only

so what is wrong is it the code, the gyroscope is damaged

here is the code

 refresh ();
 angle += (gyro_x - cal_x) * (millis () - timer) / 1000.0;
 Serial.println (angle);

refresh (); is a function that updates gyro_x

the MPU6050 is fixed so that it rotatea in one direction only

later on i took this false measure and applied it in a complementary filter, the result was plausible, and varies around 0.5 degrees, i still need to get it to an accuracy of 0.0x

$\endgroup$
0
$\begingroup$

This will be a bit troublesome to help with, as you didn't post all of your code or more importantly your exact errors (Serial.print()), but for general infos, and for others it's enough. Questions regarding troubleshooting your wiring/c code directly, I think should be directed to arduino.stackexchange.com There are countless questions and answers there.

You need to integrate the gyro if you plan on getting an angle...

An example code (in wiring) to integrate your gyroscope readings would be, with 0.01 being your sampling constant $\Delta t$

void update_int(double *u, double *y)
{
static double x[1] = {0};
double x1[1];
y[0] = x[0];
x1[0] = x[0] + 0.01*u[0];
x[0] = x1[0];
}

However keep this in mind, gyros are accurate short term, but long term have 'drift' and will become unreliable.

You can read more infos about this at adafruits gyroscope comparison site.

Generally one "fuses" several different sensor readings to make one, such as your 'complimentary filter'

Other options are the Madgwick Filter and the Kalman Filter....achieving a variance of +/- 0 dps is nearly impossible, but you can get pretty close using some clever techniques and one of the mentioned filters. A comparison of all three filtering techniques can be found at OlliW's website.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.