AeroQuad Frame Redesign

As discussed earlier, I rebuilt my quadcopter frame.  The original design worked fine, but I had a few new design goals with this frame;

  • Integrated motor mounts with the arms for simplicity
  • Separate arm holding plates and electronics module for the ESCs
  • Bigger central FCU container (for an AQ 2.0.7 shield)
  • FCU board mounting direct to a levelled metal plate
  • Vibration decoupling between the arms and the electronics module

Anyway, here’s the finished result;

Finished frame with AQ shield installed

The finished frame appears above.  Design is very similar to the old design, except now there’s four plates.  Plates 1 & 2 bolt together to hold the arms in place.  Plates 3 and 4 bolt together with spacers to provide an enclosure for the ESCs and other electronics.  The ATmega attaches to the top of plate 4 with nylon standoffs, and the FCU container bolts onto Plate 4.

Finished frame, side view

The landing gear is a set of TRex 450 (I think) landing gear that I got from HK for like $3.  The battery straps on with velcro under the landing gear.  The end result is quite a lot taller than the original design, but it has a lot more space inside and can be disassembled in a much more straightforward manner.

AeroQuad 2.0.7a Custom Board

Got my customized AQ 2.0.7 board, and I spent the weekend transferring all my existing sensors and such across to it.

AQ 2.0.7a Custom Board

So, it turned out that the board actually has an error on it!  Eagle went and isolated a piece of ground plane, so you have to hook a small air wire from GND on the barometer to GND on the LLC.  Oh well.  Other than that, everything went pretty swimmingly moving my sensors across to it.  I had to completely ruin my old AQ v1.9 board to get everything out intact though.

It also turns out that the LEDs that are supplied with the AQ kit are not normal LEDs, they are actually LEDs with built-in resistors.  So my current board has no LEDs on it while I wait for my order of special LEDs to arrive.

The board worked pretty well straight off.  I discovered that the magnetometer is basically useless in its current position, too much interference from the power systems under it.  I’m thinking of desoldering the magnetometer board and relocating it onto a mast above the quad so it can get clear of the interference.

AeroQuad 2.5.1 – Code Upload via ICSP

So I’ve been fooling with the new AeroQuad 2.5.1 code, and I’ve integrated some fixes posted by Kenny9999 (an forum user), as well as integrated my battery level compensation code.  Unfortunately though, putting in both makes the code a little too big to fit into the 32256 bytes you have available on the Uno with the Optiboot bootloader.

Since I have an ICSP programmer (Bus Pirate to the rescue!) I decided I’d go and upload the code directly.  That way I can utilize the entirety of the flash!

As discussed in my post about using a Bus Pirate as an ICSP programmer, you need to set up a new hardware definition for Arduino.  Mine’s called tiny45_85, but we’ll use that for a new ATmega328p definition.

Edit boards.txt in tiny45_85, and add the following; 16MHz (w/ BusPirate)

Essentially what this does is create a new entry in the Arduino IDE’s “Boards” menu, which will upload using the Bus Pirate programmer definition we made in attiny45_85/programmers.txt, setting the maximum upload size to 32760 bytes at 16MHz.  It will use the build core for a normal Arduino.

What’s notable is that the default fuse setup for an Arduino (here) will set the high fuse to 0xD6.  This sets up the Arduino so on boot it will boot the bootloader.  In other words, code execution will not begin at address 0x0000.  This won’t work if you have no bootloader.  The fuses need to be changed so that the BOOTRST flag is unprogrammed.  In AVR-speak, this means it’s set to a value of 1 (0 means “programmed).  So, this means that the high fuse needs to be set to 0xD7.  No other fuses need to be changed.

To change this, you’ll need to run AVRDUDE with a command line like this;

avrdude -p m328p -c buspirate -P COM8 -v -C ..\etc\avrdude.conf -U lfuse:w:0xFF:m -U hfuse:w:0xD7:m -U efuse:w:0x05:m

