Gyro Stabilizer

It is a gyroscope gimbal that keeps a point still while the base is moving. It works by using an accelerometer to send information to 3 servos which move in opposite directions to where the base is tilted.

Engineer

Matthew H.

Area of Interest

Mechanical Engineering

School

The Kings Academy

Grade

Incoming Senior

Final Milestone

My final milestone for my gyro stabilizer is building a frame or structure for it. I originally spent a week designing a base for it on a program online called Sketchup for it to be 3D printed. After I finished designing it, I sent it to be printed.The design had a few problems so I had to go back and fix those. By the time I was finished with fixing the problems, I could not get the 3D printed parts in time for the demo night. I had to create a cardboard base instead. I tried to make the cardboard base resemble the one I created on Sketchup as much as I could, but cardboard has it obvious limitations. I could not cut it as precisely and accurately as designing it for the 3D printed version. The cardboard base was also fragile and couldn’t actually hold a camera as I intended it to be. However, building this cardboard version showed me how the gyro stabilizer actually works and which parts go where. Because my breadboard had to be placed sideways next to the battery, the accelerometer had to be moved to a flat plane in order for the gyro stabilizer to work as I have programmed it to.
A few difficulties I had with moving the accelerometer off the breadboard was with the wiring. It was my first time soldering onto a PCB and I tried to do too much on the PCB initially. When I first tested if it worked, I fried my accelerometer because I connected two wires together and ended up shorting the board. I had to get a replacement because of it and that took some time as well. My next attempt was to directly take each signal from the PCB and connect it to the original pins on the breadboard that the accelerometer used when it was still on there. This made the process a lot easier and the PCB cleaner.

Third Milestone

Third Milestone

My third milestone for the gyro stabilizer is the addition of a 3rd axis and another servo. This new direction is the compass direction, or the yaw. It makes the horizontal rotations on the gimbal smoother by turning in the opposite direction of the base. To do this, I had to get a new accelerometer/gyroscope with a magnetometer which measures the horizontal rotation. I trialed through two different MPU9250 modules which both use different programs to run. This process altogether took me over two weeks to figure out the third axis. I had to do a lot of research to get the module to give useful and correct numbers.
The first roadblock I encountered was after I tried a few program and integrating them together. Through the serial monitor, where I can see the raw numbers produced by the MPU9250, I was able to convert the numbers to degrees which the servos were programmed to use. After a lot of testing, the servos would not start. I had my program check several times and I could not find a bug or error in the code to why the servos could not run. I tested each step of the program to make sure that the code was properly run through by sending a checkpoint message in the serial monitor after each block of commands. The code would pass through every other command smoothly, but it would skip the servo’s write commands. After spending a few days trying different solutions and variations to the code, I could not manage to get it running . They suggested that I try a different MPU9250 that ran on different programs.
The first problem I encountered with the new MPU9250 was the shipping time, which took a week. During the week, I did more research and testing on the accelerometer as to why it would not cooperate with the servos. I also started a sketchup for my 3D printed part for my gimbal. I was new to 3D printing and drawing so this was a learning process for me. In the end, I created a simple and rigid gimbal structure. This was done for the future work when the gimbal program would work and I could properly build a mount for a camera.
After a lot of researching and testing, I finally found a program that was capable of running servos and communicating with the MPU9250 board. This program came with a completely different library on which the code ran on as well. The numbers that this code produced was also different than all other programs. I had to find a way to convert this to degrees so that my servos would run properly. After getting that solved, I had to work on the third axis using the new function of the MPU9250 which was the magnetometer. This worked like a compass where it could tell which was it was facing. The problem with this was that the numbers it produced was between -180 to 180, but not in a 360 degree loop. The numbers were not linear and I could not find a solution to make it so that it would properly produce numbers usable with the servo. At that point, I tried using the gyro function and have it work opposite to which way the base was rotating. This worked surprisingly well and the gimbal was able to smoothly rotate a point and not have stiff movements. Over the period of two weeks, I learned a considerable amount about accelerometer and gyroscopes and how it was programmed. I learned a lot about how to interpret the raw data and how to counterbalance it using the servos so that a point can be able to stay still while the base moved. I also learned how to create the files for 3D printed parts using a program called Sketchup. I had trouble with Sketchup as well, but I was able to fix my problems by going over my models and getting rid of unnecessary lines and parts. It caused complications before with the 3D printer program where it cannot print anything without volume. This milestone took the most time, but I also learned the most from trying to complete it. From the previous step to this one, I completely changed my code essentially starting the project over again. I learned the most as I had to start from the ground up.

Second Milestone

