Introduction: Gimbal Calibration With IMU MPU-6050

Some gimbals are hard to calibrate because there is no way to graph the position in real time.

This instructable will show you how to graph the position of a 2 axis gimbal for tuning a PID. To achieve that I'm using a second IMU and an Arduino linked with Processing over serial.

Step 1: Materials

In my case, I'm using an EvvGC 1.3 open source gimbal controller. This controller doesn't have a position graph tool. I've tried to stream the angle data over serial, but this task is time-consuming for the gimbal controller and it's not a good way to tune the PID. So, you'll need a second IMU and an arduino to stream data in real time without consuming controller's resources.

You will get:

- Gimbal

- IMU (I'm using an MPU-6050)

- Arduino (I'm using an Arduino Nano)

EvvGC Gimbal controller: http://www.rcgroups.com/forums/showthread.php?t=1...

IMU MPU-6050: https://www.sparkfun.com/products/11028

Step 2: Wiring

For getting the setup completed you'll need to wire the MPU-6050 to the Arduino using SPI.

Here it's how I wired it:

MPU-6050--------Arduino Nano

---SDA------------------A4---

---SCL------------------A5---

*Don't forget to wire the pins: 3.3v and GND.

Step 3: Code - Arduino

I used the code developed by Kristian Lauszus, TKJ Electronics: http://forum.arduino.cc/index.php/topic,58048.0.h...

So, first you should download the code: https://github.com/TKJElectronics/Example-Sketch-...

Then, open the file MPU6050.ino (IMU>MPU6050>MPU6050.ino) and load in your Arduino.

Step 4: Code - Processing

In the processing code, I just did a few changes in the graph drawing for being easy to calibrate a gimbal.

Open IMU>MPU6050>Graph>Graph.pde

Then, you will have opened the following: Graph.pde, Convert.pde and DrawAxis.pde

For being easy to see just the useful axes (x and y) you can comment or erase the following parts in DrawAxis.pde:

/* Draw gyro x-axis */

/* Draw acceleromter x-axis */

/* Draw complementary filter x-axis */

/* Draw gyro y-axis */

/* Draw acceleromter y-axis */

/* Draw complementary filter y-axis */

Also, I added a few lines to show the grid.

Original code: https://github.com/TKJElectronics/Example-Sketch-....

Code including the changes: Graph.pde and DrawAxis.pde // Use these files to replace the originals in IMU>MPU6050>Graph>

Step 5: Putting All Togueter

Now, you've setup your sensor. Stick the IMU to the bottom part of your Gimbal.

Connect the Arduino to the USB and run Graph.pde in Processing, then the graph should appear.

I recommend to graph one axis at the time, you can do it by commenting the following lines in Graph.pde:

drawAxisX(); (comment to hide x axis).

drawAxisY(); (comment to hide y axis).

Step 6: Tuning the PID

Now you're ready to tune your Gimbal.

First, power the Gimbal and don't forget you should load the camera on the gimbal before starting the calibration process.

For tuning you can follow these steps:

-Perform a manual perturbation on the position of one axis.

-Check the graph

-Depending on the response, change the P, D or I constants with the tuning tool. (I'm using EvvGC GUI 0.4.1.2)

*It`s recommended to make a table with angle of perturbation vs the gimbal settling time.

Remember these tips:

P: Proportional constant. A high proportional gain results in fast response. If the proportional gain is too high, the system can become unstable.

D: Differential constant. It's useful to improve the stability of the gimbal. A high differential gain results in a smaller settling time. If the derivative gain it's too high the system oscillates.

I: Integral constant. It's useful to correct the steady-state error. In a few words, it helps the gimbal to reach the zero position.

Step 7: Results

When you have a graph of each axis it's easy to tune the gimbal's PID in a few minutes.

This instructable was made to help mounting a DIY multispectral camera on an UAV for vegetation sensing:

Have fun.

Thanks for reading.

For more information, please visit: www.southmade.org