A not particularly original quadcopter project

The main aim of this project is to create a flight controller using fairly cheap components that will provide stable motion. Though there will be user control to begin with, I would like to gradually give more and more of the control over to the controller.

You can see the current status in this video (in which I am controlling the throttle, and am making minor adjustments to pitch and roll angles).

General set up The quadcopter uses a pre-built kit for the frame, motors and ESCs. The flight controller is built around an Atmega328P 8-bit microcontroller and uses an nRF24L01+ module for communication, and an MPU-6050 IMU and HMC5883L magnetometer for motion control.

User control The quadcopter is controlled through radio using the nRF24L01+ chip connected to the microcontroller on the quadcopter. The transmitter has a similar setup of microcontroller+radio chip (there are more details on the radio controller section of the linked website). The transmitter sends a data package which contains all user inputs (joysticks plus flight mode). The quadcopter ackowledges this package and reports its status including battery level. If connection is lost for more than a short period of time, the quadcopter will attempt to land and then shut down the motors.

Flight controller An inertial measurement unit (MPU-6050) provides gyroscope and accelerometer readings, and there is a separate magnetometer (HMC5883L). Angular rate is taken directly from the gyroscope measurement. Attitude/absolute orientation is calculated from the integrated gyroscope measurements and combined with the orientation calculated from accelerometer (for pitch and roll) and magnetometer measurements (for yaw) in a complementary filter in order to counteract gyro drift. There are two levels of control. The inner control loop uses gyroscope measurements directly and attempts to achieve a given angular rate. The outer control loop attempts to achieve an absolute orientation, and its output is the required angular rate for the inner loop to achieve. There is a PID controller on each axis in both inner and outer control loops. The outer loop can be toggled on/off during flight. If it is on the control inputs will dictate orientation. If it is off the control inputs will dictate angular rate.

Future developments Add range finder and/or barometer for altitude hold Test more advanced sensor fusion algorithms e.g. Extended Kalman Filter Re-make on Teensy or RaspberryPi and add significant ‘autonomous’ functionality e.g. GPS

Links More detail about build, testing and calibration on my web site here. Github repository

I would not have got as far as I have without the enormous amounts of information that has been contributed to this forum.

bms001: Future developments Add range finder and/or barometer for altitude hold

My suggestion would be for you to use a LiDAR Lite V3 for rangefinding - so much more reliable and easy to use compared to a barometer. I use one myself for my Arduino RC airplane.

bms001: Re-make on Teensy or RaspberryPi and add significant ‘autonomous’ functionality e.g. GPS

Do yourself a favor and go with the Teensy (if you want to do image processing, you'd want to use both a Teensy and a RPi together - Teensy for control and RPi for image processing and then have them communicate via UART or I2C).

Thanks for the suggestions.

I've looked at the LiDAR Lite V3 before but a little put off by the price (I'm not suggesting they're not good value though). I will probably try with cheaper components at least to begin with just to see where I can get to since my current goal is more around my own learning. I realise that this does seriously limit what the end product is capable of and I don't want to be doing the cheap basic versions forever.

Yeah I will probably go for the Teensy in the near future. I have an RPi kicking around (never used before) and wanted a project for it but I have some other things in mind for it now. Later on I may add it to a Teensy based QC as you suggest.

bms001: I will probably try with cheaper components at least to begin with just to see where I can get to since my current goal is more around my own learning. I realise that this does seriously limit what the end product is capable of and I don't want to be doing the cheap basic versions forever.

That's understandable.

One thing I will say (based on my own experience) is that you end up paying more when you try the cheap stuff and learn the components aren't what you need. I've had times where I spend money on an IMU like an MPU6050, when later on I realize that I needed a BNO055 in the first place for what I wanted to do. Same with my altimeter, flight controller, servos.......etc. Look for what's best for your application (after doing extensive research) and then make a responsible plan on how/when to pay for it. I promise that in the long run, you will be saving money and getting better performance.

bms001: Yeah I will probably go for the Teensy in the near future. I have an RPi kicking around (never used before) and wanted a project for it but I have some other things in mind for it now. Later on I may add it to a Teensy based QC as you suggest.

I use the Teensy 3.5 for several undergraduate research projects as well as for my RC plane. I can honestly say that that MCU is the best one out there in terms of hobby grade stuff. It has amazing processing power, has a fast clock, several serial/I2C/SPI ports, 16bit ADC, 5V tolerant, and is affordable. It's also really easy to use since you can code it using the Arduino IDE.

Power_Broker: I use the Teensy 3.5 for several undergraduate research projects as well as for my RC plane. I can honestly say that that MCU is the best one out there in terms of hobby grade stuff. It has amazing processing power, has a fast clock, several serial/I2C/SPI ports, 16bit ADC, 5V tolerant, and is affordable. It's also really easy to use since you can code it using the Arduino IDE.

Yes, I got a Teensy 3.5 fairly recently and so far I have been greatly enjoying the speed of floating point calculations!