Skip to the content
PCBKitNew board
2 layers55.6 × 48.8 mmAAquad PCB, the printed circuit board in 3D

An original, "from scratch" quadcopter flight computer that was my favorite pet project for some time. Used it to learn all about flight and embedded development. It took a couple years but I eventually learned enough (and crashed enough) to get it working :) .

Size
55.6 × 48.8 mm
Copper layers
2
Thickness
1.6 mm
Parts
47
Nets
39
Pads
230
Tracks, vias
403, 74
Pours
7
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
2 Mar 2019
Updated
14 Sep 2020

Overview

AAquad PCB is an open-source printed circuit board by Fberbari, from the Fberbari/AAQuad-Evolution repository on GitHub, published under the MIT licence. It is a 2-layer board of 55.6 × 48.8 mm with 47 parts on 39 nets, routed with 403 tracks and 74 vias.

It is built around the ATMEGA328PB-AU, MPL3115A2R1 and BMX160, with the BSS138 and SPX1117M3-L-5-0/TR-TD among its other parts. Its parts include 17 capacitors, 8 resistors, 8 ICs, 4 connectors and 2 diodes. It belongs with the robots and motor control boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

5

README

README.md

AAQuad-Evolution


The AAQuad-Evolution is a flight computer I've designed to control a quadcopter. The computer takes care of continued stabilization in flight while leaving the pilot free to command roll, pitch, and yaw angles as well as altitude. The project is made up of a custom PCB, all the bare-metal C code that runs on the Atmega328pb processor and Matlab simulations used to design and tune the PID algorithms. This is very much a bare bones flight computer that is in no way as feature rich as BetaFlight or any of the other famous FOS flight controllers. Its advantage lies in its simplicity. Anyone with some understanding of the dynamics of flight, calculus, and circuitry could begin to understand the project without being faced with a mountain of complexity and no idea where to start. In the end, the AAQuad-Evolution continues to satisfy my curiosity for flight and increase my understanding of embedded systems all the while providing me with a creative outlet to try out all kinds of cool things.

Flying the Quad


The commands are as such:

  • Increasing/decreasing the throttle stick corresponds to an increase/decrease in the target altitude.
  • Increasing/decreasing the rudder stick corresponds to an increase/decrease in the target azimuth (relative to the starting azimuth).
  • Increasing/decreasing the aileron stick corresponds to an increase/decrease in the target bank angle.
  • Increasing/decreasing the elevator stick corresponds to an increase/decrease in the target pitch angle.

The ranges for all the mentioned targets are defined in src/Pid.h.

Calibrating the Quad


  1. Before plugging in the battery, turn the transmitter on and put the throttle stick to full power.
  2. Plug in the battery.
    • A solid green led will turn on, indicating calibration mode has been successfully entered.
  3. Position the Quad on a level surface and make sure it is completely still.
  4. Put the throttle stick to 0.
    • The led will turn off, indicating calibration has begun.
  5. Once the led turns on again, the Quad has been successfully calibrated and is ready to be flown.

Some in flight images

Some close ups

What's going on ?


So you want to understand how the AAQuad flies ? Great! Here is a high level explanation of what's going on.

Everything starts in main.c, which you'll find in the root directory of the project. If you go through that file, you'll find it's incredibly simple in principle. Here, we begin with a short delay to ensure all electrical systems have stabilized after power up. Next, we execute a calibration and finally, we call the controller state machine inside an infinite loop (this is where the magic happens).

