Saturday, May 18, 2013

Making the Frame

For the frame of the quadcopter, I wanted to use a 3D printer because many hobbyists either have one or access to one. This would allow anyone to print out the frame and simply attach the electronics and start flying. So I taught myself how to use SolidWorks and designed a frame to be printed. My design was based off of a design by an MIT student who attempted a similar project. It consists of a central holder for the electronics and places the motors in an X configuration, complete with landing gears.

The quadcopter frame in SolidWorks
The design from MIT

I then printed the part at Stanford's PRL (Product Realization Lab) using their ProJet 3D printer which uses wax support material so it would be easy to melt away after the print. After the print finished, the part looked great but I quickly realized some flaws in the design. The biggest flaw was that it just seemed too heavy. The printing material was heavier than I anticipated and as a result I had serious doubts about its ability to fly. Another problem that was made clear was that it wasn't the most sturdy design. I carelessly dropped it from my bed and one of the arms broke. If this quadcopter was to fly, it would often be dropping from height and would most likely break upon impact and since the frame was a single 3D print it wouldn't be easily fixed.

Fresh out of the printer

Melting off the wax

Quadcopter

So it was back to the drawing board. Armed with the lessons I learned from my previous design, I decided the new version had to have several key features. It had to be lighter, this meant less plastic or at least a lighter plastic. It had to be stronger and more easily fixed. Finally it had to be more easily printed. The first version was a difficult print and may be too hard to do with a hobbyist grade machine. With these parameters in mind, I decided that the best way to do this was use carbon fiber rods for the arms and only 3D print the base that held the electronics and motor holders. This decision had several advantages. First, the carbon fiber meant less plastic and made it much lighter while also stronger. By printing out only the motor holders and electronics base, the prints were simpler, cheaper, and easily replaceable. As an added bonus, the entire frame ended up being cheaper because I only had to use about a dollar of carbon fiber and the print only took 0.66 cubic inches of support and printing material so it was a fraction of the cost of the old frame.

Check out the CAD files at: https://sourceforge.net/projects/nanoquad/files/?source=navbar.

The revised design (the square rods are carbon fiber)
The printed parts. One of the problems was the support material was inside the holes which made it difficult to clean out.

Post support material

The assembled frame

The final quadcopter


Testing the IMU

After I soldered the board together, it was time for me to test all of the sensors and implement an IMU (inertial measurement unit). The gyro and accelerometer both use I2C communication, so I had to get familiar with the Wire library for the Arduino. I quickly wrote up some test programs for the Arduino to make sure that the communication worked and sure enough it did! The only unintuitive thing I had to do was call endTransmission(false) because the communication didn't want a stop message after querying for the data registers when reading the measurements.

After proving that the sensors worked, I wanted to test my algorithm for measuring orientation. I decided to implement it in Processing for the time being so that I could tweak it without having to reprogram the board. So I wrote a program that simply would send the readings over Serial to the computer to be processed.

For my orientation detection, I use a Kalman filter to integrate the readings from the gyro and accelerometer together to get a better approximation of the board's orientation. For those who don't know, a Kalman filter is a very powerful tool that can be used to combine two different sensors and get a better approximation of your position or orientation than either could do individually. Because of this, Kalman filters are used extensively in localization. Essentially, Kalman filters work by combining two sensors, one that directly measures the information and another that indirectly can be used to correct for errors. So in the case of a quadcopter, where I want to measure the roll, pitch, and yaw of the board, I use the gyroscope to directly measure the angular acceleration. Then through basic kinematics, it is easy to convert these accelerations to angles accurately. However, a problem with the gyroscope is that it drifts making it inaccurate over long periods. Meanwhile, the accelerometer can be used to measure the tilt of the board using the gravitational acceleration. While it doesn't drift over time, it is very noisy because it is sensitive to any other linear motion the board is subjected to. By combining the two, you get the best of both worlds. They gyro provides the immediate, precise readings while the accelerometer corrects for its drift over time.

In my Processing sketch, I query the Arduino for sensor readings and then pass them through a Kalman filter and display the results on my computer. This allows me to test the filter's functionality and tweak the filter parameters. I based my code off of the examples from this forum. I also have attached all of my code below. Enjoy!

Check out my code at: https://sourceforge.net/projects/nanoquad/?source=directory

Sunday, April 28, 2013

Reflow Soldering!

The boards I ordered recently arrived and it was time for assembly. Because I am designing for minimal cost, I had to hand solder the accelerometer and gyroscope. Both were QFN packages so I couldn't simply use a soldering iron for the job. Instead I needed to learn how to use soldering paste and do basic reflow.

The boards from SeeedStudio.

So I talked to a couple people and they suggested hot air rework. The problem was I didn't have a hot air rework station and didn't feel like shelling out $100 for one. So when I went to Fry's electronics to buy some soldering paste, I saw a $14 personal skillet and I remembered this great tutorial from SparkFun. They found that a skillet is a fitting alternative to a toaster oven and in some ways works better. I decided to give it a try and I wasn't disappointed.

The skillet from Fry's. Only $13.99!
Cooking up some electronics!

The most difficult part of the process was applying the soldering paste since I didn't have a stencil or syringe. Instead I used my pair of tweezers to "paint" it on the pads which I wouldn't recommend. It worked, but it was tedious and messy. (I have since ordered a syringe). After adding the parts to the board, I simply laid it on the skillet and watched as the parts reflowed and slid into place. Everything seemed to reflow fine save a one or two solder bridges which were easily fixed with a soldering wick.

The board after reflow. You can see some small solder bridges.

One disadvantage of the skillet method (and toaster?) is that you can only reflow one side. This meant that I designed my board with all of the reflow parts on top so I could hand solder the bottom. This wasn't too hard as I only really had to solder the microcontroller which is pretty easy with the help of soldering braid.
The hand-soldered bottom of the board.

The end result looked great and I was really pleased with skillet reflow. It was fast, cheap, and easy to do! Check out my next post where I will show how I tested the boards.

The finished product.

Saturday, March 9, 2013

Nano-Quadrocopters

It has been a long time since my last post, but recently I have been working on a new project with the Stanford Robotics Club. I am designing nano-quadrocopters which are both low-cost and easily replicable. With the boom of quadrocopters in the DIY community, I still have not seen many which are very cheap and easily built for applications like swarm robotics. Hence this project's goal is to design quadrocopters that are cheap (under $50) and easily built (3D-printed base). My hope is after, I can build many of these quads and experiment with things like swarm robotics but more on that later.

I have just finished ordering all of the parts for the quadrocopter and the BOM is promising ($33.11). I hope to get a prototype up and running in the coming weeks. Now I just have to wait for the parts to arrive and in the meantime begin coding the stabilization software.

Look out for more posts with my progress. And check out the schematic and PCB for the main controller below.


The first revision PCB

First revision schematic