Once I figure out exactly how to do it through the IDE, I’ll integrate that into boards.txt above and edit this post.  If you don’t change that fuse, your code might work, since the flash will by default be filled up with 0xFF’s, but if your code happens to be big enough to go into where the boot is trying to start, it probably won’t work.  Set the fuses right.

After that’s all done, you should be able to fire up your Arduino IDE, and see a new entry in Boards called “ATmega328p 16MHz (w/ BusPirate)”.  Select that as the target board, upload and voila!  Your code will be burned directly onto the ATmega328p with no bootloader through ICSP.

I’d suggest that you use the bootloader (since then you can use the built in USB upload) unless you have specific reasons not to (eg, pin state on boot causes the bootloader to lock up, or you need the space).

AeroQuad – Light, Barometers and Throttle Adjust

Had a bright and sunny day yesterday, and I got the chance to test out a theory I’ve seen discussed on the AeroQuad forums – namely that sunlight affects the BMP085 barometer.  The sun was bright and warm, but the air was cool.

Took the quad out to the park and flew it around.  Altitude hold was crazy again – big random swings up and down, unpredictable behaviour.  So I flew it over into a spot where there was a lot of shade, and the altitude hold went sensible pretty much straight away.  Unfortunately, it then drifted over into a spot where it was in full sun and went crazy and crashed reasonably hard 🙁

During the repairs, I folded over a loop of cardboard (blacked on the inside), and attached it to the BMP085 so that it’s sitting in shade all the time.  At the next flight, it flew awesomely – I kept it up for a whole battery pack.  Admittedly I flicked altitude hold off a couple of times, but it was holding very well compared to how it has been.  So, it looks like keeping the BMP085 in the dark is the go.  I also moved the altitude sampling code to a 33Hz task loop, since sampling it at 50Hz is too fast for the BMP085.  That seems to have helped a lot too.

Lastly, this was also a good opportunity to test my throttle adjustment code doing some maneuvering.  What I’ve done is modify the AeroQuad code so that it increases the throttle in proportion for the difference in battery voltage between now and when it took off.  That way the altitude hold (and acrobatic for that matter) modes should not need to keep pushing up the throttle all the time to account for the battery running out.

So far, that code seems to work reasonably well.  I had to apply some corrections to throttle, but nowhere near as much as I’ve had to do in the past, and when transitioning out of altitude hold back to acrobatic, the throttle was “nearly right” for hovering, instead of being way too low like it usually is.

A patch for the 2.4.2 release is available here.

AeroQuad 2.4.2 – Barometer with the Uno

I picked up a BMP-085 barometer breakout board for my quadcopter last week.  I decided to pick up one because the new AeroQuad 2.4.2 code is able to be compiled to support altitude hold and be able to fit on an Arduino Uno.

However, there’s an issue.  Apparently the version of the Optiboot bootloader that comes with the Uno has a bug in it where it reserves flash RAM equal to the biggest bootloader (~2k or so), even though Optiboot only takes up 512 bytes.  This means that if your sketch compiles to over ~30k, you can compile but you can’t upload.  You get a very obtuse error message.

There’s a way to fix this though.  Make use of the ArduinoISP I made earlier to reflash the bootloader!

There’s a fixed version of Optiboot that allows upload, but I realized that I could upload the Aeroquad binaries directly to the Arduino and bypass the bootloader entirely, and then I could use the entire 32k flash (!).  Optiboot be damned.

In order to do this, you’ll need to get hold of your compiled code in .HEX format.  The easy way to do this is to hit Ctrl-R in the Arduino IDE, then use Windows Explorer to browse to %TEMP% .  Look around for a folder called buildtmp.XXXXXX where XXXXXX is some random gibberish.  Inside of that will be a copy of all the AeroQuad code source files, a bunch of .o files, and a single .HEX file.  This is what you want.  Copy it somewhere.

After that’s done, you can use avrdude in the Arduino IDE kit to flash the Arduino directly.  The following command assumes you’re using the ArduinoISP and it’s connected to COM4.  It also assumes that the .HEX file is in c:\arduino, and you’ve installed the Arduino IDE as displayed.