Now, let's head into the src directory. Apart from main.c, this is where all the the source and header files are stored. Take a look at the state machine in Controller.c (the switch case statement inside the Controller_DoYourThingAndFlyTheQuadITrustYou function). The switch statement is organized in the order that the states get executed. Here's what's going on:

  1. GetPilotInstructions: We check to see whether there are any new instructions from the receiver. If you take a look inside the PilotInstructions module, you'll see that the pwm signals sent from the ESC are read asynchronously via external and pin change interrupts. Those instructions get translated into percentages for commanded roll, pitch, yaw and altitude. If they are ready when PilotInstructions_ComputePilotResult is called, we pick them up. Otherwise, we just move on and pick them up the next time.

  2. GetImuData: We collect the accelerometer, gyroscope and magnetometer data from the inertial measurement unit. This is also an interrupt based exchanged so when we call Imu_GetResult, we are just checking if the data is ready and picking it up if it is.

  3. GetAltitude: We collect data from the ultrasonic distance sensor. Once again, it is an interrupt based exchange, so we are just checking and picking data up if it is ready.

  4. TriggerNewMeasurements: Now that we've collected all the data of interest, we need to instruct the sensors to collect more data for us. This way, when the time comes once again to ask for it, it will be ready. For the IMU, this triggers an interrupt based SPI exchange that reads the registers that contain the relevant data. For the ultrasonic distance sensor, this sends the digital pulse instructing it to collect a new measurement.

  5. FuseMeasurements: While the sensors do their thing, we begin to crunch the math. In this state, we fuse gyroscope and accelerometer data together using a Mahony filter. This filter returns the estimated orientation of the quad encoded in a quaternion.

  6. ConvertToEuler: Since quaternions are very non linear and thus hard to use in a linear controller, we convert them into Euler angles. These are the familiar roll, pitch and yaw angles. At the same time, we also compute the derivatives of the Euler angles (representative of the angular velocity of the quad in every axis). This is for future use in the controller. It is done this way because computing a derivative from the change in measured angular positions leaves us very susceptible to noise. Since we have a gyroscope and measure the derivatives directly, we can use those values and avoid this problem.

  7. ComputePid: Now that we know what the pilot wants and what the quad is doing, we can compute what we need the motors to do to achieve the pilot's intentions. This is done via multiple PID (proportional, integral, derivative) algorithms. This module also takes care of figuring out the takeoff sequence of the quad. What we get from it is an array of 4 floats that correspond to percentages of full power that need to be delivered to each motor to achieve the desired intentions.

  8. SendToPwm: Once we know what we want the motors to do, we need to communicate that to them. To do so, we begin an interrupt based I2C exchange with a chip responsible for sending out PWM to the ESC.

  9. WaitForTimer: Last, to keep things synchronous, we sit in this state until a timer says some set time has passed. Once that is the case, we go back to the GetPilotInstructions state and the cycle begins anew.

  10. Failed: This state should never be reached in normal flight but exists in case a catastrophic failure needs to be handled. In the case that something goes horribly wrong in one of the modules (for example communication gets cut with one of our chips), we go to this state and the PWM output to the ESC gets immediately shutdown, causing the motors to stop spinning.

Building it for yourself


A word of caution. This project was not designed to be reproduced, so it is fairly difficult to do so. That being said, if anyone does want to construct the PCB and tune then upload the software, here is what they would need to do:

Prereq Hardware

  • Avr-Ice Jtag programmer
  • A 4 channel ESC with 5V BEC that can handle 200 Hz PWM refresh rates
  • A minimum 4 channel receiver that communicates over PWM
  • Your favorite quadcopter frame, motors, and battery
  • A transmitter capable of communicating with your esc of choice

Prereq Software

  • Atmel studio 7+
  • Kicad 5+ (Optional, as the gerbers are already in the repo)
  • Simulink 2019+, equipped with the aerospace blockset

Building the PCB

Full gerber files and a BOM are present in the PCB/KicadFiles directory. The only sensor not present in the BOM is the ultrasonic distance sensor. You will also need to purchase the appropriate wires to connect the ESC, receiver, and ultrasonic sensor to the PCB.

Adjusting the PID gains

If you know the mass, inertia tensor, and relationship between throttle percentage, force and torque of your quadcopter, you can adjust the appropriate blocks in the Simulink model and tune the PID gains. You can insert those gains into src/Pid.c.

Compiling and uploading the software

Once the pcb is built, power it by connecting the ESC to the battery and plug in the Jtag programmer to the appropriate pins. To open the project in Atmel studio, open the project file present in /build. Then, click the compile button and the run button.

License

This project is under the MIT license.