My second milestone is the complete physical build of the gyro stabilizer and the communication between the MPU6050, an accelerometer/gyro and the two servos. The complete build was not too difficult or too long because I had most of it complete from the first milestone. This step however was more of a permanent step. I had to super glue one servo onto the axis of the other servo which was not easily reversible. Super glue was the only option as tape could not hold up the servo and it would easily slip off. I also had a bit of trouble with the superglue by getting quite a bit of super glue on my hands which then delayed me as I had to remove the super glue off my hands with paint thinner. Through this mistake, I learned to be more cautious around super glue and how to handle it more carefully. The other part to this milestone was getting the accelerometer/gyro to communicate with the two servos. Essentially, the servos had to move in the opposite direction to the movement of the base. The accelerometer data had to be converted to degrees which was done by a pre-written program.
The MPU6050 can calculate the Pitch and Roll, but not Yaw. Pitch and roll can be calculated as it only requires a gyro inside the chip to sense which way it was tilted and how much. Yaw is different and it can sense direction similar to a compass. Yaw, however, cannot be determined by a gyro. The MPU6050 did not have the necessary instruments to calculate yaw, which was the magnetometer which can calculate rotational position. If I was to create a gyro stabilizer that can stabilize horizontal direction, I would need a different chip with an accelerometer and a magnetometer. Overall this step was a completion or wrapping up step as it brings the base project, with pitch and roll, together from several different pieces.

First Milestone

My first milestone for my gyro stabilizer project consists of getting the accelerometer/gyro to give a reading on the serial monitor and the 2 servos to work. I first had to download I2C libraries. I2C is a simple program that essentially allows communication between two boards using 2 pins only. It is necessary to have this program as it condenses the need for the use of more pins. In this project, it is used for communication between the arduino nano board and the accelerometer. It was generally simple to get the accelerometer to give a reading on the serial monitor. Some of the setup code was available on the internet which helped defining variable on the accelerometer that I used, which was the MPU6050. The more difficult part was calibrating the MPU6050. Each unit is different than the next. The number it gives on the serial monitor is not zeroed. A calibration is needed for the MPU6050 since each unit is different. A program can be found on the internet which can calibrate the MPU6050 by producing numbers in order to make numbers on the display as close to zero. The numbers given to offset the unit is different than numbers produced originally so it is difficult to zero the board. It is necessary to calibrate the board because when it interacts with the servos, it can then properly balance the servos without it favoring one side over the other. The servos were simple to program. They take a simple one line command since it is a digital output that moves each motor. The servos each turn half a circle and use degrees to define which position the servos are to be in, which later will make programming simple as it is only a addition or subtraction command to make it communicate with the accelerometer. I print the movements of the servos onto the serial monitor as well to visible check what works. I followed this tutorial for the first part of my project

Raw data read from the accelerometer

mpu6050serialmonitorprint

Starter Project

Starter Project

My starter project is the exploding star color organ kit. It reacts to sound or music by lighting up LEDs in the shape of a star depending on the beat of a music or the pulses in speech through a microphone. It is controlled by two IC units that vary the timing and the sequence of LEDs that light up. This project was generally simple aside from a roadblock that impeded my progress because I did not put parts in correctly due to a lack of involvement and carefulness. Paying more attention to specific details during the build could have saved me more time, but I definitely learned quite a bit from my mistakes.
I was able to take away how to read specifically on labelled parts to differentiate between the two because they may look similar, but they can serve completely different functionalities. Essentially, I swapped the place of a PNP and NPN transistor which look exactly the same except for a small pin number written on them. A transistor is a device with three terminals known as the Emitter, Base, and Collector.  A NPN transistor is most common bipolar transistor which has a n-regions on the outside and a p-region on the inside, and opposite for the PNP transistor. NPN transistors require a power supply while the PNP needs a negative power supply. NPN transistors generally have a higher electron mobility than the PNP transistors as well. These two transistors work in opposite ways where the NPN transistor is on when there is current at the base terminal while the PNP turns on only if there is no current at the base terminal. NPN transistors send electrons from the collector to the emitter while the PNP does the opposite. Switching the places of those different transistors negates the function it had on the board because of the opposite functions it does.
I also learned more about variable resistors and how they functioned on the board. Variable resistors allow me to tune and change how fast the LEDs were able to sequence and the sensitivity to the sound or music around the microphone. I was also able to reinforce skills and knowledge that I have already known during the project such as soldering and what each component on the board did such as a resistor, capacitor, and transistor. I have soldered in the past, but I was able to work more with soldering to refine my technique and learn how to desolder using a desoldering pump. A resistor limits the flow of current by preventing electron flow, a capacitor stores electric charge like a battery, and a transistor can act like a switch or amplifier.

Leave a Comment

Start typing and press Enter to search