C:\arduino\hardware\tools\avr\bin>avrdude -pm328p -cstk500v1 -b19200 -PCOM4 -v -C ..\etc\avrdude.conf -e -U flash:w:\arduino\aeroquad.hex
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
         Copyright (c) 2000-2005 Brian Dean,
         System wide configuration file is “..\etc\avrdude.conf”
         Using Port            : COM4
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 19200
         AVR Part              : ATMEGA328P
         Chip Erase delay      : 9000 us
         PAGEL                 : PD7
         BS2                   : PC2
         RESET disposition     : dedicated
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ———– —- —– —– —- —— —— —- —— —– —– ———
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: erasing chip
avrdude: reading input file “\arduino\aeroquad.hex”
avrdude: input file \arduino\aeroquad.hex auto detected as Intel Hex
avrdude: writing flash (31406 bytes):
Writing | ################################################## | 100% 36.19s
avrdude: 31406 bytes of flash written
avrdude: verifying flash memory against \arduino\aeroquad.hex:
avrdude: load data flash data from input file \arduino\aeroquad.hex:
avrdude: input file \arduino\aeroquad.hex auto detected as Intel Hex
avrdude: input file \arduino\aeroquad.hex contains 31406 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 36.03s
avrdude: verifying …
avrdude: 31406 bytes of flash verified
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK
avrdude done.  Thank you.


Ta-da!  After that’s finished, you should have the AeroQuad code running on a Uno, with no bootloader.  One advantage with this technique is I’m pretty sure you can compile it to have BatteryMonitor, AltitudeHold and use DCM instead of ARG, which is a better flight algorithm.

Flight testing on the weekend 🙂

AeroQuad – We Have Liftoff!

Well, it’s done!  Last night I completed the last of the wiring, spun up all the motors, ran through the pre-flight checklists, and this morning I set the quad going in the carport.  It took off, no major issues.  Leans to the right, but I think that’s because of the angle of the carport’s concrete.  I only brought it about a foot off the ground 🙂

Ready for flight!

Top View

Everything fitted in, however I had to cut a few mm off the inside end of the arms to make enough room for the wiring harness.  Total weight is 1708 grams.  Heavier than I anticipated, and I put that down to additional weight from the wiring harness, connectors, and solder in the bullet connectors.  Still within the thrust power:weight ratio though.

Assembled with top baseplate removed, showing wiring
Power distribution harness

The cables that are going between the arms are shielded from the arms by a folded piece of hard plastic, acting as a grommet.  The actual power harness itself uses heavy 12 AWG wire for the main branch, breaking out into 16 AWG for the branches for each ESC, and also a breakout for a 2.1mm jack for the Arduino.  The trunks are then heatshrunk and ziptied together.  The whole arrangement is quite stiff, hence why I had to organize things so that two ESCs were in the front quadrant, and one in each side quadrant, with none in the back.

Each 2-wire bullet connector is keyed so that they can’t be plugged in the wrong way around.  However, the 3-wire bullet connector for the ESC to motor connection is unkeyed so that they can be reversed to reverse the motor.

ESC and Motor connections

I’ve followed the same bullet connector keying as the battery.  As of right now, none of the bolts are Loctited, but I’ll have to disassemble and apply Loctite everywhere shortly.

Now that’s done, I need to learn how to fly the damn thing, and then think about extensions.  First thing I’m thinking of is a way to leverage a barometer/magnetometer onto the thing…

Frame Assembly – Part 1

Well, I got the frame assembled (mostly)!  Still need to do a few bits (and all the cabling), but the frame’s put together and it fits like the plans said it would.  Great feeling when that pans out.

Assembled Frame

The frame was put together entirely from the design I described in my last post.  The MCU container that I’m using is sitting on a ring of 3mm foam rubber to isolate it from the body of the frame.

