Maker Tim Hanewich has put collectively a quadcopter drone pushed by a {custom} MicroPython flight controller operating on a Raspberry Pi Pico improvement board — and has made the undertaking open supply for others to take pleasure in.
“Throughout summer season 2023, I developed a DIY quadcopter drone utilizing the Raspberry Pi Pico because the ‘mind,’ operating a Python-based custom-developed flight controller to realize flight,” Hanewich explains of his undertaking, dropped at our consideration by Adafruit. “This was a really computationally difficult activity, however by way of a lot trial-and-error, I used to be in a position to squeeze sufficient efficiency out of the RP2040 to permit for secure and agile flight.”
This quadcopter is pushed by a Raspberry Pi Pico, standing in for a way more costly industrial flight controller. ((?: Tim Hanewich)
The flight controller in query is dubbed Scout, and is designed to place the core capabilities of a industrial flight controller costing $100 or extra onto the $4 Raspberry Pi Pico and its dual-core RP2040 microcontroller. “Simply as a scout ventures into uncharted territories to collect data and pave the best way for future success and innovation,” Hanewich explains of the identify, “this flight controller represents my entry into a brand new area of experience, certainly one of which I knew little or no about when starting this undertaking.”
It took seventy days — and, Hanewich notes, 1,194 code commits — for Scout to take flight, requiring Hanewich to study in regards to the flight dynamics of a quadcopter, the way to combine the microcontroller with a gyroscope, proportional–integral–by-product (PID) management, driving brushless motors through digital pace controllers (ESCs) utilizing the RP2040’s pulse-width modulation (PWM) capabilities, and reacting to inputs from a handheld radio controller.
“The Scout Flight Controller runs the PID adjustment loop at 250Hz, or 250 instances per second. I discovered that attaining this pace is a problem utilizing MicroPython on the cheap Raspberry Pi Pico’s CPU {hardware},” Hanewich notes of one of many greatest challenges within the undertaking.
“To attain these speeds, you will discover that I’m not utilizing the essential ideas of programming — modularity, reusability, and many others. I’m preserving my utilization of lessons, capabilities, and modules to the naked minimal. It is because utilization of those easy Python ideas truly requires a bit of additional processing time that may gradual the execution of the code down sufficient for the 250Hz adjustment loop to be out of attain.”
To get the MicroPython code operating quick sufficient, the Scout runs the RP2040 microcontroller at 250MHz. (?: Tim Hanewich)
Even then, the controller was operating too gradual for consolation — which led Hanewich to strive the brute-force resolution. “The Scout Flight Controller overclocks the Raspberry Pi Pico’s RP2040 processor from 125MHz to 250MHz, double its rated pace,” he explains. “From my expertise, this has not brought on any antagonistic results in any respect. The ability consumption, temperature, reliability, and many others., nonetheless seem like regular.”
The creation of the Scout Flight Controller is detailed in a 12-part sequence on Hanewich’s weblog, together with the MicroPython supply code itself.