Acknowledgements

  • SOH Madgwick, whose implementation of the Mahony filter is used in this project.
  • A shoutout to Anny Wang, who said: "Hey, wouldn't it be cool to build a quadcopter ?" back in 2018, which is how this project began :p.

Parts

47
QtyValueFootprintReferences
60.1uFCapacitors_SMD:C_0805C1, C3, C6, C7, C12, C13
410KResistor_SMD:R_0805_2012MetricR1, R5, R6, R7
410uFCapacitor_SMD:C_0805_2012MetricC14, C15, C16, C17
4levelShifterlevelShifters:74LVC1T45GW_125IC3, IC4, IC5, IC6
310uFCapacitors_SMD:C_0805C2, C4, C8
2100uFCapacitor_SMD:C_1206_3216MetricC5, C9
22KResistor_SMD:R_0805_2012MetricR2, R8
2300Resistor_SMD:R_0805_2012MetricR3, R4
233pFCapacitor_SMD:C_0402_1005MetricC10, C11
2BSS138TO_SOT_Packages_SMD:SOT-23Q1, Q2
1Atmega328pbmicrocontrollers:ATMEGA328PB-ANRU1
1BMX160sensors:bmx160IC1
1CrystalCrystals:Crystal_SMD_7050-2pin_7.0x5.0mmY1
1ESC_InputConnector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ3
1MPL3115A2sensors:MPL3115A2IC2
1PCA9685PW_112digikey-footprints:TSSOP-28_W4.40mmU2
1Receiver_OutputConnector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ2
1SPX1117M3-L-5-0_TRSamacSys_Parts:SOT230P700X170-4NPS1
1greenLEDs:LED_0805_HandSolderingD1
1programmerConnector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ1
1redLEDs:LED_0805_HandSolderingD2
1ultrasonicConnector_PinHeader_2.54mm:PinHeader_2x02_P2.54mm_VerticalJ4

The 43 most common of 47 parts.

Questions

How big is the AAquad PCB PCB?

It measures 55.6 × 48.8 mm and has 2 copper layers, 1.6 mm thick.

What parts does the AAquad PCB use?

47 parts, built around the ATMEGA328PB-AU, MPL3115A2R1, BMX160 and BSS138. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the AAquad PCB KiCad files?

From the Fberbari/AAQuad-Evolution repository on GitHub, at the commit this page was made from: the board is PCB/KicadFiles/AAquad_PCB.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the AAquad PCB design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers55.6 × 48.8 mmAAquad PCB, the printed circuit board in 3D

    AAquad PCB

    Fberbari/AAquad

    (OUTDATED, see AAQuad-Evolution) a baremetal implementation of a multirotor flight computer.

    38 partsGPL-3.0
  • 4 layers90 × 70 mmRobot hub rev3, the printed circuit board in 3D

    Robot hub rev3

    dustin-lehmann/TWIPR

    See https://github.com/dustin-lehmann/TWIPR/wiki for descriptions on how to use the hardware and software

    278 parts1
  • 2 layersBarometer, the printed circuit board in 3D

    Barometer

    Olin-Rocketry/sensing

    Sensing hardware and software

    10 parts
  • 4 layers90.2 × 95.9 mmMainboard v04, the printed circuit board in 3D

    Mainboard v04

    pycubed/hardware

    Pycubed PC104 layout design files

    201 parts97
  • 2 layers72.9 × 25.4 mmBeepSensors, the printed circuit board in 3D

    BeepSensors

    57Bravo/BeepSensors

    GPS, IMU, MAG, BARO, and Buzzer for the BeepBerry

    19 parts15
  • 4 layers40.1 × 38.1 mmCrazyflie contol board, the printed circuit board in 3D

    Crazyflie contol board

    sPyOpenSource/ESP32-PCB

    PCB boards designed with ESP32

    98 parts8MIT
  • 4 layers90.2 × 95.9 mmMainboard v05, the printed circuit board in 3D

    Mainboard v05

    alxklso/ISP-cubesat

    This is the repo for the Isomer Space Program (ISP) 1U CoyoteSat CubeSat mission.

    255 parts1MIT