Tim Hanewich's Scout Flight Controller Pushes MicroPython on the Raspberry Pi Pico to the Limit

Clever coding and an overclock to 250MHz sends a $4 Raspberry Pi Pico to the skies, in place of $100-or-more commercial flight controllers.

Maker Tim Hanewich has put together a quadcopter drone driven by a custom MicroPython flight controller running on a Raspberry Pi Pico development board — and has made the project open source for others to enjoy.

"During summer 2023, I developed a DIY quadcopter drone using the Raspberry Pi Pico as the 'brain,' running a Python-based custom-developed flight controller to achieve flight," Hanewich explains of his project, brought to our attention by Adafruit. "This was a very computationally challenging task, but through much trial-and-error, I was able to squeeze enough performance out of the RP2040 to allow for stable and agile flight."

The flight controller in question is dubbed Scout, and is designed to put the core capabilities of a commercial flight controller costing $100 or more onto the $4 Raspberry Pi Pico and its dual-core RP2040 microcontroller. "Just as a scout ventures into uncharted territories to gather knowledge and pave the way for future success and innovation," Hanewich explains of the name, "this flight controller represents my entry into a new domain of expertise, one of which I knew very little about when beginning this project."

It took seventy days — and, Hanewich notes, 1,194 code commits — for Scout to take flight, requiring Hanewich to learn about the flight dynamics of a quadcopter, how to integrate the microcontroller with a gyroscope, proportional–integral–derivative (PID) control, driving brushless motors via electronic speed controllers (ESCs) using the RP2040's pulse-width modulation (PWM) capabilities, and reacting to inputs from a handheld radio controller.

Initial test flights took place on a tether for safety, though the Scout's quadcopter host is now free-roaming. (📹: Tim Hanewich)

"The Scout Flight Controller runs the PID adjustment loop at 250Hz, or 250 times per second. I learned that achieving this speed is a challenge using MicroPython on the inexpensive Raspberry Pi Pico’s CPU hardware," Hanewich notes of one of the biggest challenges in the project.

"To achieve these speeds, you'll notice that I am not using the basic principles of programming — modularity, reusability, etc. I am keeping my usage of classes, functions, and modules to the bare minimum. This is because usage of these simple Python concepts actually requires a bit of extra processing time that would slow the execution of the code down enough for the 250Hz adjustment loop to be out of reach."

Even then, the controller was running too slow for comfort — which led Hanewich to try the brute-force solution. "The Scout Flight Controller overclocks the Raspberry Pi Pico's RP2040 processor from 125MHz to 250MHz, double its rated speed," he explains. "From my experience, this has not caused any adverse effects whatsoever. The power consumption, temperature, reliability, etc., still appear to be normal."

The creation of the Scout Flight Controller is detailed in a 12-part series on Hanewich's blog, including the MicroPython source code itself.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles