#let post_slug = "building-a-drone"
#let post_preview_image = "top.jpg"
#let post_summary = "Using a raspberry pi and 3d printer to build a drone from scratch"

= Building a Drone

I chose to build a drone from scratch for my AP Physics final project.
We were given an open ended assignment to _build something cool_
and I wanted a drone. My choice was much more ambitious than the course required,
and took quite a while to complete.

For the drones frame I finally had an excuse to purchase a 3d printer. I
modelled the frame and arms modularly to support future upgrades and
replacements from damage, reducing the cost of operation. Initially I
was using some 3d printed torodial propellers due to their higher
efficiency and lower sounds usage. Due to safety concerns of the
propellers not withstanding tension at higher RPMs and exploding I
switched to some generic acrylic propellers I bought. A challenge in
designing the frame was leaving enough room to contain the volume of the
wires. I went with the Elegoo Neptune 3 as the printer was open-source
and had a much better cost-to-utility than proprietary printers such as
the Ender series. I am not sponsored I just really like the printer.


The flight computer was the most difficult part to program. Using an
ultrasonic distance sensor, gyroscope, and accelerometer the drone has
enough information to probably never crash. The autopilot is implemented
on an Arduino UNO using a
#link("https://en.wikipedia.org/wiki/Proportional%E2%80%93integral%E2%80%93derivative_controller")[PID Controller]
for stabolization. The autopilot quality is currently impacted every time
the drones mass distribution changes, which can be fixed with a reinforcement
machine learning algorithm. For the higher level programming such as flight
automation, video transmission and WiFi communications I used a Raspberry
Pi Pico. There is also a 2.4GHz line of sight receiver for manual control.
A future upgrade may contain a SIM card for near-infinite remote control
connection, but drone regulations would make this difficult.

The power system is the most physically challenging portion of the
drone. The motors took 14.6 Volts, while the UNO microcontroller took 5
Volts, and the Pico and most sensors run at 3.3 Volts. All of the power
to the motors ran through the power distribution board, which I modified
to also output the lower voltages and used Bidirectional Logic Level
Converters to shift between 3.3 and 5V signals where needed. A potential
flaw with having all the power coming from the same source is spikes in
energy consumption to the motors may cause the microcomputers to receive
too little power, which could be fixed with a capacitor. Luckily, I
haven't experienced this yet as the 2C discharge rate on the 2.5Ah
capacity battery is more than enough. Having a battery this big does
mean it takes up about half the internal electronics volume and is half
of the drones mass, but it can also maintain full throttle for half an
hour making for long flights.

The motors I used were a bit overkill for a 1.1kg drone, as going past
20% throttle sends it shooting through the sky, which is not a bad
issue to have. Here's the technical numbers behind that: I have
propellers with a 6cm radius on motors with a 2450KV rating (2450 rpm
per volt) and peaking at 14.6 Volts. From this the tip speed is ~225m/s
under no load at max throttle, quite a lot more than what
is safe or necessary to get into the air.