While the propellors are currently installed, that was mostly for looks and to verify that they swing as I was expecting.  I had to drill the center of the props out to 5mm, which means I’ve probably got the angle off on at least one.  But I have 30 spares, so it doesn’t matter much.

All bolts are 25mm M5’s, except for the four bolts holding the motor mounts to the frame, which are 35mm M5’s, and the bolts holding the motors to the mounts, which are 10mm M3’s.  I have not as yet applied Loctite anywhere, and won’t until I have completely finalized the build and I’m sure I won’t need to remove anything.

Motor mounting closeup

The bottom plate (forming the “leg”) on the motor mount is a piece of 20x60x3mm aluminium – the same template as the motor mounts themselves, except it was bent through a 45 degree angle at the 19mm mark.  This mark is in dashes on the template.

The idea is that the bent leg should act as a standoff from slightly rough landings, and the mount and standoff itself should bend reasonably easily (or swivel for that matter), providing a way to dissipate crash energy without bending the motors.  The arms themselves have a 19mm internal end cap pushed into them to discourage dirt and such getting in.

Frame – without MCU and motor mounts

The above photo is missing the 1/2″ grommet I put into the center of the top plate for routing wiring, but it shows how the bolts and plates assemble to form the frame.

Task remaining to do are;  All the wiring, making the landing skids, and the battery holder.  My shipment of bullet connectors is on its way, so I’m not far off the test flight.

Finalized Frame Design (and all-up weight)

Finalized what I’m going to do with the frame design last night.  Frame design can be found at this link (Visio document).  This frame is intended to be fairly small, but still robust and very easy (and cheap!) to construct replacement parts for.  M2M distance is ~475mm, which is around the 18.7 inch mark.  This frame is intended for use with 10 inch props (a 10 inch prop will just avoid the baseplate getting into the prop wash).

The materials that are required for building this frame are;

  • 12pcs 25mm M5 bolts, nuts and washers
  • 4pcs 30mm M5 bolts, nuts and washers
  • 8pcs 10mm M3 bolts, with 3 washers and one spring washer each
  • A few spare M5 bolts (for the landing gear, sizes not decided yet)
  • 4pcs 19.05×19.05x200mm aluminium square tube, 1.2mm thickness (thicker is ok)
  • 2pcs 145x145mm aluminium sheet, 1.2mm thickness (thicker is ok)
  • 4pcs 20x60mm aluminium flat bar, 3mm thickness
  • 2pcs 20x255mm aluminium flat bar, 1.2mm thickness (thicker is ok)

I had to adjust my design a number of times, in particular because the sheet I bought was 295x295mm, which means I couldn’t get multiple baseplates out of the one sheet if I went with a 150mm baseplate.  By varying the design to 145mm, I can get four baseplates out of one sheet, which is a significant cost savings (meaning each baseplate costs me ~$1.75).

Landing skids on the underside are two bent pieces of 1.2mm aluminium bar.  I may have to upgrade them to 3mm, depending on how easily they’re deformed.  Bends on the skids should all be inwards and 90 degrees, so that the skids make a U shape with the tags pointing inwards.  Drill the 5mm hole for the bolts first.  The bars for the skids are slightly longer than they need to be to take into account losses involved with bending.  The skids provide 40mm of spacing, which is sufficient to keep the battery off the ground and also sufficient to have the legs on the arms off not making contact under normal circumstances.

All-up weight with no ESCs, props, or cabling is 1462g, so with the extra bits I’d expect to be around the 1.6kg mark.  A thrust calculator says that I have 4kg static thrust with the GWS 10×6 propellors I have (4.4 mins full throttle flight time), and 4.7kg static thrust with the APC 10×4.7 SF props (only 3.8 mins full throttle flight time).  This fits in nicely with my aimed 2:1 thrust:weight ratio, so performance should be fine.  The quad should be able to hover at around half throttle.

