Saturday, August 3, 2013

Part 1: Quadcopter Design

I've decided to document the design of my quadcopter and how I came to this design. I started with no knowledge of rc/quadcopters so I'll document some of what I have learned over the last couple months. One note is I designed most of the software myself, less so on the hardware side. Ultimately I'd like to 3D print a frame. But my day job is designing flight control laws for fighter jets and military type UAVs so that's where my main interest is as you may end up seeing in this design.

List of parts to blog:
Part 1: Quadcopter Design
Part 2: Integrating rc Transmitter and Receiver with Arduino
Part 3: ESC and motors (wiring and code)
Part 4: Sensors (reading in raw data and applying calibration)
Part 5: IMU - Kalman Filter Orientation Estimator
Part 6: Discussion on Arduino Boards
Part 7: Designing a shield for the Due
Part 8: Control Laws!!!!!


Part 1: Quadcopter Design:

Part 1A: Sizing/design on paper
Okay so the first question to ask myself: how big of a quadcopter. Or maybe a hexcopter, or more...
Well with the plan to develop and test it within my single room apartment I figured a 330mm (diagonal distance) frame would be right for now. Eventually I want to move to FPV but for now just get it flying and prove out the design of the flight control systems. With 330mm frame, this puts the quadcopter in the range of using 8 to 9 inch props. On a 330mm (~13inchs) frame, the tips of adjacent 9 inch props will be missing each other by 0.19 inches. Not ideal but doable.

So frame = 330m, props = 8 or 9 inches. The other components to size take a bit of playing with numbers. For this I used:
http://www.ecalc.ch/xcoptercalc.htm?ecalc&lang=en
Basically it is a quadcopter sizing program.

Important pieces of quad:
Batteries: 3 numbers to look at when picking a battery. It will look something like this:
3S 2000mah 20C
  • Number before S = # of Cells: basically the batteries have individual cells that each are about 3.7V (4.2V fully charged). The more cells, the more voltage, and thus more RPM from the motors. 3S = 11.1V, 4S = 14.8V
  • mahs (milli-amps) you can think of as energy. The more mah the more energy the battery has and thus the longer you can fly for, but that comes at the steep cost of weight.
  • 20C, this number is the discharge rating. If you take a huge battery and try to drain all of its energy within a few seconds it will probably overheat and start on fire or explode. The C number is basically a rating on how fast you can discharge. This will come from the sizing code. If it says its not high enough, then just up it until it works. Then add 5 or 10 for good measure...
ESC (electronic speed control): MOST IMPORTANT PIECE. well maybe not but very important, so don't shrug this off as just a number you need to meat. Usually listed as 10A, or 20A, etc. Its the amps it can handle before overheating and melting or starting on fire. What the ESC does is basically you send a command to this thing saying how fast you want the motor to spin (50%, 70%,  100%, or whatever) and it pulses the battery voltage at incredibly high frequencies so the DC motor spins at that rate. You can only turn power on or off, you can't just send the power at 50%, so what you have to do is send the full power half the time. So to get this done with quick response to changes and accuracy you need a good ESC and you need to flash it with better software than they typically come with (will be covered later). But basically the stock firmware runs at around 12-14 kHz switching which is a VERY VERY high pitched annoying sound. When you see videos of quads with high pitched annoying sounds it means they have shit firmware. If you flash them with SimonK you get much better response and pushes the frequency they switch at  over 16kHz I believe which you can't hear. All i hear from my motors now is the props spinning the air, otherwise the motor itself is quiet (in the audible range. i'm sure it's still damaging my ears and pissing off all the dogs nearby)

Motor: I don't even know where to start on motors... So many different makers and sizes. the motors are generally numbers like this: 2812-1200kv. The first 2 numbers (28) have something to do with size. 35 motors are more powerful than 28 motors. I think its either diameter of motor or maybe its shaft length. Then the second 2 numbers (12) are another size, again larger is more powerful, but the primary size is the first 2 numbers. So: 2808 < 2812 < 3505 < 3520 and so on. (must admit I am not entirely sure on this part but to the best of my knowledge this what it means...) The last number is far more important, kv = rpm per volt (why k=rpm, I have no idea....). So a 1000kv motor with a 3S battery (11.1V) will be spinning at full at 11,100 rpm (in theory?).
Generally larger motors you spin slower. So a 35 motor will spin larger props at a slower speed. 22 motors will spin smaller props at high rpm.

Props: Number is usually shown as something like 9x45 or 9045. First number is diameter, last numbers are pitch. If you were spinning the prop through jello, each 360 degree spin of the propr would move you 4.5 inches forward (i think) not real important, 4.7 or 4.5 are fairly normal for 8 to 10 inch props.
3 choices of prop types. Nylon plastic: cheap and usually poorly balanced but good for early testing where you might flip or run into walls and break props. Carbon-plastic fold: these are good props, very stiff and good performacen without costing much. Carbon fiber: expensive but good, no ideal for early testing but once the quad is working, probably switch to these.

