This is a Mobile gimbal ,which is a Stabilizer for the phone when shooting videos.
I care a lot about this idea since I work in the media field as a videographer (previously as a graphic designer).
Using a device like this will make able to shoot amazing shots that are nearly impossible to do with just my hand.
The Idea of it is very simple, there are 3 servo motors that reflect to my hands motion, each motor reflect one axis so the 3 servos reflect to the 3 axis's (x, y, z).
I wanted to make a wooden prototype for the handle to imagine how the 3d printed part will look like as mistakes in laser cutting cost way less than in 3d printing.
Mobile 3d part to imagine the size of mobile phone in the 3d simulation according to the whole gimbal
This is the Handle design that would be 3d Printed.
It wasn't that same design the whole time it actually took a lot of modification to reach that result.
I made it smaller at the beginning but it wouldn't contain all the components in it.
This is the cover of the handle,
I had the intention to make it using 3d printing at the beginning but due the handle main part over size it was too difficult as my quot was already finished, so my instructor Mohanad proposed to me the idea of making it using PLY wood so I made it and it actually worked
Wood Prototype
Wood Prototype from behind
Mobile 3d part
3d Gimble Handle design
Handle main part
Handle Cover (holds the first Servo motor)
Simulating Electronic components in the 3d design to imagine their size in real life.
I used PLY wood to make the arms that will hold the 3 Servo motors and the Cover of the Handle.
All the parts couldn't be laser cutted in the same time so I divided them into 3 separate documents.
I used 3d printing to fabricate the Handle main part.
It took too many time so I leaved it to print over night so I didn't get the chance to take so many photos.
Laser cutting all the arms parts
3d printing the Final handle Part
3 servo motors: each one control an axis
gyroscope: detect the orientation of the device
Nano Arduino: provide the output of the coding to the electronic components.
I used NANO instead of UNO Arduino to consume less space in the project.
small breadboard: to connect all the electronic components with each others.
I used small breadboard instead of the regular one to consume less space.
jumpers: to conduct electricity between all components.
5V charger: to provide power for the whole project.
The power come form the 5V charger to power the Arduino NANO, gyroscope and the 3 servo motors (all connected in parallel).
The signal pins of servos are connected to digital pins 3,4,5
The connection of gyroscope: SCL to A5 and SDA to A4
I know that the project has to be powered with 5V, I used the battery at the beginning but the project didn't work as it seems to be that the battery was empty and I didn't have it's charger, so I used the regular 5V to power the whole project, and I used the switch adaptor to have the ON/OFF control over the project.
First of all the output of the code is the 3 motions about the 3 axis's(x, y, z) in the code they are called Yaw, Pitch and roll.
At the beginning 2 libraries are defied which are Wire and Servo, also there are some variable that are defined to be used in the code later.
Then we get some data from the accelerometer and gyroscope and do some calculations to turn them to degrees per second (which is angular velocity). then we want to turn this number to degrees only which is the data that the servos will receive, so we have to multiply them by time, which is got by a function called millis and stored in a variable called current time.
Then we add / subtract some numbers to the x, y and z to correct the final number and make it more accurate.
Then a small calculation is made to get the final degree number which will be stored in Yaw, Pitch and Roll variables.
But before they are used to drive the servos, they are mapped from -90, 90 to 0, 180 degrees
The Code I used:
#include<Wire.h>
#include<Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
const int MPU = 0x68;
int16_t AccX, AccY, AccZ, Tmp, GyroX, GyroY, GyroZ;
float elapsedTime, currentTime, previousTime, roll, pitch, yaw;
float accAngleX, accAngleY, gyroAngleX, gyroAngleY, gyroAngleZ, accErrorX, accErrorY, gyroErrorX, gyroErrorY, gyroErrorZ;
int c = 0;
float correct, j = 0;
float servo1Value, servo2Value, servo3Value;
void setup()
{
servo1.attach(3);
servo2.attach(4);
servo3.attach(5);
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B);
Wire.write(0x00);
Wire.endTransmission(true);
delay(20);
}
void loop()
{
// === Read Accelerometer Data === //
Wire.beginTransmission(MPU);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU, 6, true);
AccX = (Wire.read() << 8 | Wire.read()) / 16384.0;
AccY = (Wire.read() << 8 | Wire.read()) / 16384.0;
AccZ = (Wire.read() << 8 | Wire.read()) / 16384.0;
accAngleX = (atan(AccY / sqrt(pow(AccX, 2) + pow(AccZ, 2))) * 180 / PI) - 0.58;
accAngleY = (atan(-1 * AccX / sqrt(pow(AccY, 2) + pow(AccZ, 2))) * 180 / PI) + 1.58;
// === Read Gyroscope Data === //
previousTime = currentTime;
currentTime = millis();
elapsedTime = (currentTime - previousTime) / 1000;
Wire.beginTransmission(MPU);
Wire.write(0x43);
Wire.endTransmission(false);
Wire.requestFrom(MPU, 6, true);
GyroX = (Wire.read() << 8 | Wire.read()) / 131.0;
GyroY = (Wire.read() << 8 | Wire.read()) / 131.0;
GyroZ = (Wire.read() << 8 | Wire.read()) / 131.0;
GyroX = GyroX + 0.56;
GyroY = GyroY ;
GyroZ = GyroZ + 0.79;
roll = roll + GyroY * elapsedTime;
pitch = pitch + GyroX * elapsedTime;
yaw = yaw + GyroZ * elapsedTime;
delay(20);
servo1Value = map(roll, -90, 90, 0, 180);
servo2Value = map(yaw, -90, 90, 0, 180);
servo3Value = map(pitch, -90, 90, 0, 180);
servo1.write(servo1Value);
servo2.write(servo2Value);
servo3.write(servo3Value);
}
First of all I tried the idea with a cardboard prototype using only one axis, so that I can have a better idea about the project and how it should be working (that was during weeks before working on the project it self).
The first trial of controlling the Servo motor with the gyroscope after a lot (and I mean a lot) of troubleshooting with the code.
The output of the gyroscope alone was number in thousands, and the servo's inputs are numbers that refers to degrees from 0 to 180, so I did a lot of research to understand how to transfer these numbers and I found a very helpful video that did the same mobile gimbal with the same sensor and gyroscope, so I used the code he used and made some modifications on it so that it fits my project.
Trying the Gimbal on the wooden prototype after the code finally worked. It felt really amazing.
After a lot of troubleshooting and understanding the code I used from that video, I could finally say that I can use this code to drive three servo motors, so as soon as I fabricated the ply wood prototype using laser cutter, I tested all the fittings and put all components together and of course it didn't work at the beginning and did some troubleshooting but it worked eventually, so after I finished the assembly I didn't wait and asked one of my friends to record me right away.
This is my friend the final project presented to you after so many time, so many tries, so many troubleshooting, a lot of effort, a lot of going to lab.
After all that it's not perfect, but I am very happy by this result and I intend to upgrade it even more in the near future.
Cardboard Prototype (one axis)
ServoGyro Experiment
Gimbal on wooden prototype
OH I had a lot of feedback from the Instructors and my friends and I got through a lot of conversations about the final project of me and nearly all of my friends.
The Ideas of using Arduino NANO and metallic gear Servo motors were Saeed's Ideas.Also I got stuck a lot and asked help form my Instructors Menna and Mohanad.
Also I helped my friends with Ideas and troubleshooting on their projects and I solved actual problems with them.
I got an obvious feedback from nearly everyone which is the 3d printed handle was too big, I had to make it big so that it fits all the components, but it actually got bigger than I expected.
A quick photo session for the project :-)
I got stuck nearly every minute during this project, I did a lot of research and asked feedback from my friends and Instructors.
I couldn't make the code alone as the content I got from the diploma alone was not enough (which is normal for a project like this one) so I researched a lot until I found that code that I did my modifications on to fit my purposes.
I did a fatal mistake by exchanging the vcc and ground of the gyroscope sensor which made the NANO Arduino emits some smoke, luckily Saeed was near by and he took a look at the Arduino, luckily it was still working but the voltage regulator in it was burnt. After some troubleshooting and a very helpful consulting from the Instructor Shereef, I knew another mistake that I did to power the NANO Arduino and it worked eventually.
An Advice I would give to someone doing my project is do a lot of Logical thinking, that's going to help a lot to discover the problem, also ask other instructors not only yours cause everyone got a different background and could give different advices.
I would Paint the whole Project in Black
I would buy the third metallic Servo motor and try installing my mobile phone in it.
I would make the nice to have features which is 3 switches, one for each axis to give the user the ability to make a certain camera movement according to his own.