MPU6050 Gyro and Acc values

Hey everyone. I'm trying to design a heavy duty gimbal. I will use MPU6050 sensor to give me the angles and movements of the camera so i can use arduino and stepper motors to stabilize. I've found the code below to read gyro and acc values but i dont know which type of output they will provide ? How can i calculate the steps required -imagine 1.8 step angle stepper motors- for stabilization using the data that this code gives out. Thank you.

#include <helper_3dmath.h>
#include <MPU6050.h>
#include <MPU6050_6Axis_MotionApps20.h>
#include <MPU6050_9Axis_MotionApps41.h>

#include <Wire.h>
#include <I2Cdev.h> 
#include <MPU6050.h> 
MPU6050 mpu; 
int16_t ax, ay, az; 
int16_t gx, gy, gz; 
void setup() {
Serial.println("I2C starting...");
Serial.println("Testing connection...");
Serial.println(mpu.testConnection() ? "MPU6050 success" : "MPU6050 failed");
void loop() {
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); 
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.print(gz); Serial.println("\t");

The MPU-6050 is a rate gyro, and measures the rate of rotation, not angles.

You can use the accelerometer to measure the two stationary tilt angles, as described here: How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing-DFRobot

All the details are in the device data sheet:


Depending on the stepper driver You didn't tell about micro stepping like half step, or smaller, can give a better resolution than 1.8 degrees.

1 Like

I will use ULN2003 just for prototpye. Firstly, im just trying to understand the units of the output i will get. Like if the sensor / camera is tilted 36 degrees then my motor will have to rotate 20 steps. I just want to know how can i get this 36 degrees from the output data.

Multiply steps by 1.8.

is suitable for only a certain kind of steppers. Already running them? Else, please post a link to the steppers You intend to use.

im using 28byj-48 for testing

stepper.step (( newangle - offset ) / 1.8)

where newangle means the new angular position of the cencor after it moved in an axis. while offset is the starting angular value. Does this code would make my stepper motor to move required steps to stabilize ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.