Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a gyro/accelerometer with Arduino

I've tried this sketch provided by arduino.cc. (I've an MPU6050 GY-521 breakout board.)

I think it works fine. It gives a weird set of numbers I can't get any meaning out. It says that those are raw values.

How can I convert them into meaningful values?

The output is as follows. Even when the whole thing is kept stationary, it gives changing values! Is this meaningful? Then how is it to be understood?

(What I only know is that the temperature value is meaningful :D)

June 2012
WHO_AM_I : 68, error = 0
PWR_MGMT_2 : 0, error = 0

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 260, 120, 15572
temperature: 31.047 degrees Celsius
gyro x,y,z : -24, -234, -240,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 304, 12, 15608
temperature: 31.000 degrees Celsius
gyro x,y,z : -7, -234, -232,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 160, 100, 15716
temperature: 31.000 degrees Celsius
gyro x,y,z : -8, -241, -248,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 192, 56, 15712
temperature: 31.000 degrees Celsius
gyro x,y,z : -36, -212, -222,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 212, 100, 15440
temperature: 30.906 degrees Celsius
gyro x,y,z : -32, -253, -240,
like image 402
Anubis Avatar asked Sep 06 '12 10:09

Anubis


People also ask

Can we use accelerometer as gyroscope?

Yes they both can be used to together describe the motion of a device, but they can also be used to correct each other. For example, I read and experimented that the drift in the gyroscope can be corrected by using the accelerometer even though they don't essentially measure the same thing.

How do you combine accelerometer and gyroscope data?

Combining 3D accelerometers and gyroscopes This can be accomplished with a sensor fusion strategy. Sensor fusion techniques combine sensory data from disparate sources and generate information that has less uncertainty, or more accuracy.

Does Arduino Mega have gyroscope?

Arduino Mega 2560 Gyroscope Control Code MPU6050s are configurable accelerometers and gyroscopes. So you are capable to measure acceleration, rotation speed and temperature. The gravity is added to the acceleration. From these data the current angle of MPU6050 is calculated in degrees.

How do I use Arduino accelerometer?

The accelerometer uses very little current, so it can be plugged into your board and run directly off of the output from the digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin.


1 Answers

You need to look at the datasheet to translate the raw values to meaningful ones. Look for tables like this one for the gyroscope:

gyro table

If you used the default values, FS_SEL will be 0. That's the sensitivity setting. So to translate your raw gyroscope values to degrees per second, you divide them by 131. You can see your numbers come out under 2 degrees per second or so, which is a reasonable margin of error.

For the default accelerometer sensitivity, you divide by 16,384 to get the value in g (the force exerted by the earth). You're getting on the order of 0.01g for the x and y axes and 0.95g for the z axis, which is within a reasonable margin of error for the chip staying still with the z-axis pointed toward the earth.

like image 133
Karl Bielefeldt Avatar answered Oct 03 '22 01:10

Karl Bielefeldt