Weights of individual items follow;

  • Arms with plastic endcaps fitted (holes not drilled) – 206g
  • 295x295x1.2mm plate – 288g
  • 4pcs M5 25mm bolt with nut (no washer) – 20g
  • 1000x20x1.6mm flat bar – 88g
  • 757x20x3mm flat bar – 124g
  • MCU in container with M5 bolts / nuts – 212g
  • Motors with mounts fitted (no props or arm retaining bolts) – 346g
  • Battery – 404g

As you can see, the MCU+Motor+Battery combination comprises a very significant portion of the overall weight, so I’m not convinced I could really drop much weight by going to, say, nylon or aluminium bolts or other small things like that.  Replacing the baseplate with G10 fiberglass may remove a fair bit of weight though.

Note that some of those items are for uncut pieces – so that the baseplates I actually fit will weigh under a quarter of the whole 295x295mm plate and such.

Anyway, it’s all coming together reasonably nicely.  Next tasks are to cut out the baseplates, drill all the holes and assemble the rest of the frame.

AeroQuad – Engine Mounts

After a lot of discussion on the AeroQuad forums about mounting the Turnigy 2217-16 motors I got to the arms of the frame, I decided to take a good idea and implement it.

Essentially, what I’m going to do is to construct a plate out of 20mm x 3mm aluminium flat bar (bought from Bunnings at like $6 a metre), 60mm in length.  That plate has the motor bolted directly to it with some 10mm M3 bolts, and then is bolted to the end of the arm with a single 25mm M5 bolt.  The idea there is that crash stresses on the end of the arm will tend to bend the 3mm plate or rotate it around its M5 bolt without damaging the motor mount.  Sounds like an idea.

So last night I templated up what it would look like, went and bought the aluminium, and fired up the drill press and made one.  Looks to me like it’ll do the job.

Completed Motor Mount

 The motor mount has 3mm holes for the M3 bolts, a 9mm hole for the motor’s shaft to pass through, and a 5mm hole for the M5 mounting bolt.  In hindsight, I should probably make the M3 holes at 3.5mm, since it’s pretty hard to get them exactly right, and if they are off by even a tiny amount, they’re hard to screw in because of the mating required with the motor.  Notice how one of the bolts is a little skewed on mine.

Closeup – notice skewed right bolt & three washers

Since the only suitable M3 bolts I had were 10mm, I had to use three washers and a spring washer to provide enough spacing to ensure that the bolt didn’t penetrate too far into the guts of the motor.  As it is, one of them is pressing lightly on the insulation of one of the cables.  It shouldn’t do any harm, but I’ll inspect it after use for any kind of damage – I might need to go with four washers (or a smaller 3mm aluminium spacer or something).  I haven’t sealed down the bolts yet with Loctite, I’ll wait until I have everything assembled and finalized, then I’ll Loctite everything in place.

Motor mount (underside)

When i bolt the mount to the arm, I’ll also be bending a piece of 1.6mm plate under the motor mount to use as a leg – not a supporting structure, but a standoff to stop the arms touching the ground on a slightly wobbly landing.

Completed leg

Next up is to adjust my frame designs, then make three more of these mounts.

Remaining parts (mostly) arrived!

Received the bulk of the remaining parts yesterday, so now I’ve got my motors, ESCs, and props.  What I wound out getting was;

And a few other sundries (battery tester, ESC config card).  I bought a lot of propellors (30 in total!) because I’m anticipating breaking off a lot, and those ones are dirt cheap.  I’ll get the better APC 10×4.7 SF’s later, once I’m not smashing off props all the time.

I ordered a few spare motors, and I’m glad I did – one of the motor accessory packs is missing the mounting screws for the X motor mount!  I may not turn out needing that, I need to do something thinking about how I’m going to mount the motors to the arms.  What I’m thinking of doing is mounting the motor directly to the arm, but that carries with it the risk of bending the motor in a crash.

What I’m waiting for now is the bullet connectors I ordered.  The motors come with bullets, but I also ordered some protected bullets which come in a frame that holds 3 or 2 together, to avoid instances of motors being plugged in the wrong way around.