So now with this knowledge I played around with eCalc varying numbers until I got a good design. 330mm frame = ~150g, plus some more for a micro controller and cables/plugs and such I started with a no drive weight of 200g. For motors I started with using Turnigy  motors because a lot are in the system and they are cheap as hell. I would recommend using them to at least start sizing. Then switch to better motors. My plan was to buy some cheap turnigy's and then switch to something like tiger motors later.


So here is what I ended up on eCalc:


Boxes in red are variables I tweaked. Blue are the numbers I was trying to optimize. In hover you want less than 50% throttle. Good rule of thumb, unless there is some reason you don't need good thrust to weight. Ideally I tried to get to a thrust to weight of 3:1, so 33%. Got close. Flight time is short but not to bad. all up weight ended up being about 800g's. The yellow box is to note I am using too much power at full throttle. its close enough. These are cheapo motors anyways, a couple W's won't do much harm (i hope). I suspect the motors might get hot if I run them at full power for a while. Eventually I plan to switch to tiger motors or some other non cheapo Chinese motors anyways. Couple other things to note, battery load is only 15.91C, so 20C should give me good buffer of safety. motors are 13A at full throttle. They do make 15A ESC's I think but I want some buffer here to so 20A will work well.

So thats my quad design I ended up with.

Part 1B: Pick out other required components
So above I covered frame size, props, motors, batteries and ESC.  I'll list the actual pieces at the end that I bought. But theres a couple other parts need to be addressed.
First and probably more important than the ESC is an IMU. You need some sensors to know what orientation the quadcopter is in inorder to stabilize it. Need atleast a gyro and accelerometer. A magnetometer helps a lot also. I'll go into more details on the IMU in a later post but I went with a 9dof unit that includes all 3 pieces in one.
Next piece is a receiver and transmitter. Need at minimum 4 channels. There's a ton of brands. Spektrum and Futaba are good ones. I ended up getting a 6 channel transmitter, the Spektrum dx6i which is a VERY good transmitter. I got a 7 channel receiver, AR7010 (why 7? well... i found one for sale that was cheaper than the 6 also the 7 channel has a failsafe mode that allows you to program in a value for each channel incase you lose communication with the transmitter. So I can set that if it loses comm, put motors to 30%, normally they'd go to 0% but the AR7010 lets me specify it). I ended up putting more money into the transmitter and receiver than I planned. You can get by much cheaper than I did but in the end, this is a fairly critical piece so I'd spend a little more plus this will be used on all of my future quads. it s one time upfront buy so make it good.

One note, before buying ESC's make sure they are on this list:
http://wiki.openpilot.org/display/Doc/RapidESC+Database#RapidESCDatabase-ESCSpreadsheetbyTomSn0w
A later post I will go into flashing the ESCs, but you need to make sure to get ones that are capable of having the firmware flashed.


Final part: Flight controller. There's a bunch out there like the NAZA, KK2, the ArduCopter board (they really need to change their name since they aren't arduino based anymore, what a joke.). I wanted a true arduino based system so I could write all the software myself. I considered going with a linux based board like a Raspberry Pi or something but decided to stay with a microcontroller like an Arduino (an actual arduino unlike the px4 ARDUcopter boards now). I'll make another post on the arduino selection later but I ended up with an Arduino Due.


Part 1C: Buy parts
So to sum it all up, here is the final list. I ended up buying tons of other pieces you may see in this blog later like pressure sensors and a gps and a bluetooth module but here is the original parts list:

Quad components
Frame: DJI F330 (25$)
Props: 9x4.7 - 3 sets of (2xCW + 2xCCW) of nylon plastic + 1 set of carbon fold (~15$)
ESCs: Hobbyking 20A BlueSeries (4x10 = 40$)
Motors: Turnigy SK3-2826-1130kv (4x15 = 60$)
Battery: Turnigy 3s 3000mah 25C (25$)
Sensors: 9Dof Razor IMU from sparkfun (Bonus: has an Atmega328 on it!) (125$)
Transmitter: 6 Channel - Spektrum DX6i (140$)
Receiver:  7 Channel AR7010 (found one for 50$)
Flight controller: Arduino Due (50$)

Other
Battery Charger: Turnigy Accucel 6A + 6A AC-DC power cord adapter (30$)
Prop Balancer: not sure where I got it (~5$)
Jewelry weight scale: (~5$)
Connectors and cables: (10-20$)

Total = 550-600$

Other random parts I bought later that you may end up needing:
FTDI: to reprogram the ATmega328 on the 9dof IMU razor (link)
USBasp Programmer: for flashing the ESC's

Note you could save quite a bit here by not spending almost 200 on a transmitter and receiver and get by for like 80. Also a lot of this is 1 time costs. Like the battery charger and such. I just tell myself most of this can be reused on later quads. So quad#1 costs like 600$ but quad #2 might be much better and bigger but only be like another 250$.


In the next blogs I'll go into detail on assembling this all together. I'll also explain writing the software like calibrating the sensors and designing and kalman filter orientation estimator and then go into developing some of the control laws to fly the thing. I also recently designed my own shield to sit over the Arduino due to plug everything into, so I don't have a rats nest of wires.

No comments:

Post a Comment