<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tim Hanewich on Medium]]></title>
        <description><![CDATA[Stories by Tim Hanewich on Medium]]></description>
        <link>https://medium.com/@timhanewich?source=rss-77c9bad82740------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*LpMPnVP_5z3Z-K2eC7dkQQ.jpeg</url>
            <title>Stories by Tim Hanewich on Medium</title>
            <link>https://medium.com/@timhanewich?source=rss-77c9bad82740------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 06:58:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@timhanewich/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Disappearing Moats]]></title>
            <link>https://timhanewich.medium.com/disappearing-moats-2599abbbb1db?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/2599abbbb1db</guid>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[future-of-work]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 12:23:14 GMT</pubDate>
            <atom:updated>2026-10-31T12:23:14.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IiNq6WiPowANYZBq.jpeg" /></figure><p>Much of human activity is driven by a desire to improve our own lives. Humans are innately selfish creatures, acting primarily to better their own circumstances. Secondary interests often extend to immediate family, then extended family, and finally the broader community, but the vast majority of human activity is motivated by personal gain.</p><p>Despite this, we have a thriving society built on human-to-human collaboration and mutual benefit. How is this possible given our innate “selfish” behavior? <strong>Incentive structures</strong>.</p><p><strong>Capitalism</strong> is the prevailing incentive structure behind this cooperation. In a capitalist economy (adopted by the leading global economic powers), individuals are free to pursue their own profit. The main way to do so is to create goods or services that <em>others</em> value enough to pay for, benefiting both parties. In a free market economy (with government intervention limited to where it is necessary), this simple concept drives societal progress: innovation that benefits society as a whole is <em>incentivized</em> by the prospect of personal prosperity for the individual behind it!</p><p>This is how our global economy works! Corporations must put meaningful incentive structures in place for their employees that <em>incentivize</em> work towards the company’s shared mission, whatever it may be. Employees work towards that mission for the (selfish, yes) purpose of benefiting themselves, usually through financial compensation.</p><h3>So are we humans “selfish”?</h3><p>A common reaction to capitalism, particularly among socially minded people, is disgust at the “selfish” motivations behind pursuing success for personal rather than collective benefit.</p><p>In my opinion: you can make whatever <em>subjective</em> judgment you like about this behavior, but must <em>objectively</em> admit that nearly all of humanity’s technological progress since civilization began was driven largely by individuals pursuing innovation <em>primarily</em> to improve their own lives; that pursuit often benefits society too.</p><p>Capitalism benefits many aspects of your life, whether you realize it or not:</p><ol><li>Modern medicine cures illnesses and restores you to health; these medicines would not exist without the profit incentive that drives pharmaceutical companies to invest in R&amp;D.</li><li>Your smartphone lets you connect with friends and family, educate yourself, and participate in the digital economy; these products would not exist if tech giants like Apple and Google (and plenty of component providers) had not invested in building them for profit.</li><li>Your household appliances (e.g. refrigerator, washing machine) save you time and physical labor, freeing you to pursue more fulfilling activities; these would not exist if GE, LG, Whirlpool, and other companies had not developed them for profit.</li></ol><p>The result of capitalism is <strong>mutual benefit</strong> for the individual or business pursuing profit <em>and</em> the people buying from them. Both parties agree to exchange currency for goods/services because the transaction improves <em>their unique</em> circumstances.</p><h3>The Catalyst of Capitalism: The Moat</h3><p>One of the catalysts that makes capitalism work is the “moat”; more specifically, the “economic moat”. An economic moat is a competitive advantage that protects a company’s long-term profits and market share from copycats and rivals.</p><p>In capitalism, <em>everything</em> relies on a moat!</p><ul><li>You buy a smartphone because it is more efficient than learning every discipline needed to build your own; the technical know-how and manufacturing processes are Apple’s “moat”.</li><li>You are hired over another candidate because the hiring manager sees greater knowledge, understanding, or capability in you; that edge over your competition is your “moat”.</li><li>You are promoted because you make better decisions or execute specific tasks better than your peers; that edge is your “moat”.</li><li>Your domain expertise and personality as a salesperson make you an advisor rather than just a vendor, helping you build customer partnerships and win business; those skills, developed over years, are your “moat”.</li></ul><p><em>Without</em> these moats, you could not provide any economic value at all in a capitalist economy, as you offer nothing beyond your competition that is <em>worth</em> a premium. You would become a commodity, indistinguishable from the competition.</p><p>Moats (your “edge”) are extremely important in a capitalist economy! This is why young adults have pursued higher education for decades, investing in formal graduate programs to become more valuable in the job market; the knowledge and skills they gain are their “moat” relative to those without that education, allowing them to command a higher price (e.g. salary).</p><h3>Moats are Disappearing at the Hands of AI</h3><p>In my recent post, <a href="https://timhanewich.medium.com/fulfillment-in-struggle-07d2b63caebc"><em>Fulfillment in Struggle</em></a>, I wrote about advances in AI that now allow it to perform much of the modern world’s white-collar work.</p><p>As AI advances and becomes readily available to everyone on the planet, most moats will quickly be filled:</p><ul><li>A software developer spends years meticulously learning backend development. Employers value that expertise, helping the developer land a tech job and command a high salary. Suddenly, anyone with the latest AI model can replicate their work faster, cheaper, and better, often for mere pennies.</li><li>A salesperson made their mark by following up with clients, building rapport, and following through. That reputation helped them beat competing vendors and close deals. Suddenly, anyone with the latest AI model can create the illusion of that same care and attentiveness simply by asking an agent to do the work.</li><li>A data analyst spent years learning pandas or NumPy and brings value to their employer through those hard-earned skills. Suddenly, anyone with the latest AI model can produce a deeper, more exhaustive analysis for pennies.</li><li>A healthcare domain expert, such as a consultant, has spent years mastering the industry’s processes, systems, laws, and rules. That deep understanding is why clients turn to them for advice. Suddenly, anyone with the latest AI model can produce comprehensive reports covering the same information, tailored to their specific needs.</li></ul><p>The “moat” each professional spent years building has disappeared, virtually overnight. All that separates you from your competition is an AI prompt and then they are level with you!</p><p>Around the world, people are questioning the traditional path to building personal economic value: why go to college to learn a discipline when any non-expert with an AI model can so easily replicate the work? And better yet, why learn it at all if <em>you yourself</em> have access to an AI model that already makes your expertise redundant?</p><h3>Mixed Reactions</h3><p>What has surprised me most is how differently people are reacting to this shifting economic landscape.</p><p>Take <a href="https://www.science.org/content/article/openai-just-changed-math-forever-exactly-how-no-one-yet-knows">the recent series of mathematical discoveries by OpenAI’s latest models</a>, for example. This is one of the clearest examples of elite scientists’ hard-earned “moat” evaporating virtually overnight.</p><p>On the cusp of the largest wave of innovation their field has ever seen, many mathematicians are struggling to accept the loss of their hard-earned moat, feeling less valuable in this new era; that loss has sparked strong pushback and criticism of AI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LWqg16J9lEn-lhrF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*bbzfrjZmPSvy06QX.png" /></figure><p>Some have shown empathy for these affected communities and mathematics is not the only one!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*KCt1_7biyTF-n5uq.png" /></figure><p>But there has also been the opposite: disdain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*3Wh767_vfZrYmT9N.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*MblC0PacFmTp3YZ6.png" /></figure><h3>The need for Empathy</h3><p>I’ve been quite surprised by how much hostility is directed at people coming to terms with the overnight loss of a moat they worked hard to build (and built much of their identity around). From hero to zero almost instantly!</p><p>For years, we as a society have <em>incentivized</em> people to devote their time and attention to these fields. Everyone came for their own reasons: financial reward, prestige, or simply passion. Whatever their reasons, they invested years of effort in becoming proficient, with the promise that their expertise would eventually earn them an important position, a high salary, or whatever reward they were pursuing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*jPIUeMIOtZmgFRmr.png" /></figure><p>This will not affect only mathematicians. It will not affect only software developers. This phenomenon will reach nearly every role in the information economy. We cannot blame people for the demise of their careers; it is not as though they could have seen this coming or made obviously poor decisions they should have avoided. We are now dealing with a technology the world has never had before one that previously existed only in sci-fi!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2599abbbb1db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fulfillment in Struggle]]></title>
            <link>https://timhanewich.medium.com/fulfillment-in-struggle-07d2b63caebc?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/07d2b63caebc</guid>
            <category><![CDATA[ssi]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 01:15:01 GMT</pubDate>
            <atom:updated>2026-10-12T01:15:01.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H0ZqpS3oJVF-9y4G.jpeg" /></figure><p>Growing up in Western culture, I’ve seen how heavily <em>productivity</em> and <em>hustle</em> can be instilled from such an early age. That emphasis has roots stretching back generations:</p><ul><li>Religions like Protestantism viewed work as a “saving grace” that might lead the common person to salvation.</li><li>The Industrial Revolution introduced the time clock, making time a measured unit of production.</li><li>Management science in the 90s began treating the labor force as a resource to optimize for maximum productivity.</li></ul><p>In terms of economic output, this has served the US well! This productivity-focused culture helped create one of the world’s most prosperous economies, establishing the US as a superpower despite its relative youth compared with historical superpowers.</p><p>A prosperous economy brings many benefits (better quality of life, healthcare, safety, abundant nutrition, etc.), but it can also have side effects.</p><p>As early as elementary school, children are taught to pursue good grades to qualify for advanced placement classes in high school. High school students are pushed to score well on placement exams to enter the best universities. University students are pushed to secure Fortune 500 internships to improve their chances of a lucrative career. New graduates are encouraged to work long hours to earn promotions. Those promoted are encouraged to take leadership positions for greater impact. Those in leadership are encouraged to climb further and lead entire organizations.</p><p>This “hustle” mentality is rooted in the developed world’s culture and reinforced across generations. While this mindset has produced one of the world’s most prosperous nations, it has also tightly tied human identity and worth to the productivity and success that innate abilities and hard-earned skills make possible.</p><h3>The Disruption</h3><p>Since the dawn of civilization, human effort, both labor and intellect, has driven economic development. Over time, capital (machinery) entered the mix and automated much of that labor. This has increasingly shifted human work toward information economy (“white-collar”) jobs, where intellectual output is the valuable contribution.</p><p>For decades, as machines took over physical labor, human workers moved toward “higher ground”, where intellect was the product they delivered. True intelligence was always beyond a machine’s reach, making intellectual pursuits a refuge of security and value.</p><p><strong>That has now changed.</strong> Artificial Intelligence has proven capable of participating directly in the information economy and serving in many roles humans hold today.</p><p>For the first time in history, <em>critical thinking</em> can be delegated to a machine. Human cognition is no longer the <em>only</em> source of intellect. Moreover, this machine-delivered intelligence is faster, deeper, cheaper, and more widely available. In a capitalist economy, this will drive massive shifts as the cost and time required to deliver intelligence fall dramatically before our eyes.</p><p>This will have massive implications for the economy and the future job market. Economists much smarter than me are forecasting what the coming decades might look like (probably with AI’s assistance!). In this post, I don’t want to pontificate about the economy’s future, but about what this change might bring to the human spirit.</p><h3>The Problem</h3><p>As mentioned earlier, Western culture emphasizes productivity and intellectual achievement so heavily that they often become tied to self-worth and purpose. With abundant intelligence available at a fraction of the cost and time required by humans, capitalist economies will begin to reduce their reliance on human intellect for many tasks, first out of a desire for efficiency (profit) and later out of necessity. If this happens at scale, millions of white-collar workers worldwide could be separated from work they spent decades mastering and building an identity around. For most, this will be a rough wake-up call.</p><p>According to Pew Research, a <a href="https://www.pewresearch.org/social-trends/2016/10/06/3-how-americans-view-their-jobs/">2016 study</a> found that 51% of Americans derive a sense of identity from their jobs, rising to 66% in STEM fields. That identity may slowly be pried away as AI performs these roles’ technical tasks more efficiently and cheaply.</p><p>Resistance to these changes is already appearing across many industries.</p><p>As I write this, mathematicians are struggling to accept the changes brought by recent advances and discoveries from OpenAI’s latest models:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D9E18Kjru44fR3EG.png" /></figure><p>In March 2026, the <a href="https://cwa-union.org/sites/default/files/2026-03/cwanews-2026-spring.pdf">Communications Workers of America argued that unions are necessary</a> against AI to retain worker value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/0*r-x6AdRHBeBJF9oJ.png" /></figure><p>In April 2026, <a href="https://www.thewrap.com/media-platforms/journalism/propublica-union-walkout-ai-contract-negotiations/">ProPublica journalists staged a 24-hour walkout</a> in light of management refusing to agree to not replace journalists with AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*23Qvb64tKfjN0wfL.png" /></figure><p>These are just three recent examples of resistance to AI-driven changes. We are still in AI’s early days, four years after ChatGPT brought the technology to the masses and sparked the wave of investment and discovery now called <a href="https://en.wikipedia.org/wiki/AI_boom">“The AI Boom”</a>. AI will continue rippling through the global economy, eventually reaching every area.</p><h3>The Risk</h3><p>Many predict a future “utopia” in which AI drives much of the economy while human work becomes optional. In this theoretical situation, humans may receive Universal Basic Income (UBI) checks simply for existing, funded by heavy taxation of AI-performed economic activity combined with proceeds from a “sovereign wealth fund” representing public ownership of AI infrastructure or capital.</p><p>For many, getting paid to do nothing while endlessly watching a favorite show with a glass of red wine sounds appealing, but I believe the enjoyment would be short-lived.</p><p>In a zoo, animals receive food, shelter, healthcare, and protection without having to earn them. Captivity removes the challenges of foraging, hunting, escaping predators, and similar activities. Although this may seem like a utopia for animals otherwise facing the risks of the wild, it is far from one.</p><p>Zoo animals are unhappy even with everything provided for free. They become depressed. Yet in the wild, where they struggle and face death around every corner, they thrive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*qA-XihTxMoPxKs7C.png" /></figure><p>The first zoo dates to 3500 BCE, based on animal remains archaeologists discovered in Egypt that appear to indicate captivity. In the more than 5,000 years since, captive animals’ psychological well-being has been a serious problem for zoo operators!</p><p>Many zoo animals in this “utopia” suffer from depression, boredom, and an inability to influence their surroundings through their own efforts. For centuries, veterinarians and animal behaviorists have studied this and introduced artificial challenges and threats: puzzle feeders, hidden food, new objects, varied terrain, and stimulating activities. These efforts have modestly improved captive animals’ psychological well-being.</p><p>It is striking that a “utopia” providing every need without effort can offer less fulfillment than an environment where every meal must be fought for, an injury may mean death, and a predator may be ready to pounce.</p><p>Something in these animals is wired to find satisfaction and fulfillment in “the struggle” itself.</p><p>This isn’t limited to other animals; humans have faced a similar issue in our physical lives for decades! The Industrial Revolution and subsequent years brought widespread machinery to meet the economy’s physical demands. As a result, our bodies have grown weaker and atrophied. But we invented a solution! The gym: artificial physical work that satisfies our animal need to maintain our bodies and supports our psychological happiness.</p><p>The point isn’t that we need suffering or insecurity. It’s that we need opportunities to choose challenges, develop abilities, and exercise agency.</p><p>Our modern information economy is the equivalent of hunting, foraging, building shelter, and other activities that fulfill a wild animal’s life. It has become our way of staying intellectually active and finding purpose and meaning.</p><p>Machinery removed the need for human <em>physical</em> labor. AI that reasons and thinks may reduce economic demand for some forms of human <em>intellectual</em> work. We may be moving toward a future where applying ourselves becomes optional, with rewards we once worked toward (money, housing, etc.) provided automatically through UBI funded by AI’s gains: a “zoo” of sorts.</p><p>Where will this leave us? In a Western world obsessed with productivity and an identity tied to intellectual output, entering “a zoo” where effort is no longer required will be shattering for many.</p><p>Beyond “the what” described above, I’ve recently been pondering “the why.” Why does the absence of challenges and struggle pose such an existential burden for humans? Two reasons come to mind:</p><ol><li>We are wired that way as animals. Evolution has “wired” our brains’ chemical receptors to reward us when we “do a good job.” We face a challenge and solve a problem. It feels good.</li><li>Western culture, increasingly global, ties self-worth and identity to intellectual output. Our intelligence is a tool for accomplishment. With nothing left to accomplish through our own abilities, we lose our sense of self-value.</li></ol><h3>The Path Ahead</h3><p>As some technical skills potentially become less economically valuable, where does this leave human labor? Time will tell whether humans can turn to “higher ground” (e.g. greater emphasis on human-to-human interaction), but meanwhile, millions of workers employed for their technical prowess will need to reassess their investments in learning and effort. This may be a bitter pill to swallow.</p><p><strong>Detach identity from productivity</strong>. As mentioned above, Western culture heavily ties worth to economic productivity, often rooted in specialized skills that took years to acquire. A first step is to undo this: to <em>decouple</em> identity from productivity. This adjustment will likely occur at both individual and generational levels, through personal emotional struggles and broader cultural changes. Three generations from now, writing code or analyzing data may be viewed like bragging today about how quickly one washes clothes with a washboard!</p><p><strong>Prioritize fulfillment over achievement</strong>. Particularly over the past decade, consumerism and social media have fueled a “keeping up with the Joneses” mentality: larger houses, more luxurious cars, the latest electronics, and the finest clothes. These often depend on career achievements that provide the means to acquire them. As AI plays a growing role in the global economy, we must refocus on what matters most: fulfillment and enjoyment of life. If the “utopia” explored earlier comes to pass, with AI driving most of the economy and meeting human needs, our most important task will be finding fulfillment. Develop opinions and taste. Value art for your enjoyment, not because it is “the best.” Value a friend’s guitar playing not for its precise timing, but because it is human-made and has “soul.”</p><p><strong>Self-reflect</strong>. In recent years, humanity has made what may be one of its greatest discoveries. It may even be the last major discovery we ever have to make on our own. Machines can now perform tasks involving <em>thinking</em> and <em>reasoning</em>, potentially moving us toward much greater intellectual abundance. We are in unprecedented times, and past generations’ “playbook” for a successful, fulfilling life has been thrown out. Whatever the future brings, it is largely up to you to decide what to make of it. Humanity may soon have an opportunity to pause and be still, no longer tending to an ever-growing list of workplace demands. In these moments, self-reflection will become more important as you consider how best to handle this opportunity. Some will lack answers and struggle, sinking into depression, unprepared for the loss of identity that an irrelevant skillset may bring. Others may thrive, planning to apply themselves differently but just as meaningfully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07d2b63caebc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 9: Closing Thoughts]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-9-closing-thoughts-1f6855269e5f?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f6855269e5f</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 15:48:51 GMT</pubDate>
            <atom:updated>2026-07-31T15:48:51.660Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZH5a5L5B31HiEZ8T.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>.</em></p><p>At this stage in the series we’ve fully explored the entire <em>Centauri</em> ecosystem: the quadcopter, the transmitter, and the telemetry analysis program. In this final chapter I’ll share some closing thoughts on the project overall, along with a few tips that will hopefully help you if you pursue building your own!</p><h3>Why do all this?</h3><p>The first question I want to address is the “why do all this?” question. As you can probably tell from the series, building a fully custom quadcopter and pilot transmitter is a daunting undertaking. Financially, it may even be <em>cheaper</em> to buy an off-the-shelf quadcopter/transmitter pair and call it a day! And from a time-to-value perspective, you’d be looking at potentially months of research and development before ever getting in the air, versus maybe a 2-day shipping window if you buy off the shelf.</p><p>The answer is: <strong>the challenge</strong>. I, like you if you’re still reading this, am an engineer. And engineers don’t just like <em>using</em> things; they like <em>making</em> them, and <em>understanding</em> how they work. The off-the-shelf method gives you the quickest time to use, but you skip over the fun (and difficult) parts of building your own. And that difficult, uphill battle of figuring everything out is where the <em>real learning</em> happens.</p><p>The pride I felt when <a href="https://www.youtube.com/watch?v=Wh5G9zdJbzk"><em>Scout</em> achieved its first flight back in 2023</a> and then when <a href="https://x.com/TimHanewich/status/1982566777273163850/video/1">Centauri achieved its first flight in 2025</a>, after <em>months</em> of frustration, hard work, and exploring new ideas, will <em>never</em> be something you can purchase. And the learnings that come along the way are a great bonus!</p><p>But more than that, I think building your own quadcopter (or any robotics project for that matter) is more valuable today than it has ever been. We live in an AI era, where anybody with access to the latest AI coding agent can “fake” intelligence or capability extremely easily.</p><p>Building something complicated, in both the software <em>and</em> hardware world, is not something that can be replicated by a 3-minute prompt. If you want to stand out and show your intrinsic skill, talent, or knowledge, venturing into the hardware space and completing a multi-month build is a wonderful way to set yourself apart.</p><h3>To go faster, slow down</h3><p>Something was very different between my first attempt at a custom flight controller (Scout) and my second (Centauri): my approach to the building process.</p><p>In 2023 when I built <em>Scout</em>, my engineering approach was to move quickly, break things, and iterate fast until I stumbled into a problem (that’s a bit exaggerated, but you get the point). I wasn’t focused on any one part of the project for very long; I’d get one piece mostly working and then quickly move on to the next, so focused on getting “the big payoff” as soon as possible: seeing Scout fly!</p><p>That mindset caused more problems than it fixed. Building something that bridges the software and hardware world, and is as complex as a quadcopter, is <em>very</em> challenging. It warrants time spent early in the project planning, weighing various approaches, and then relentless attention to detail through every facet of the build. While <em>Scout</em> flew, I wouldn’t call it as reliable or efficient as it could have been.</p><p>Fortunately, I learned from my mistakes. About two years later when making <em>Centauri</em>, I was far more methodical through the entire planning, design, building, programming, and testing process. No doubt I had a burning desire to see <em>Centauri</em> fly after the countless hours I invested turned into days, weeks, and months. But from what I learned with <em>Scout</em>, I knew any rushing would only cost me in the long run, because then I’d have to carve out time to <em>go back</em> and fix errors that wouldn’t have been there had I just given that part of the project the time it deserved.</p><p>With <em>Centauri</em> I was much more methodical and detail-oriented through every part of the project. In hindsight, my approach was likely subconsciously inspired by “Gradatim Ferociter”, the motto of Blue Origin that I must have read about a decade prior. <a href="https://www.geekwire.com/2016/jeff-bezos-blue-origin-motto-logo-boots/">Jeff Bezos explained the motto</a>:</p><blockquote>“Gradatim Ferociter” is Latin for “Step by Step, Ferociously. If you’re building a flying vehicle, you can’t cut any corners. If you do, it’s going to be just an illusion that it’s going to make it faster. You have to do it step by step, but you do want to do it ferociously.”</blockquote><h3>This isn’t easy!</h3><p>Let me be the first to tell you: building a custom quadcopter is <em>not</em> an easy feat. Even having this series and sample code to guide you, it will be challenging. If you decide to build your own iteration of <em>Centauri</em>, please bear this in mind. Be be kind to yourself. Take your time. This is a very daunting project, and one you likely won’t succeed at on the first try. Focus on the small things, one after another, and eventually the bigger picture will come together.</p><p>PID tuning, shown below, is one of the most frustrating part of the building process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*-CGuLpxXPFf2jt4S.gif" /></figure><p>And even after you have everything working, things happen!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*1D_II0ogUL6z6cWh.gif" /></figure><h3>Future Improvements</h3><p>As I described in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-1-the-centauri-ecosystem-eacfcecc90f5">chapter 1</a>, <em>Centauri</em> was already a huge upgrade over <em>Scout</em>, for a number of reasons. However, <em>Centauri</em>, at least in its current state as of this writing, is still relatively primitive in the overall landscape of quadcopters out there today.</p><p>I do plan to make further improvements to <em>Centauri</em>, building on this fantastic foundation. The following come to mind as immediate ideas:</p><ul><li><strong>Tweak Angle Estimates</strong>: The <em>Centauri Flight Controller</em> uses a complementary filter to estimate the pitch and roll angles during flight. While the angles are mostly correct, there are certainly discrepancies. I’ll need to take a closer look, identify any potential errors, and then work on improving their accuracy.</li><li><strong>Advanced Flight Controller Modes</strong>: as I discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-5-quadcopter-part-3-the-flight-controller-310b3f288975">chapter 5</a>, the <em>Centauri Flight Controller</em>, while impressive, is actually quite primitive in its capabilities. At some point I’d like to equip <em>Centauri</em> with additional hardware (sensors) and software to let it hold attitude, hold position, or even fly to various waypoints. This will be quite the undertaking!</li><li><strong>Handheld Transmitter</strong>: in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a">chapter 6</a> I described the decision to use an “augmented” PC (laptop) as the transmitter instead of building a custom transmitter. That decision worked very well! But at some point I’d like to fly <em>Centauri</em> without packing up a full laptop and transceiver platform. For that, I’ll need to design, build, and implement a handheld transceiver.</li><li><strong>Custom PCB</strong>: as I showed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-4-quadcopter-part-2-hardware-and-electronics-package-69a5c26bc30b">chapter 4</a>, my first iteration of the <em>Centauri quadcopter</em> is rather messy. I assembled all the hardware onto the 3D-prints and then wired everything together myself. Not the best formula if you’re after a clean, sleek-looking quadcopter. At some point I’ll develop a custom PCB (printed circuit board) for <em>Centauri</em> that will make the final result much sleeker while saving weight (more performance and range).</li></ul><p>Those are just the immediate big ideas that come to mind, but I’m sure many more will follow! If you have any ideas or suggestions, I’m all ears.</p><h3>Join The Community!</h3><p>In the three years since I released <a href="https://timhanewich.medium.com/taking-flight-with-the-raspberry-pi-pico-micropython-diy-quadcopter-drone-61ed4f7ee746">my write-up series on <em>Scout</em></a>, I’ve had so many positive interactions with members of the maker community; people that were just like me when I first sat down to build my own custom quadcopter flight controller. Messages, YouTube comments, tweets, and more.</p><p><strong>I’m creating a space for any makers interested in building <em>their own</em> iteration of <em>Centauri</em> to share progress and ideas, ask questions, and celebrate their successes</strong>! You can join us on the <strong>Full Stack Flight Discord Server</strong>. It’s completely free to join in on the conversation!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pdw8jpC1VBz3Tfbz.png" /></figure><p>Scan the QR code above or click <a href="https://discord.gg/wwqfmCUzGg">here</a> for an invite to the Full Stack Flight Discord Server!</p><p>I’ll be there too, sharing my own progress and helping answer questions from those pursuing building <em>Centauri</em> themselves! I hope to see you there.</p><h3>Parting Thought</h3><p>Building <em>my own</em> quadcopter, from absolute scratch, and taking flight had been a dream of mine. To build a flying machine, that would be amazing! And I remember just <em>how hard</em> it was pursuing this with <em>Scout</em> back in 2023. I remember the countless hours searching online, trying new ideas, reading over bugs, and brainstorming problems and their solutions.</p><p>If you can relate to that, I hope you’re able to find value in this series. I hope it helps you accomplish exactly what you’d like to do <em>without</em> the headache I experienced. In a way, this series and the entire <em>Centauri</em> project is a distilled version of everything I learned, packaged up for a new maker to leverage.</p><p>Use this guide! Learn and build understanding! And do something amazing. Good luck to you. 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f6855269e5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 8: Unpacking Flight Telemetry for Analysis]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-8-unpacking-flight-telemetry-for-analysis-73d251a4a449?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/73d251a4a449</guid>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[telemetry]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 15:48:43 GMT</pubDate>
            <atom:updated>2026-08-13T11:01:16.286Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jXNS7qHLzDtieiWY.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>.</em></p><p>Over the previous chapters in this series about the <em>Centauri</em> quadcopter ecosystem, we learned how Centauri’s quadcopter was designed, built, and programmed, and how the pilot’s transmitter was built for bidirectional communication with the quadcopter. In this chapter, we’ll look at the <em>after-flight</em> phase: analyzing telemetry data!</p><p>As discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-5-quadcopter-part-3-the-flight-controller-310b3f288975">chapter 5</a>, the <em>Centauri Flight Controller</em> logs telemetry data to its onboard flash storage several times per second. This data lives on the device and can easily be accessed later.</p><p>And as we discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-1-the-centauri-ecosystem-eacfcecc90f5">chapter 1</a>, Centauri’s 3D-printed airframe was designed so the USB port on the Raspberry Pi Pico (the microcontroller) is easily accessible:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v9b-xlIJmhNjzgSn.png" /></figure><p>Because the port is so accessible, it’s very easy to plug a USB cable between your computer and the quadcopter after a flight and pull off the telemetry!</p><h3>Accessing the Telemetry</h3><p>After plugging in your Raspberry Pi Pico (which has already been configured with MicroPython, flashed with the <em>Centauri Flight Controller Firmware</em>, and completed a successful flight), you can use <a href="https://thonny.org/">Thonny</a> to access the files on the Pico’s small flash memory, shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QAOi6FZYjLSesslB.png" /></figure><p>The top left of the window shows the directory on your PC you’re currently in, and the bottom left shows the files on the Raspberry Pi Pico. Using Thonny, we can easily transfer a file from the Pico to our computer by right-clicking it and choosing “Download to …”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*l7ukAOkoD3BEmySm.png" /></figure><p>After a few moments of transferring (depending on file size), you’ll have the file saved and accessible on your computer!</p><h3>Telemetry Format</h3><p>You’ll notice the file the <em>Centauri Flight Controller</em> logs to its flash storage is simply named log. To conserve the Pico&#39;s limited onboard storage <em>and</em> keep the telemetry packing as compute-efficient as possible, the raw telemetry is saved in a <strong>dense binary format</strong>. This means it&#39;s raw bytes, <em>not</em> something you can easily open and read like a .csv file or an .xlsx spreadsheet!</p><p>This raw log file contains all the telemetry, but in a very information-dense format. While it isn&#39;t human-readable as-is, we have a way to unpack it <em>into</em> a human-readable format. And that&#39;s where the <strong>analysis script</strong> comes in!</p><h3>Unpacking the Telemetry</h3><p>I wrote a lightweight script that handles <strong>unpacking</strong> the raw telemetry the quadcopter records into a human-readable format. You can find that script <a href="https://github.com/TimHanewich/centauri/tree/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/analysis">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ASgOjbUkEQB_mtrS.png" /></figure><p>As you can see above, using the analysis script is quite simple!</p><ol><li>Run main.py (Python script)</li><li>Pass the raw log file to it</li></ol><p>It then unpacks all the individual telemetry frames present in that raw log file (the Centauri Flight Controller logs multiple telemetry frames per second).</p><p>Next, it performs some analysis over the telemetry frames in the log file. More specifically, it focuses on each individual &quot;flight&quot; recorded in the file. It infers a unique &quot;flight&quot; whenever the quadcopter went from <strong>unarmed --&gt; armed --&gt; unarmed again</strong>. That span of time when it was &quot;armed&quot; (motors spinning) is considered a unique flight.</p><p>At the very end of its output, the script prompts you for the path of a file to dump the raw telemetry into, in a <em>human-readable format</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ROOon01VhrldsKri.png" /></figure><p>After passing in the path to a brand-new (empty) CSV file, you can open it and see the telemetry data presented in a spreadsheet format!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RHWlWWqHCDJMuEd8.png" /></figure><p>And now we have that telemetry, unpacked, in a human-readable format!</p><p><em>Note: below is the difference in storage size between the binary </em><em>log file and the unpacked </em><em>log.csv file, illustrating the efficiency gains of storing as binary. At 112 KB vs. 293 KB, the unpacked version is 162% bigger! The binary version has a footprint of only 38% of the unpacked version.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*34xZmdGnQpmO51QV.png" /></figure><h3>Understanding the Telemetry</h3><p>With the telemetry data unpacked into a human-readable format (a CSV file), let’s take a closer look at the full data available:</p><ul><li><strong>Seconds</strong>: the exact timestamp, in seconds, this telemetry frame was taken at. Note that this may <em>decrease</em> from a high timestamp to a low one if the quadcopter is rebooted (system time resets back to 0).</li><li><strong>Battery Voltage</strong>: raw battery supply voltage.</li><li><strong>Pitch Rate</strong>, <strong>Roll Rate</strong>, <strong>Yaw Rate</strong>: the <em>actual</em> angular velocity of the quadcopter’s body.</li><li><strong>Pitch Angle</strong> and <strong>Roll Angle</strong>: the angle estimates, calculated by the flight controller’s complementary filter. (<em>Note: as of this writing, I believe these to be only mildly accurate; I need to tweak the calculation.</em>)</li><li><strong>G-Force</strong>: how many G’s the quadcopter is pulling at that moment.</li><li><strong>Input Throttle</strong>: the pilot’s current throttle input, from 0 to 100, representing 0–100%.</li><li><strong>Input Pitch</strong>, <strong>Input Roll</strong>, <strong>Input Yaw</strong>: the pilot’s current input on the three axes, ranging from -100 to 100, representing -100% to 100%.</li><li><strong>M1 Throttle</strong>, <strong>M2 Throttle</strong>, <strong>M3 Throttle</strong>, <strong>M4 Throttle</strong>: the flight controller’s current output for each motor throttle, determined by the PID calculations.</li><li><strong>Cmd Last Receved ms</strong>: how long ago a <em>Control Packet</em> (see <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">chapter 2</a>) was last received, in milliseconds. Helps indicate Rx issues. Represented by 1 byte, so it maxes out at 2,550 ms.</li></ul><h3>Using the Telemetry: Overlay &amp; Dashboarding</h3><p>With a heap of telemetry data from the flights <em>Centauri</em> took, there’s a lot we can do with it, which is amazing!</p><p>The first use of the telemetry I want to highlight (and probably the flashiest 😊) is as a <em>telemetry overlay</em> on any onboard or ground-based video recordings of <em>Centauri</em> flying. <a href="https://dashware.software.informer.com/">Dashware</a> is a discontinued, yet still widely used, PC app that lets you overlay telemetry data onto a video recording. I developed <a href="https://github.com/TimHanewich/centauri/tree/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/dashware">Centauri telemetry-specific Dashware assets</a> that you can use to overlay your <em>Centauri</em> telemetry data directly onto a video with only a few clicks and timing syncs!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*uJIAY_U18oIplif0.gif" /></figure><p>The above is just a short clip from a much longer flight with <em>Centauri</em>. You can watch the full recording of that flight <a href="https://www.youtube.com/watch?v=evh0FCPapC8">here on YouTube</a>, embedded below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fevh0FCPapC8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Devh0FCPapC8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fevh0FCPapC8%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9050b0ecfec9408b1d35b1c2146d7aa/href">https://medium.com/media/e9050b0ecfec9408b1d35b1c2146d7aa/href</a></iframe><p><em>While I do mention the step-by-step process for overlaying telemetry data onto a video </em><a href="https://github.com/TimHanewich/centauri/tree/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/dashware#steps-to-overlaying-telemetry-on-onboard-footage"><em>in this section on GitHub</em></a><em>, I don’t go into great detail. If it would be helpful for me to write a dedicated article on that, let me know! Comment below or reach out to me.</em></p><p>Besides overlaying telemetry on top of a video, we can also plot this data in any dashboarding or reporting software like Power BI or Tableau. Or, in the modern era, you can prompt any AI coding agent to create a bespoke dashboard for you, like the one I made below in 5 minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AsXelnrDlq9XSyki.gif" /></figure><p><em>If you want to test this out for yourself, you can download the </em><em>dashboard.html file </em><a href="https://github.com/TimHanewich/centauri/releases/download/54577736/dashboard.html"><em>here</em></a><em>.</em></p><h3>Analyzing the Telemetry: Troubleshooting!</h3><p>As much as I love showing off the cool telemetry overlays and dashboards, any experienced engineer knows telemetry <em>also</em> helps diagnose the root cause of problems. It’s not the fun, flashy side of things, but closely reviewing telemetry is sometimes the best way to start figuring out what went wrong!</p><p>The best example of a problem occurring and telemetry analysis leading me to a conclusion and later a fix was a flight <em>attempt</em> I made on February 13, 2026. This was meant to be the first flight of <em>Centauri</em> in “Configuration D” (see <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-3-quadcopter-part-1-designing-a-3d-printed-airframe-9d4f9021a68c">chapter 3</a>) with the antenna mast.</p><p>As you can see below, it was <em>not</em> a successful flight!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*Nm08hCKa7L0N1dpj.gif" /></figure><p>And unfortunately the quadcopter broke in multiple places and needed repairs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OCFMyoID_b1mqgOX.png" /></figure><p>As soon as I applied any throttle, the motors spooled up to an aggressive speed and the quadcopter uncontrollably smacked the roof, then fell and crashed. I was puzzled as to why! Fortunately, I had the onboard telemetry, and analyzing it helped me determine the root cause:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R_mJgwUkNiPLj2qf.png" /></figure><p>I’ll spare you the lengthy details, but this kicked off a multi-week investigation into the root cause, <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/flights/20260213%20Nokomis%20Community%20Park/tests.md">experimental tests to isolate the issue</a>, and the development of <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/flights/20260213%20Nokomis%20Community%20Park/humidity-short-theory.md">some theories</a>, which ultimately led to a more secure, failsafe-heavy communication protocol between the transmitter and quadcopter.</p><p>Had I not had this telemetry to analyze, I would have been left with almost no breadcrumbs, making it particularly difficult to bounce back and make improvements!</p><h3>Try it yourself!</h3><p>Fortunately, unlike the rest of the <em>Centauri</em> ecosystem, you can try converting and analyzing <em>Centauri</em> telemetry <em>right now</em> with nothing more than a computer that has Python installed.</p><p>Below are a few direct download links to raw log binary files:</p><ul><li><a href="https://github.com/TimHanewich/centauri/releases/download/45/log">February 13, 2026: Corrupt Packet Failure</a> (discussed in section above)</li><li><a href="https://github.com/TimHanewich/centauri/releases/download/48/log">February 22, 2026: eight flights</a></li><li><a href="https://github.com/TimHanewich/centauri/releases/download/57/log">March 7, 2026: multiple multi-minute flights</a></li></ul><p>Download a log file above and pass it to <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/analysis/src/main.py">main.py</a> to unpack it, save it as a CSV file, and test your analysis skills!</p><h3>Close</h3><p>And now we’ve covered the third and final part of the <em>Centauri</em> ecosystem: post-flight analysis scripts and tools for analyzing real flight telemetry. This is a powerful capability that gives you a strong understanding of how your own <em>Centauri</em> quadcopter is working and helps you diagnose challenges (plus, it looks cool as an overlay!).</p><p>In the next chapter, the final chapter of this series (at least for now), I’ll share some closing thoughts about the <em>Centauri</em> project overall and how I recommend approaching building your own <em>Centauri</em> flight system!</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-9-closing-thoughts-1f6855269e5f">Full-Stack Flight, Chapter 9: Closing Thoughts</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73d251a4a449" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 7: Transmitter, Part 2: The Pilot’s Control Interface]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-7-transmitter-part-2-the-pilots-control-interface-dd14b90d5169?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd14b90d5169</guid>
            <category><![CDATA[aerospace]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 15:13:20 GMT</pubDate>
            <atom:updated>2026-07-30T15:13:20.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U3Lr9L0aUd7x7rM_.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LopGpa4gskDWv0RP.jpeg" /></figure><p>In the last chapter, we explored the role the <em>Transmitter</em> plays in the flight ecosystem. As we learned, the <em>Transmitter</em> is the critical device the pilot uses to both control the quadcopter’s flight and, potentially, view telemetry or other data the quadcopter sends back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g4JI8DFqol1sLk-N.png" /></figure><p>The <em>Centauri</em> Transmitter is really a <strong>3-part</strong> system, acting together as one:</p><ul><li><strong>Transceiver Platform</strong>: covered in depth in the last chapter, this grants the PC the ability to communicate over the 433 MHz spectrum.</li><li><strong>PC</strong>: a computer that runs the Transmitter program, acting as “the brain” of the transmitter.</li><li><strong>Xbox Controller</strong>: an external gamepad, the control interface the pilot manipulates.</li></ul><p>We covered the Transceiver Platform in depth in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a">the previous chapter</a>. In this chapter, we’ll focus on <strong>the PC</strong> and <strong>the Xbox Controller</strong>.</p><h3>Why a PC + Xbox Controller?</h3><p>I described this in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a">the previous chapter</a> but will briefly explain it again here. Consider two capabilities any decent transmitter should provide to the pilot:</p><ul><li>A sleek, ergonomic, reliable controller they can manipulate to fly the quadcopter.</li><li>A display screen that shows important input and telemetry data.</li></ul><p>I considered designing, printing, assembling, and building a custom transmitter with rudimentary analog controls and a small display screen. However, I decided against it, reasoning that <em>leveraging an off-the-shelf PC and Xbox controller</em>, which already provide these capabilities so well, would be more efficient. Fortunately, that hunch paid off!</p><p>So you can think of the Centauri Transmitter as a program that runs on a laptop, leveraging attached, specialized hardware that makes the transmitter’s entire operation possible!</p><h3>How the Transmitter Operates</h3><p>The transmitter program itself is written in <strong>Python</strong>, with an assortment of SDK dependencies I’ll describe later in this chapter. There are <strong>four</strong> critical coroutines that run within the transmitter program, side by side, continuously and indefinitely:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b81Tg9O7v3gcYZao.png" /></figure><ul><li><strong>Read Controller Inputs</strong>: read the inputs on the Xbox controller to understand how the pilot wants to change the quadcopter’s flight characteristics.</li><li><strong>Transmit Control Data</strong>: send updated control packets to the drone, telling it to adjust its flight to the pilot’s wishes.</li><li><strong>Receive Telemetry</strong>: listen for and unpack telemetry the drone sends back with important status information.</li><li><strong>Update Display</strong>: update the laptop’s screen, showing the most up-to-date information the pilot needs.</li></ul><p>A <a href="https://docs.python.org/3/library/asyncio-task.html">coroutine</a> is essentially a Python function that executes continuously, concurrently with other coroutines. Unlike <strong>threading</strong>, which also achieves concurrency, coroutines orchestrated by Python’s asyncio module use only a single core to cooperatively multitask between the four coroutines, tending to whichever needs attention.</p><p>Each of these is a mini-discipline in its own right, so I’ll dive deeper into all four in the sections below!</p><p><em>If you’d like to read the complete source code for the Transmitter, check it out </em><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py"><em>here</em></a><em> on GitHub, fully open source!</em></p><h3>Coroutine: Read Controller Inputs</h3><p>Reading the pilot’s inputs on the Xbox controller is absolutely critical to flying any drone! Particularly in FPV quadcopter flight, the pilot updates their inputs continuously, often making very small adjustments, and these small adjustments are vital to keeping the quadcopter in the air!</p><p>As mentioned previously, an off-the-shelf Xbox controller is a great device: we can plug it into the PC via USB and it’s plug and play! But once it’s plugged in, how do we read its inputs?</p><p>Enter <strong>pygame</strong>, a staple in the Python community for years now. <a href="https://pypi.org/project/pygame/">Pygame</a> is a free, open-source, cross-platform library most commonly used for lightweight game development, but which <em>also</em> natively supports reading Human Input Devices (HIDs) like the Xbox controller.</p><p>With pygame, we can easily identify the attached controller during setup:</p><pre># Initialize pygame and joystick module<br>console.print(&quot;[u]Controller Setup[/u]&quot;)<br>print(&quot;Initializing pygame for controller reads...&quot;)<br>pygame.init()<br>pygame.joystick.init()<br><br># count how many controllers (joysticks) are connected<br>num_joysticks = pygame.joystick.get_count()<br>print(&quot;Number of connected controllers: &quot; + str(num_joysticks))<br>if controller_required and num_joysticks == 0:<br>    print(&quot;No controllers connected! You must connect one before proceeding.&quot;)<br>    exit()<br><br># loop through each controller<br>for i in range(num_joysticks):<br>    tjs = pygame.joystick.Joystick(i)<br>    tjs.init()<br>    print(&quot;Joystick &quot; + str(i) + &quot;: &quot; + tjs.get_name())<br><br># select the controller that will be used<br>controller = None<br>if num_joysticks &gt; 0:<br>    controller = pygame.joystick.Joystick(0)<br>    controller.init()<br>    print(&quot;Controller #0, &#39;&quot; + controller.get_name() + &quot;&#39; will be used.&quot;)</pre><p>As you can see above, setup is quite easy. And the continuous coroutine that reads new Xbox controller inputs is shown below:</p><pre># set up continous Xbox controller read function<br>async def continuous_read_xbox() -&gt; None:<br><br>    # declare non-local variables from main we will be accessing<br>    nonlocal armed<br>    nonlocal mode<br>    nonlocal throttle<br>    nonlocal pitch<br>    nonlocal roll<br>    nonlocal yaw<br><br>    # Establish nonlinear transformers for each input axis<br>    nlt_pitch:tools.NonlinearTransformer = tools.NonlinearTransformer(2.0, 0.05)<br>    nlt_roll:tools.NonlinearTransformer = tools.NonlinearTransformer(2.0, 0.05)<br>    nlt_yaw:tools.NonlinearTransformer = tools.NonlinearTransformer(2.0, 0.10) # my deadzone is higher than the others because I have a broken right stick on my controller that often rests at around 8% in either direction<br><br>    # determine what the yaw axis ID is (right stick X, horizontal, axis)<br>    right_stick_x_axis_id:int = 2 # default to windows<br>    if sys.platform.startswith(&quot;linux&quot;): # if we are on linux<br>        right_stick_x_axis_id = 3 # set to3<br>    <br>    # infinite loop of reading<br>    while True:<br><br>        # handle changes in input state on the Xbox controller<br>        try:<br>            for event in pygame.event.get():<br>                if event.type == pygame.JOYAXISMOTION:<br>                    if event.axis == 5: # right trigger<br>                        throttle = (event.value + 1) / 2   # gets it to between 0.0 and 1.0<br>                    elif event.axis == 0: # left stick X axis (left/right)<br>                        roll = nlt_roll.transform(event.value)<br>                    elif event.axis == 1: # left stick Y axis (up/down)<br>                        # pushing the left stick forward will result in a NEGATIVE value. While this may seem incorrect at first, it is actually correct... pushing the left stick forward should prompt the quadcopter to pitch down (forward), hence it should be negative!<br>                        pitch = nlt_pitch.transform(event.value)<br>                    elif event.axis == right_stick_x_axis_id: # right stick X axis (left/right)<br>                        yaw = nlt_yaw.transform(event.value)<br>                    else:<br>                        #print(&quot;Axis &#39;&quot; + str(event.axis) + &quot;&#39;: &quot; + str(event.value))<br>                        pass<br>                elif event.type == pygame.JOYBUTTONDOWN:<br>                    if event.button == 0: # A<br>                        armed = True<br>                    elif event.button == 1: # B<br>                        armed = False<br>                    elif event.button == 4: # LB<br>                        mode = False # rate mode<br>                    elif event.button == 5: # RB<br>                        mode = True # angle mode<br>                    else:<br>                        #print(&quot;Button pressed: &quot; + str(event.button))<br>                        pass<br>        except: # if it fails for some reason (i.e. glitch or xbox controller unplugged?), unarm!<br>            armed = False<br>            throttle = 0.0<br>            pitch = 0.0<br>            roll = 0.0<br>            yaw = 0.0<br>        <br>        # wait a moment<br>        await asyncio.sleep(0.05)</pre><p>And that’s it! That’s the entire portion of the code that <em>reads input</em> from the USB-attached Xbox controller. I’ll explain a few things in a bit more detail:</p><p>First, the NonlinearTransformer. This borrows from a concept I developed while building <a href="https://github.com/TimHanewich/scout"><em>Scout</em></a>, my previous quadcopter flight controller, but never actually used. One problem I hit early in testing <em>Centauri</em>, after it became air-worthy, was how a <em>minor</em> input on the sticks would produce a relatively large reaction from the quadcopter, making it feel &quot;twitchy&quot;. To combat this, the Transmitter implements a <strong>NonlinearTransformer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iOJaymxrlrIB2jOe.png" /></figure><p>This is just a basic mathematical model that uses trigonometry to transform an input into a “dampened” version of itself, while still preserving the full range of input at the extremities. As you can see in the code snippet above, all three orientation inputs (pitch, roll, yaw) pass through a NonlinearTransformer that dampens the raw inputs. You may also notice the NonlinearTransformer implements a minor deadzone, preventing extremely small non-zero positions from being interpreted as valid input.</p><p>You’ll also see that four buttons on the controller are monitored for being pressed: <strong>A</strong>, <strong>B</strong>, <strong>LB</strong>, and <strong>RB</strong>:</p><ul><li><strong>A</strong>: “arms” the drone, moving the transmitter into a mode where it broadcasts non-zero throttle control packets. This basically enters flight mode!</li><li><strong>B</strong>: “disarms” the drone, shifting the transmitter to <em>only</em> broadcast zero-throttle packets, telling the quadcopter to stop spinning its motors.</li><li><strong>LB</strong> and <strong>RB</strong>: switch between “rate mode” and “angle mode”, covered in chapter 5. <em>Note: while this mode-switch capability exists, it isn’t implemented. As of this writing, the Centauri Flight Controller doesn’t yet support angle mode.</em></li></ul><p>And that’s how the continuous_read_xbox() coroutine works! Think of it as an ongoing bit of code that constantly reads the inputs on the Xbox controller, translates the raw values, and updates internal variables that other coroutines then use.</p><h3>Coroutine: Transmit Control Data</h3><p>With control inputs collected from the Xbox controller, we now focus on the next routine: <strong>transmitting these inputs to the quadcopter via Control Packets</strong>. Remember the <strong>Control Packet</strong> we discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">chapter 2</a>? The role of this coroutine is to take the pilot’s raw inputs on the Xbox controller and encode them into a <strong>Control Packet</strong> that is sent out continuously at a high frequency.</p><pre># set up continuous radio sending<br>async def continuous_radio_tx() -&gt; None:<br><br>    # declare variables from main we will be updating<br>    nonlocal packets_sent<br><br>    while True:<br>        if armed:<br>            throttle_to_send:float = idle_throttle + ((max_throttle - idle_throttle) * throttle) # scale within range, if armed<br>            ToSend:bytes = tools.pack_control_packet(throttle_to_send, pitch, roll, yaw) # pack into bytes<br>            if ser != None:<br>                ser.write(ToSend + &quot;\r\n&quot;.encode()) # send it via HC-12 by sending it to the transceiver over the serial line<br>                packets_sent = packets_sent + 1<br>            await asyncio.sleep(0.05) # 20 Hz<br>        else:<br>            ToSend:bytes = tools.pack_control_packet(0.0, 0.0, 0.0, 0.0) # pack all 0 inputs<br>            if ser != None:<br>                ser.write(ToSend + &quot;\r\n&quot;.encode()) # send it via HC-12 by sending it to the transceiver over the serial line<br>                packets_sent = packets_sent + 1<br>            await asyncio.sleep(0.5) # 2 Hz</pre><p>As you can see above, continuous_radio_tx(), responsible for transmitting control data out to the quadcopter, is actually fairly simple. It handles the &quot;armed&quot; and &quot;disarmed&quot; situations separately:</p><p>If armed, it first scales the raw throttle (0–100%) linearly between idle_throttle and max_throttle, two onboard transmitter settings. Think of idle_throttle as the motor throttle when the quadcopter is <em>armed</em> but no throttle input has been applied yet (sitting on the ground, motors spinning, ready to take off). max_throttle is the maximum throttle the transmitter will ever send, even if the pilot applies 100% throttle on the controller. Both are configurable in the settings; more on that later.</p><p>It then packs all four control inputs (throttle, pitch, roll, yaw) into a bytes object, which is the Control Packet! Finally, it transmits this Control Packet to the quadcopter by sending it over the serial line (USB) to the Transceiver Platform, which broadcasts it out (read more about the Transceiver Platform in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a">chapter 6</a>).</p><p>If disarmed, the transmitter instead ignores all raw inputs on the Xbox controller, encodes a “zero-input” Control Packet in which all controls are at 0%, and broadcasts that out, essentially telling the quadcopter to “shut down all your motors and do nothing”.</p><p>You’ll also see that <em>during flight</em> (when armed), this coroutine continuously broadcasts 20 Control Packets per second (20 Hz), reducing that to just 2 per second (2 Hz) when transmitting disarmed packets. The higher rate is necessary for accurate flight, while the lower rate when disarmed gives the HC-12 on the Transceiver Platform more “available time” to <em>hear</em> the telemetry the quadcopter broadcasts while unarmed.</p><p>And speaking of receiving telemetry from the quadcopter, that brings us to our next section!</p><h3>Coroutine: Receive Telemetry</h3><p>As we discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">Chapter 2 about the Centauri Communication Protocol</a>, <em>Centauri</em> supports <strong>bidirectional</strong> communication between the pilot and the quadcopter. While unarmed (not in flight), the quadcopter continuously broadcasts <strong>Telemetry Packets</strong> containing status updates for the pilot.</p><p>In this coroutine, the Transmitter program checks for and receives those Telemetry Packets, unpacks them, and updates the internal variables that track the most recent quadcopter status data.</p><pre># set up continuous radio rx (through tranceiver)<br>async def continuous_radio_rx() -&gt; None:<br>    &quot;&quot;&quot;Handles all received data from the transceiver via the USB (the transceiver passes along data it receives via the HC-12)&quot;&quot;&quot;<br><br>    # declare nonlocal variables we will be modifying<br>    nonlocal packets_received<br>    nonlocal packets_last_received_at<br>    nonlocal vbat # drone&#39;s battery level<br>    nonlocal pitch_rate<br>    nonlocal roll_rate<br>    nonlocal yaw_rate<br>    nonlocal pitch_angle<br>    nonlocal roll_angle<br><br>    # declare rxBuffer of all data received from transceiver through the USB serial line<br>    rxBuffer:bytearray = bytearray()<br><br>    # continuously monitor and receive new data from the serial port (from transceiver)<br>    while True:<br><br>        # read data if any is available!<br>        if ser != None:<br>            if ser.in_waiting &gt; 0: # if we have data available<br>                data:bytes = ser.read(ser.in_waiting) # read the available data<br>                rxBuffer.extend(data)<br>            <br>        # handle data if we have any full lines in there<br>        while &quot;\r\n&quot;.encode() in rxBuffer:<br><br>            # get the line<br>            loc:int = rxBuffer.find(&quot;\r\n&quot;.encode())<br>            ThisLine:bytes = rxBuffer[0:loc+2] # include the \r\n at the end (why we +2)<br>            rxBuffer = rxBuffer[loc+2:] # remove the line<br><br>            # increment packets received and mark the receiving timestamp<br>            packets_received = packets_received + 1<br>            packets_last_received_at = time.time()<br><br>            # Handle the line based on what it is<br>            if ThisLine[0] &amp; 0b00000001 == 0: # if bit 0 is 0, it is a telemetry packet<br>                TelemetryData:dict = tools.unpack_telemetry(ThisLine)<br>                if TelemetryData != None: # it returns None if there was an issue like it wasn&#39;t long enough<br>                    vbat = TelemetryData[&quot;vbat&quot;]<br>                    pitch_rate = TelemetryData[&quot;pitch_rate&quot;]<br>                    roll_rate = TelemetryData[&quot;roll_rate&quot;]<br>                    yaw_rate = TelemetryData[&quot;yaw_rate&quot;]<br>                    pitch_angle = TelemetryData[&quot;pitch_angle&quot;]<br>                    roll_angle = TelemetryData[&quot;roll_angle&quot;]<br>            elif ThisLine[0] &amp; 0b00000001 &gt; 0: # if bit 0 is 1, it is a special packet (text)<br>                msg:str = tools.unpack_special_packet(ThisLine)<br>                drone_messages.append(display.Message(msg, time.time()))<br>            else:<br>                # handle uknown packet type?<br>                pass<br>            <br>        # sleep<br>        await asyncio.sleep(0.05)</pre><p>In the above code, ser is a Serial object from <a href="https://pythonhosted.org/pyserial/">the pyserial</a> package.</p><p>Observe that, at a rate of 20 times per second:</p><ul><li>Any newly received data is checked for.</li><li>If newly received data is available, it’s collected.</li><li>Collected data is broken out into “lines” (discrete packets).</li><li>Each line is interpreted by type and then unpacked.</li><li>The unpacked data is used to update internal tracking variables.</li></ul><p>The most interesting piece of that code is probably the use of tools.unpack_telemetry(). <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/tools.py#L100">The </a><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/tools.py#L100">unpack_telemetry function</a> is a lightweight tool that translates the encoded <strong>Telemetry Packet</strong> (just a raw bytes object) into its discrete data points. You pass in the bytes object and get back a dict with the data points!</p><p>As you can see in the code above, various variables (vbat, pitch_rate, roll_angle, drone_messages, etc.) are updated; these variables will later be displayed to the pilot, which is a great segue to our next and final coroutine!</p><h3>Coroutine: Update Display</h3><p>We now focus on the final coroutine: <em>displaying</em> all of this data for the pilot to see! This is a critical capability, as the pilot needs to see their own control input to confirm everything is working as expected, and also monitor the quadcopter’s status to confirm it’s still fit to fly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n3z6xO7IVFvq6jpm.gif" /><figcaption>Unarmed → Armed Example</figcaption></figure><p>The Transmitter program itself does <em>not</em> use a full GUI (graphical user interface); it uses the terminal directly. I’m using <a href="https://github.com/textualize/rich">rich</a>, a popular Python library that lets you build beautiful formatting directly in the terminal, to display the pilot’s dashboard.</p><p>I developed <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/display.py">display.py</a> as a modular capability that uses rich to display all the data in the terminal, in a format I like. You pass a DisplayPack object into the construct() function, and the function builds a structure that&#39;s displayed in the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DOs2B5fUjQyuxFkw.png" /><figcaption>The pilot’s control interface</figcaption></figure><p>The following is the display-updating coroutine, which uses the display.py module I wrote:</p><pre># set up continuous display function<br>async def continuous_display() -&gt; None:<br><br>    # display with live<br>    with rich.live.Live(refresh_per_second=60, screen=True) as l: # the refresh_per_second sets the upper limit for refresh rate<br>        while True:<br><br>            # prepare to print with display packet<br>            dp:display.DisplayPack = display.DisplayPack()<br><br>            # plug in basic telemetry info<br>            dp.uptime_seconds = time.time() - booted    # uptime of the system, in seconds (current time minus the booted timestamp)<br>            dp.packets_sent = packets_sent<br>            dp.packets_received = packets_received<br>            if packets_last_received_at != None:<br>                dp.packet_last_received_ago_ms = int((time.time() - packets_last_received_at) * 1000)<br>            else:<br>                dp.packet_last_received_ago_ms = None<br><br>            # plug in control variables<br>            dp.armed = armed<br>            dp.mode = mode<br>            dp.throttle = throttle<br>            dp.pitch = pitch<br>            dp.roll = roll<br>            dp.yaw = yaw                <br><br>            # plug in drone telemetry variables<br>            dp.drone_battery = vbat<br>            dp.pitch_rate = pitch_rate<br>            dp.roll_rate = roll_rate<br>            dp.yaw_rate = yaw_rate<br>            dp.pitch_angle = pitch_angle<br>            dp.roll_angle = roll_angle<br><br>            # plug in drone messages<br>            dp.messages = drone_messages<br>            <br>            # get to display<br>            td = display.construct(dp)<br><br>            # update live<br>            l.update(td)<br><br>            # wait<br>            await asyncio.sleep(0.01)</pre><p>As you can see above, the continuous_display() coroutine is actually quite simple! It continuously packs all the internal status variables (kept up to date by the three other coroutines) into a new DisplayPack object, which is passed into the construct() function of my display.py module and turned into a rich.console.Group object. This rich.console.Group is then fed into a rich.live.Live object that manages the display, refreshing what&#39;s shown on screen at 60 Hz!</p><h3>Settings Update</h3><p>If you’re looking at <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py">the complete </a><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py">main.py Transmitter program</a>, you&#39;ll notice it <em>also</em> lets the pilot use the laptop to update both transmitter-side and quadcopter-side flight settings.</p><p>The ability to update these settings lives in the update_settings() function. This function first prints the current settings (idle throttle, max throttle, PID configurations, etc.) and then asks what the pilot wants to do, if anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XP7UociZLDHQ_5MV.png" /><figcaption>Settings Config Screen</figcaption></figure><p>From here, the pilot has a few options:</p><ol><li><strong>Load Settings Profile</strong>: pre-load default PID gains, values I use that are confirmed to work. You can adjust this PID profile in the source code if you wish.</li><li><strong>Update Controller Settings</strong>: update the idle throttle and max throttle the transmitter constrains to.</li><li><strong>Update PID Settings</strong>: enter interactive configuration where the pilot can punch in the unique PID gains for each setting (used for PID tuning).</li><li><strong>Adjust PID Master Multiplier</strong>: apply a multiplier across all configured PID values. This is helpful when the pilot wants to increase or decrease the drone’s responsiveness while keeping all PID gains proportional to each other.</li><li><strong>Send Settings to Drone</strong>: send the PID settings the pilot set on the transmitter (currently “loaded and ready”) off to the drone via a <em>Settings Update Packet</em> (read more about this in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">Chapter 2</a>).</li><li><strong>Return</strong>: go back to the main dashboard.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tj4nVFSuKQFiksBo.gif" /><figcaption>Sending out Settings Update Packet to Drone</figcaption></figure><p><em>Above: from the main control interface, pressing ‘S’ on the keyboard, and then sending over a settings update packet, receiving confirmation from the drone, and then returning to the main control interface.</em></p><p>While I removed it from the snippet above for simplicity, you’ll see <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py#L507">in the full main.py file</a> that the continuous_display() function checks for presses of the &quot;s&quot; key while in the main dashboard. If &quot;s&quot; is pressed, it fires off the update_settings() function, entering the settings menu.</p><h3>Validate Drone Connection</h3><p>If you did look at the full continuous_display() function, you&#39;ll also see it <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py#L523">checks for the &quot;c&quot; key being pressed</a>. If &quot;c&quot; is pressed, it invokes the validate_connection() function, a simple function that tries to make contact with the quadcopter to confirm it&#39;s operational.</p><p>The validate_connection() function sends out a TIMHPING message and waits a moment; if the quadcopter is operational, it should send back a TIMHPONG message, which the transmitter listens for.</p><p>This is just a simple way for the pilot to confirm the quadcopter is on and functioning as expected!</p><h3>Close</h3><p>Wonderful! With the <em>Centauri</em> quadcopter covered in previous chapters, the complete <em>Centauri</em> Transmitter system covered in this chapter and the last, and the communication protocol between the two covered in detail in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">Chapter 2</a>, we now fully understand how the two work together to achieve flight!</p><p>In the next chapter, we’ll look at the <em>analysis</em> phase: extracting, unpacking, and analyzing telemetry recorded onboard the quadcopter. The final piece (for now) of the <em>Centauri</em> ecosystem!</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-8-unpacking-flight-telemetry-for-analysis-73d251a4a449">Full-Stack Flight, Chapter 8: Unpacking Flight Telemetry for Analysis</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd14b90d5169" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 6: Transmitter, Part 1: Transceiver Platform]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/7aee3793da9a</guid>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <category><![CDATA[radio]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 15:13:09 GMT</pubDate>
            <atom:updated>2026-07-30T15:13:09.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dqXjjJtvfv6l4NQ-.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>. This article contains Amazon affiliate links. If you make a purchase through them, I may earn a small commission at no extra cost to you.</em></p><p>Over the previous three chapters in this series, we learned how the <em>Centauri Quadcopter</em> was designed, fabricated, assembled, wired, and programmed from the ground up. Now, with a functioning quadcopter, it’s time to focus on the other half of the equation: how the pilot will control it!</p><p>In drone piloting, this is often called the pilot’s <strong>transmitter</strong>: a device the pilot uses to <em>transmit</em> control commands to the drone in real time, continuously updating its flight. A transmitter is typically responsible for the following tasks:</p><ol><li>Sending control data to the drone that represents the pilot’s control input.</li><li>Receiving telemetry data from the drone and presenting it to the pilot on a screen or dashboard.</li></ol><p>In many commercial systems, the transmitter may do more than this, and sometimes less. At a bare minimum it handles #1, with #2 being a common addition. My previous quadcopter, <a href="https://timhanewich.medium.com/taking-flight-with-the-raspberry-pi-pico-micropython-diy-quadcopter-drone-61ed4f7ee746">Scout</a>, only did #1 (a single-direction communication stream); but as we discussed in depth in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">chapter 2</a>, communication in the <em>Centauri</em> system is bidirectional, so the transmitter must <em>also</em> be able to receive data from the drone!</p><p>When designing the pilot side of the <em>Centauri</em> ecosystem, I had two options for how to build the transmitter:</p><ul><li><strong>Dedicated Device</strong>: build a custom, dedicated system with all the bells and whistles needed to control the quadcopter <em>and</em> show telemetry: joysticks, trigger switches, buttons, screens, an onboard battery, etc.</li><li><strong>Extend Laptop Capability</strong>: equip a standard laptop with the ability to send and receive radio communications, use a standard USB-ready gamepad, and write a script that runs on the PC to perform all operations.</li></ul><p>Both options have their pros and cons. To cut a long story short, I ultimately chose the <strong>Extend Laptop Capability</strong> option. It’s certainly the path that gets us up and flying as quickly as possible, taking advantage of an off-the-shelf gamepad (the Xbox Controller) and the laptop’s display for showing data. All we have to worry about from there is giving the laptop the <em>ability</em> to send and receive data with the quadcopter, plus the script that orchestrates the entire operation. For simplicity and speed, this certainly beats designing and building a custom transmitter!</p><p>We can think of the transmitter as three separate components brought together as one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jwm_oKuDmrrd6zS_.png" /></figure><p>Since the gamepad side is very simple (buy <a href="https://amzn.to/4wUxGlE">an Xbox controller</a> and plug it into the PC via USB!), I’ll focus on how I developed the other two components: <strong>the transceiver platform</strong> and the <strong>transmitter program</strong>. In this article, I’ll focus on <em>the transceiver platform</em>.</p><h3>Quick Reference: Complete Hardware List</h3><p>Before diving in, here’s a one-stop shopping list of every component used to build the transceiver platform, for easy reference! Just in case you visited this chapter specifically to find a link to something you needed to buy. 😊</p><ul><li><a href="https://amzn.to/4vZ5DkH">Raspberry Pi Pico</a> (microcontroller) — 1x</li><li><a href="https://amzn.to/4eWx48V">HC-12</a> (wireless transceiver) — 1x (the quadcopter also has one)</li><li><a href="https://www.digikey.com/short/qjz8575r">FLEXI-SMA-433 433 MHz antenna</a> — 1x (<em>optional — you can also use the HC-12’s spring antenna if low-range is acceptable</em>)</li><li><a href="https://amzn.to/4wDVgTh">CP2102</a> (USB-to-UART adapter) — 1x</li><li>3D-printed platform (<a href="https://www.thingiverse.com/thing:7376838">.stl files on Thingiverse</a>)</li><li>A bit of wire and solder!</li></ul><h3>Transceiver Platform: Hardware</h3><p>On its own, a laptop can’t communicate over the 433 MHz band the way the HC-12 on the <em>Centauri</em> quadcopter can. So we have to give the laptop that ability. Fortunately, the solution is rather simple: create a small, lightweight device that the PC communicates with via serial, and let that device handle the sending and receiving over the HC-12. You can think of this <strong>transceiver platform</strong> as a “broker” between the PC and the quadcopter, handling the transmission and reception of messages over the air.</p><p>The transceiver platform is a very simple device that plugs into the laptop via USB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UvgG4UpEHEPrR0r6.png" /></figure><p>As pointed out in the photo above, it connects to the laptop via a <a href="https://amzn.to/4wDVgTh">CP2102</a> USB-to-UART adapter that lets the laptop communicate with it seamlessly. On the radio side, a <a href="https://www.digikey.com/short/qjz8575r">FLEXI-SMA-433 433 MHz antenna</a> lets it broadcast and receive data over the 433 MHz band. I’ve had a lot of success with this antenna and recommend it!</p><p>At the logic layer, the transceiver platform is very simple: a Raspberry Pi Pico wired to an HC-12:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VwqPHUFzVQKCuZ1d.png" /></figure><p>And as you can probably tell from the images above, I designed and 3D-printed a very simple platform for mounting all the components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GXdprGXGfa0vzrlh.png" /></figure><p>You can download the .stl files <a href="https://www.thingiverse.com/thing:7376838">on Thingiverse</a>! As noted above, it&#39;s a simple two-component design. (See the <em>Quick Reference</em> list above for the full parts list.)</p><h3>Transceiver Platform: Software</h3><p>With the transceiver’s hardware covered and assembled, we’ll move on to the <em>code</em> flashed onto the transceiver’s Raspberry Pi Pico. Like the <em>Centauri</em> quadcopter’s flight controller, it’s written in MicroPython.</p><p>The role of the transceiver platform is simple: serve as a “broker” between the PC and the quadcopter. In other words, if a message is received from the drone, send it to the PC via the USB connection; and if the PC sends a message to the transceiver platform via USB, send it on to the drone. That simple!</p><p>And so our code is quite simple too! You can find the complete source code (two files) for the transceiver platform <a href="https://github.com/TimHanewich/centauri/tree/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/transceiver/src">here</a>, which I’ll explain below:</p><ul><li><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/transceiver/src/main.py">main.py</a>: the main transceiver platform operation code, handling the receiving and transmitting of messages via the onboard HC-12.</li><li><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/transceiver/src/HC12.py">HC12.py</a>: a lightweight “helper” module I wrote that makes interfacing with the HC-12 in MicroPython easier. More information about it can be found <a href="https://github.com/TimHanewich/MicroPython-Collection/tree/master/HC-12">here</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RQZFLzGRt9sbofC9.png" /></figure><p>As shown in the diagram above, there are <strong>four types</strong> of communication exchanged between the PC program and the transceiver platform (connected via USB, using UART to communicate):</p><ol><li><strong>PING/PONG</strong>: the PC can send TRANPING (encoded in ASCII) to the transceiver as a &quot;hey, are you there?&quot; check. If received, the transceiver responds TRANPONG to confirm it&#39;s on.</li><li><strong>STATUS</strong>: the PC can also request a status update. If the PC sends the message TRANSTATUS? (encoded in ASCII), the transceiver responds with the HC-12&#39;s configuration (mode, channel, power). <em>Note: as of this writing, this functionality is available but not used.</em></li><li><strong>TRAN Message</strong>: the transceiver platform can send any unstructured message to the PC to flag a situation, status, or issue. To ensure a message that originated from <em>the transceiver</em> isn’t confused with one that originated from <em>the drone</em>, TRAN (encoded in ASCII) is prepended to the message.</li><li><strong>“Passthrough” Communication</strong>: for all other binary payloads the transceiver platform receives from or sends to the PC, if it <em>isn’t</em> one of the payload types above, it can be assumed to be a message either from the drone (bound for the transmitter) or from the transmitter (bound for the drone).</li></ol><p>The fourth communication type, the “passthrough,” is the most important and most commonly used capability of the transceiver platform. To reiterate, the main purpose of the transceiver platform is to serve as a “passthrough broker” between the drone and the transmitter program, handling the wireless transmitting and receiving.</p><p>With those communication types covered, let’s take a high-level look at how the transceiver platform, powered by code running on the Raspberry Pi Pico, operates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5VNR9w4IPWbe4pFT.png" /></figure><p>As you can see above, when the transceiver platform’s Raspberry Pi Pico first boots up, it runs through a four-step boot sequence. In this stage, it:</p><ul><li>Turns on the onboard LED to confirm it has received power and is booting.</li><li>Sets up two UART interfaces to communicate with both the PC and the HC-12 (both use UART to communicate with the Pico).</li><li>Configures the HC-12 according to the <em>Centauri-specific</em> settings.</li><li>Sends an “I’m online now!” message to the PC, in case it’s listening and waiting for it.</li></ul><p>The entire boot sequence is quite quick! It usually completes in under a second, ready to go almost as soon as power is received.</p><p>After booting, it moves into the operational phase, the most important piece! In this phase it:</p><ul><li>Checks for new PC-to-drone communication. It checks the UART interface with the PC for incoming data. As long as this data isn’t one of the three “internal” message types described above, it assumes the PC intends to send it out to the drone.</li><li>If there is new PC-to-drone data, transmits it out via the HC-12, relaying it unaltered over UART.</li><li>Checks for new drone-to-pilot communication. It checks the UART interface with the HC-12 for newly received data. If there is new data, it assumes it’s a message from the drone intended for the pilot.</li><li>If there is new drone-to-pilot communication, relays it unaltered to the PC via UART.</li></ul><p>And that’s it! It really is that simple. The transceiver platform is nothing more than a broker, relaying messages between the drone and the pilot with low latency using its HC-12.</p><h3>Close</h3><p>With the transceiver platform assembled and operational, the PC running our transmitter program now has an “accessory device” that lets it wirelessly communicate with the drone over the 433 MHz band!</p><p>In the next chapter, we’ll take a closer look at exactly how the PC transmitter program works to control the <em>Centauri</em> drone!</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-7-transmitter-part-2-the-pilots-control-interface-dd14b90d5169">Full-Stack Flight, Chapter 7: Transmitter, Part 2: The Pilot’s Control Interface</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7aee3793da9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 5: Quadcopter, Part 3: The Flight Controller]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-5-quadcopter-part-3-the-flight-controller-310b3f288975?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/310b3f288975</guid>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[aerospace]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <category><![CDATA[flight-controller]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 11:54:48 GMT</pubDate>
            <atom:updated>2026-07-29T11:54:48.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6bryxW8jRbLSK-qX.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>. This article contains Amazon affiliate links. If you make a purchase through them, I may earn a small commission at no extra cost to you.</em></p><p>With the body printed, the hardware assembled, and everything wired up, we’re ready for the software phase: programming the flight controller! Having built both <em>Scout</em> and <em>Centauri</em>, I can confidently say this is the most challenging part of the entire build, but don’t worry, I’ve done it successfully and will walk you through it!</p><h3>Language of Choice: MicroPython (Python)</h3><p>As discussed in previous chapters, the <em>Centauri Quadcopter</em> uses an RP2040 microcontroller, hosted on a Raspberry Pi Pico. When developing on the RP2040, we have two directions to choose from in terms of programming language:</p><ul><li><strong>MicroPython</strong>: a port of the popular Python programming language, designed specifically for <em>microcontrollers</em>.</li><li><strong>C/C++</strong>: a low-level language that is harder to write and implement, but delivers a major boost in raw performance.</li></ul><p>For most performance-critical flight controllers (those needing maximum execution speed, sub-millisecond timing precision, low-latency interrupts, and heavy mathematical processing), <strong>C/C++</strong> would be the obvious choice. However, my goal with this project was to keep the code and internal processes transparent and <strong>approachable</strong> for any novice looking to understand flight controllers and build their own. Python is far more approachable, significantly easier to read and understand, and allows for a very quick iterative testing cycle. So for <em>Centauri</em>, as with <em>Scout</em>, I chose to develop the flight controller in MicroPython.</p><p>That said, this isn’t without trade-offs. As mentioned above, MicroPython runs significantly slower on the Pico than its C/C++ counterpart because it’s an <em>interpreted</em> language. Flight controllers notoriously need to run code very quickly, and MicroPython’s slower execution puts that at risk. Even so, I’ve successfully developed the Centauri Flight Controller in MicroPython with ample performance for stable flight; I assure you, it’s do-able!</p><h3>The Centauri Flight Controller: What it is, What it isn’t</h3><p>Within the domain of quadcopter flight controllers and computers, there are what I’d call four “levels” of flight control, which I’ll describe below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fWpgzdk4mAtBLP0G.png" /></figure><ul><li><strong>Rate Control</strong>: the most primitive form of flight controller. It only monitors and controls angular velocity (the rate of change in orientation). If the pilot lifts off the sticks, the flight controller tries to achieve zero change in orientation, holding whatever orientation it’s currently in.</li><li><strong>Attitude Control</strong>: one level up from rate control. This is more complex: the flight controller not only observes and controls the rate of change in orientation, but also its absolute orientation: its pitch and roll angle relative to the ground. If the pilot lifts off the sticks, the flight controller tries to “level out” the quadcopter, achieving 0 degrees of pitch and roll.</li><li><strong>Position Control</strong>: one level up from attitude control. Here we move beyond a mere “flight controller” and into “flight computer” territory. At this level, the flight computer also observes the <em>position</em> of the quadcopter in 3D space, typically using multiple sensors like a GPS and barometer. It observes and optimizes for a fixed position in space: a location, altitude, and orientation. If the pilot lifts off the sticks, the flight computer holds that position, actively adjusting if wind pushes it off course.</li><li><strong>Mission Control</strong>: the highest level of flight computer, typically reserved for industrial and professional applications beyond the scope of hobbyist drones. Here, an even more sophisticated flight computer <em>updates</em> the quadcopter’s goal position over a planned period of time (a flight mission), autonomously flying it through space to accomplish a goal. This is common in professional applications like agriculture (seeding a field along a fixed flight path). Another example is DJI’s “return to home” feature, where the drone takes over autonomous control and flies itself back to a set point on autopilot.</li></ul><p><strong>The Centauri Flight Controller is a “Rate Control” flight controller</strong>. It’s the most primitive form, requiring only the limited avionics system we’ve given it (read more about that in the previous chapter).</p><p>When I sat down to create <em>Centauri</em> in July of 2025, my original intent was an <strong>Attitude Control</strong> flight controller, capable of observing and controlling its attitude (pitch and roll angles). I later abandoned that in pursuit of something simpler, but you’ll still find remnants of it in today’s flight controller code (like the angle estimation algorithms)!</p><h3>How the Centauri Flight Controller Works</h3><p>For the sake of organization, I’ll describe the flight controller as having “two sides,” each covered in detail in the sections below.</p><p>The first is the <strong>startup sequence</strong>: everything the flight controller does to prepare for normal operation the moment it boots (as soon as the Raspberry Pi Pico receives power).</p><p>The second is the <strong>control loop</strong>: the core loop that continuously and rapidly performs all normal operation, both in flight and when grounded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bsjZ4yviubib1gSZ.png" /></figure><p>The graphic above depicts the high-level architecture of the Centauri Flight Controller, split into its two “phases.” I’ll describe each step in detail in the sections below, alongside some code snippets!</p><p>If you’d like to follow along with the entire flight controller code as you read, you can find it <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py">here</a>!</p><p>Before we dive into the code, I want to mention that its style likely won’t match the traditional Python “best practices” you may have read about or seen online. I keep traditional abstraction layers like modules, classes, and functions to a minimum, and my use of math, slicing, and the like is decidedly “not normal.” There’s a reason for all of this: <strong>performance</strong>. I’ll elaborate at the end of this chapter, but wanted to give you a heads-up here.</p><p>And with that, let’s take a closer look at the flight controller code.</p><h3>Boot Sequence: LED On</h3><p>Upon booting, the <em>very</em> first thing the flight controller does is turn on the Raspberry Pi Pico’s onboard LED.</p><pre>import machine<br><br># First thing is first: set up onboard LED, turn it on while loading<br>print(&quot;Turning LED on...&quot;)<br>led = machine.Pin(&quot;LED&quot;, machine.Pin.OUT)<br>led.on()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*vhAgYaeLSoFpAxGy.png" /></figure><p>As shown in the image above, the Raspberry Pi Pico has a small onboard LED that can be controlled by code. I turn it on simply to confirm that power has successfully reached the Pico and the flight controller code is now running.</p><h3>Boot Sequence: Initialize Motor PWM Control</h3><p>The next step in the boot sequence is immediately initializing the pulse width modulation (PWM) signal for each of the four motors.</p><p>We prioritize doing this right away for two reasons:</p><ol><li><strong>ESC timeout</strong>: The ESCs were likely powered on the moment the Pico was. Some ESCs have a “timeout”: if they don’t receive a PWM signal within several seconds of booting, they switch back off.</li><li><strong>Safety</strong>: the propellers and motors are the only moving parts on the quadcopter, and an unexpected spin-up is a real safety concern. It’s best practice to immediately set the motors to 0% throttle when power is received, in case a “leftover” PWM signal lingered on the Pico from a prior boot.</li></ol><pre>gpio_motor1:int = 21 # front left, clockwise<br>gpio_motor2:int = 20 # front right, counter clockwise<br>gpio_motor3:int = 19 # rear left, counter clockwise<br>gpio_motor4:int = 18 # rear right, clockwise<br>target_hz:int = 250 # the number of times to run the PID loop<br>M1:machine.PWM = machine.PWM(machine.Pin(gpio_motor1), freq=target_hz, duty_ns=1000000)<br>M2:machine.PWM = machine.PWM(machine.Pin(gpio_motor2), freq=target_hz, duty_ns=1000000)<br>M3:machine.PWM = machine.PWM(machine.Pin(gpio_motor3), freq=target_hz, duty_ns=1000000)<br>M4:machine.PWM = machine.PWM(machine.Pin(gpio_motor4), freq=target_hz, duty_ns=1000000)</pre><p>I’ll elaborate on two things in the code snippet above:</p><p>freq: you&#39;ll notice the freq parameter is set to 250 on each motor PWM. This is the frequency of the PWM signal in hertz: how many complete on/off cycles occur per second. At 250 Hz, each cycle lasts exactly 4 ms. We use 250 Hz because our control loop (the &quot;PID loop&quot;) runs at 250 Hz, so we may update the throttle as often as 250 times per second.</p><p>duty_ns: you&#39;ll notice duty_ns is set to 1000000. This value is <strong>1,000,000</strong> nanoseconds, the <strong>width of the PWM signal</strong>. In the world of ESCs, a pulse width of 1,000,000 ns represents 0% throttle, while 2,000,000 ns represents 100% throttle. So by initializing each motor&#39;s pulse width at 1,000,000 nanoseconds, we start each at 0% throttle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kYeczMzWkzIHv91F.png" /></figure><p>The graphic above depicts this, showing the pulse width changing to represent different throttle levels. 0% throttle lasts 1 ms and 100% throttle lasts 2 ms, with linear scaling between the two.</p><h3>Boot Sequence: Wireless Transceiver Setup</h3><p>As discussed in the previous chapter, an HC-12 serves as the wireless transceiver that lets the quadcopter communicate bidirectionally with the pilot. Setting up and configuring the HC-12 early is a priority so the quadcopter can immediately send out an “I’m online” message, confirming it has booted successfully and is operational.</p><p>The HC-12 uses the <a href="https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter">UART protocol</a> to communicate with the Pico, so in MicroPython we can leverage the <a href="https://docs.micropython.org/en/latest/library/machine.UART.html">UART class</a> from the machine module to interface with it. The HC-12 also has a &quot;SET&quot; pin that lets the Pico switch between configuration and communication mode, which we set up as well.</p><pre>print(&quot;Setting up HC-12 via UART...&quot;)<br>hc12_set = machine.Pin(7, machine.Pin.OUT) # the SET pin, used for going into and out of AT mode<br>uart_hc12 = machine.UART(1, tx=machine.Pin(8), rx=machine.Pin(9), baudrate=9600)<br>uart_hc12.read(uart_hc12.any()) # clear out any RX buffer that may exist</pre><p>After initializing the UART object we need to communicate with the HC-12, we “pulse” it to confirm it’s hooked up and working. The HC-12 accepts a range of “AT Commands” when the SET pin is pulled low (configuration mode); one is simply sending AT, to which it responds OK to confirm it&#39;s on and operational.</p><pre># pulse HC-12<br>hc12_set.low() # pull it LOW to enter AT command mode<br>time.sleep(0.2) # wait a moment for AT mode to be entered<br>hc12_pulsed:bool = False<br>hc12_pulse_attempts:int = 0<br>hc12_pulse_rx_buffer:bytearray = bytearray()<br>while hc12_pulsed == False and hc12_pulse_attempts &lt; 3:<br>    print(&quot;Sending pulse attempt # &quot; + str(hc12_pulse_attempts + 1) + &quot;...&quot;)<br>    uart_hc12.write(&quot;AT\r\n&quot;.encode()) # send AT command<br>    hc12_pulse_attempts = hc12_pulse_attempts + 1<br>    time.sleep(0.2) # wait a moment for it to be responded to<br><br>    # if there is data<br>    if uart_hc12.any():<br>        hc12_pulse_rx_buffer.extend(uart_hc12.read(uart_hc12.any())) # append<br>        if &quot;OK\r\n&quot;.encode() in hc12_pulse_rx_buffer:<br>            hc12_pulsed = True<br>            print(&quot;Pulse received!&quot;)<br>            break<br>        else:<br>            print(&quot;Data received back from HC-12 but it wasn&#39;t an OK (pulse)&quot;)<br>    else:<br>        print(&quot;No data received from HC-12.&quot;)<br><br>    # wait<br>    time.sleep(1.0)<br><br># handle results of HC-12 pulse attempt<br>if hc12_pulsed:<br>    print(&quot;HC-12 pulsed! It is connected and working properly.&quot;)<br>else:<br>    print(&quot;HC-12 did not pulse back! Ensure it is connected, in baudrate 9600 mode, and working properly.&quot;)<br>    FATAL_ERROR()</pre><p>Communicating with the pilot via the HC-12 is a vital capability, so if establishing a connection with the module fails, the quadcopter enters a failure mode, flashing a code on the Pico’s onboard LED and refusing to continue.</p><p>Once we confirm the HC-12 is set up and operational, we make a few configurations. For the HC-12 on the quadcopter to communicate with the HC-12 on the pilot’s transmitter, the two must be configured identically.</p><p>We place the HC-12 into FU3 mode, its “general purpose” mode, which provides a good trade-off between range and speed:</p><pre># Configure HC-12 while still in AT mode: mode = FU3<br>print(&quot;Setting HC-12 mode to FU3...&quot;)<br>uart_hc12.write(&quot;AT+FU3\r\n&quot;.encode()) # go into mode FU3 (normal mode)<br>time.sleep(0.2) # wait a moment<br>response:bytes = uart_hc12.read(uart_hc12.any())<br>if &quot;OK+FU3\r\n&quot;.encode() in response:<br>    print(&quot;HC-12 in FU3 mode successful!&quot;)<br>else:<br>    print(&quot;HC-12 not confirmed to be in FU3 mode!&quot;)<br>    FATAL_ERROR()</pre><p>We then configure it to listen and broadcast on channel 2, one of 100 selectable channels:</p><pre># Configure HC-12 while still in AT mode: channel = 2<br>print(&quot;Setting HC-12 channel to 2...&quot;)<br>uart_hc12.write(&quot;AT+C002\r\n&quot;.encode())<br>time.sleep(0.2) # wait a moment<br>response:bytes = uart_hc12.read(uart_hc12.any())<br>if &quot;OK+C002\r\n&quot;.encode() in response:<br>    print(&quot;HC-12 set to channel 2!&quot;)<br>else:<br>    print(&quot;HC-12 not confirmed to be in channel 2.&quot;)<br>    FATAL_ERROR()</pre><p>And finally, we set its broadcasting power (when it sends data) to the maximum level of 8, which equates to 20 dBm:</p><pre># Configure HC-12 while still in AT mode: power<br>print(&quot;Setting HC-12 power to maximum level of 8...&quot;)<br>uart_hc12.write(&quot;AT+P8\r\n&quot;.encode())<br>time.sleep(0.2) # wait a moment<br>response:bytes = uart_hc12.read(uart_hc12.any())<br>if &quot;OK+P8\r\n&quot;.encode() in response:<br>    print(&quot;HC-12 power set to level 8 (20 dBM)&quot;)<br>else:<br>    print(&quot;Unsuccessful in setting HC-12 power level to 8.&quot;)<br>    FATAL_ERROR()</pre><p>After making those configurations, we return the “SET” pin to a high state, bringing the HC-12 back to its normal operating mode (out of configuration mode):</p><pre># now that the HC-12 is set up and configured, close out of AT mode by setting the SET pin back to HIGH<br>print(&quot;Returning HC-12 SET pin to HIGH (exiting AT mode)...&quot;)<br>hc12_set.high()<br>time.sleep(0.5) # wait a moment for the HC-12 to successfully get out of AT mode before proceeding with sending any messages</pre><p>You’ll notice that just after HC-12 setup completes, the first thing it does is send out a “HC12 OK” message, so the pilot can see the quadcopter is powered on and capable of communicating through a working HC-12 unit. This is the <strong>special packet</strong> discussed in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">Full-Stack Flight, Chapter 2: Defining a Communication Protocol</a>, which can carry a plain-text, unstructured message.</p><pre># define special message packet function for sending special packets<br>print(&quot;Defining special message function...&quot;)<br>def send_special(msg:str) -&gt; None:<br>    ToSend:bytearray = bytearray()<br>    ToSend.append(0b00000001) # append header byte with bit 0 = 1 to identify it as a special packet<br>    if len(msg) &gt; 50:<br>        msg = msg[0:50] # limit to 50 chars<br>    ToSend.extend(msg.encode())<br>    ToSend.extend(&quot;\r\n&quot;.encode()) # terminator<br>    uart_hc12.write(ToSend)<br><br># send online notification<br>print(&quot;Sending &#39;HC12 OK&#39; message...&quot;)<br>send_special(&quot;HC12 OK&quot;)</pre><p><em>Note: I previously put together a helper class for working with the HC-12, which you can find </em><a href="https://github.com/TimHanewich/MicroPython-Collection/tree/master/HC-12"><em>here</em></a><em>. I’m not using it in the Centauri Flight Controller, for performance reasons. If you’d like to learn more about how the HC-12 works, I suggest reading through it and possibly the </em><a href="https://www.elecrow.com/download/HC-12.pdf"><em>HC-12 manual</em></a><em>.</em></p><h3>Boot Sequence: IMU Setup &amp; Calibration</h3><p>With wireless communication now set up, we move on to the onboard Inertial Measurement Unit (IMU). As mentioned in the previous chapter, Centauri uses the common and affordable <a href="https://amzn.to/4yh76Ev">MPU-6050</a> as its IMU. As you’ll see later, the IMU is another vital part of the quadcopter’s avionics; without it, flight would never happen!</p><p>The MPU-6050 uses the <a href="https://en.wikipedia.org/wiki/I2C">I2C protocol</a>, which MicroPython supports via the <a href="https://docs.micropython.org/en/latest/library/machine.I2C.html">I2C class</a> of the machine module.</p><p>We initialize the I2C interface and then perform a scan to check available devices on the bus:</p><pre># Confirm MPU-6050 is connected via I2C<br>print(&quot;Setting up I2C...&quot;)<br>i2c = machine.I2C(0, sda=machine.Pin(16), scl=machine.Pin(17))<br>if 0x68 not in i2c.scan():<br>    print(&quot;MPU-6050 not connected via I2C!&quot;)<br>    FATAL_ERROR(&quot;MPU-6050 not connected!&quot;)<br>else:<br>    print(&quot;MPU-6050 confirmed to be connected via I2C.&quot;)</pre><p>Now that we’ve confirmed it <em>is</em> showing up, we run a quick check of its “whoami” register, which should always respond with the same value, 0x68, confirming it&#39;s present and operating:</p><pre># Confirm MPU-6050 is on and operational by reading the &quot;whoami&quot; register<br>print(&quot;Reading MPU-6050 WHOAMI register...&quot;)<br>whoami:int = i2c.readfrom_mem(0x68, 0x75, 1)[0]<br>if whoami == 0x68:<br>    print(&quot;MPU-6050 WHOAMI passed!&quot;)<br>    send_special(&quot;IMU OK&quot;)<br>else:<br>    print(&quot;MPU-6050 WHOAMI Failed!&quot;)<br>    FATAL_ERROR(&quot;MPU6050 WHOAMI Fail&quot;)</pre><p>Next, we write a few values to various registers on the MPU-6050 to wake it up and configure it. I won’t go into detail here to save space (this alone could fill a full chapter), but I’m sure you could feed this snippet to your favorite AI agent and get a very verbose explanation. 😊</p><pre># Set up MPU-6050<br>print(&quot;Waking up MPU-6050...&quot;)<br>i2c.writeto_mem(0x68, 0x6B, bytes([0])) # wake up <br>print(&quot;Setting MPU-6050 gyro scale range to 1,000 d/s...&quot;)<br>i2c.writeto_mem(0x68, 0x1B, bytes([0x10])) # set full scale range of gyro to 1,000 degrees per second<br>print(&quot;Setting MPU-6050 accelerometer scale range to 8g...&quot;)<br>i2c.writeto_mem(0x68, 0x1C, bytes([0x10])) # set full scale range of accelerometer to 8g<br>print(&quot;Setting MPU-6050 LPF to 10 Hz...&quot;)<br>i2c.writeto_mem(0x68, 0x1A, bytes([0x05])) # set low pass filter for both gyro and accel to 10 hz (level 5 out of 6 in smoothing)</pre><p>After that, we “read back” those registers to <strong>confirm</strong> the configuration updates took effect (not shown here).</p><p>With communication established and the MPU-6050 configured correctly, we’re ready to calibrate it. No IMU is perfect; every one has some error or “drift.” When the MPU-6050 sits absolutely still, it still returns minor values across its gyroscope and accelerometer readouts that aren’t actually true; they’re the result of small imperfections. Later, in the control loop, we’ll want readings as accurate as possible. To achieve that, we observe these values for a few seconds now so we know what to <em>subtract</em> from the raw readings later.</p><p>The following snippet collects hundreds of readings across a three-second span:</p><pre># Perform IMU (Gyro &amp; Accel) Calibration<br>gfs:int = 0          # g-force samples (sum)<br>gxs:int = 0          # gyro x samples (sum)<br>gys:int = 0          # gyro y samples (sum)<br>gzs:int = 0          # gyro z samples (sum)<br>samples:int = 0      # to count the number of samples we collect<br>for i in range(3):<br>    print(&quot;Beginning IMU calibration in &quot; + str(3 - i) + &quot;... &quot;)<br>    time.sleep(1.0)<br>send_special(&quot;IMU Cal...&quot;)<br>print(&quot;Calibrating IMU...&quot;)<br>started_at_ticks_ms:int = time.ticks_ms()<br>while time.ticks_diff(time.ticks_ms(), started_at_ticks_ms) &lt; 3000: # 3 seconds<br>    <br>    # Read<br>    gyro_data:bytes = i2c.readfrom_mem(0x68, 0x43, 6)    # read 6 gyro bytes, 2 for each axis<br>    accel_data:bytes = i2c.readfrom_mem(0x68, 0x3B, 6)   # read 6 accelerometer bytes, 2 for each axis<br><br>    # Transform gyro data<br>    gyro_x = (gyro_data[0] &lt;&lt; 8) | gyro_data[1]<br>    gyro_y = (gyro_data[2] &lt;&lt; 8) | gyro_data[3]<br>    gyro_z = (gyro_data[4] &lt;&lt; 8) | gyro_data[5]<br>    if gyro_x &gt;= 32768: gyro_x = ((65535 - gyro_x) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    if gyro_y &gt;= 32768: gyro_y = ((65535 - gyro_y) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    if gyro_z &gt;= 32768: gyro_z = ((65535 - gyro_z) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    gyro_x = gyro_x * 10000 // 328      # now, divide by the scale factor to get the actual degrees per second. Multiply by 10,000 to both offset the divisor being 328 (not 32.8 as specified for this gyro scale) AND ensure the output is 1000x more so we can do integer math<br>    gyro_y = gyro_y * 10000 // 328      # now, divide by the scale factor to get the actual degrees per second. Multiply by 10,000 to both offset the divisor being 328 (not 32.8 as specified for this gyro scale) AND ensure the output is 1000x more so we can do integer math<br>    gyro_z = gyro_z * 10000 // 328      # now, divide by the scale factor to get the actual degrees per second. Multiply by 10,000 to both offset the divisor being 328 (not 32.8 as specified for this gyro scale) AND ensure the output is 1000x more so we can do integer math<br><br>    # Transform accel data<br>    accel_x = (accel_data[0] &lt;&lt; 8) | accel_data[1]<br>    accel_y = (accel_data[2] &lt;&lt; 8) | accel_data[3]<br>    accel_z = (accel_data[4] &lt;&lt; 8) | accel_data[5]<br>    if accel_x &gt;= 32768: accel_x = ((65535 - accel_x) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    if accel_y &gt;= 32768: accel_y = ((65535 - accel_y) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    if accel_z &gt;= 32768: accel_z = ((65535 - accel_z) + 1) * -1 # convert unsigned ints to signed ints (so there can be negatives)<br>    accel_x = (accel_x * 1000) // 4096 # divide by scale factor for 8g range to get value. But before doing so, multiply by 1,000 because we will work with larger number to do integer math (faster) instead of floating point math (slow and memory leak)<br>    accel_y = (accel_y * 1000) // 4096 # divide by scale factor for 8g range to get value. But before doing so, multiply by 1,000 because we will work with larger number to do integer math (faster) instead of floating point math (slow and memory leak)<br>    accel_z = (accel_z * 1000) // 4096 # divide by scale factor for 8g range to get value. But before doing so, multiply by 1,000 because we will work with larger number to do integer math (faster) instead of floating point math (slow and memory leak)<br><br>    # use accel data to calculate current G-Force<br>    gforce:int = tools.isqrt(accel_x*accel_x + accel_y*accel_y + accel_z*accel_z)         # 1,000 would be 1g<br><br>    # increment<br>    gxs = gxs + gyro_x<br>    gys = gys + gyro_y<br>    gzs = gzs + gyro_z<br>    gfs = gfs + gforce<br>    samples = samples + 1<br><br>    # wait<br>    time.sleep(0.01)</pre><p>With those readings collected, we can calculate the inherent biases on each of the gyroscope’s axes:</p><pre># calculate biases<br>print(str(samples) + &quot; IMU samples collected.&quot;)<br>gyro_bias_x:int = gxs // samples<br>gyro_bias_y:int = gys // samples<br>gyro_bias_z:int = gzs // samples<br>gforce_bias:int = (gfs // samples) - 1000     # the &quot;bias&quot; can be described as the difference between 1 full g and the avg reading. So if, being totally still, the IMU is reading 0.9g, we know it is off by 0.1g, because it should be 1.0g standing still!<br>print(&quot;Gyro Bias: &quot; + str(gyro_bias_x) + &quot;, &quot; + str(gyro_bias_y) + &quot;, &quot; + str(gyro_bias_z))<br>print(&quot;GForce Bias: &quot; + str(gforce_bias))<br>send_special(&quot;IMU Calib OK&quot;)</pre><p>We’ll later use these to get a better estimate of the <em>actual</em> changes in angular velocity by subtracting this error from the readings!</p><p><em>Note: for this to work, the quadcopter must rest absolutely still during this three-second period. As soon as you power it on, step away and don’t touch it for the first ~10 seconds to ensure an accurate calibration reading!</em></p><h3>Boot Sequence: Other Things</h3><p>I won’t detail the other things that happen during the boot sequence, since I only wanted to cover the “big ones” above. The rest is primarily setting up variables and bytearray objects that get reused later in the control loop (to save memory), along with some precomputed calculations, timestamp flags, and the like. You&#39;re welcome to look through it in the <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py">source code</a> yourself!</p><p>Now, with the <em>Centauri</em> flight controller booted up, set up, and ready, it transitions to the <strong>control loop</strong>, and <em>that</em> is where flight happens!</p><h3>Control Loop: Mark Loop Start Time</h3><p>The first thing that happens within the control loop is marking the current time:</p><pre># mark loop start time<br>loop_begin_us:int = time.ticks_us() # ticks, in microseconds (us)</pre><p>The reason is to maintain a <strong>fixed</strong> and <strong>consistent</strong> 250 Hz control loop. As you’ll see at the end of the loop, if there’s excess time (i.e. it finished before the 4 ms needed for 250 Hz), it waits out the remainder before proceeding, ensuring consistent timing.</p><h3>Control Loop: Receive Control Input</h3><p>Next, it receives new control input via the HC-12. This involves checking whether any newly received data is available to read on the UART interface, and if so, reading and processing it.</p><pre>bytesavailable:int = uart_hc12.any()<br>if bytesavailable &gt; 0:<br>    # read into the rxBuffer (just a place to read them into)<br>    bytesread:int = uart_hc12.readinto(rxBuffer, bytesavailable)<br><br>    # Do we have room to move all of the newly received bytes into the process buffer?<br>    # if the available space remaining is NOT ENOUGH to fit ALL of the newly received data... dump it!<br>    if (len(ProcessBuffer) - ProcessBufferOccupied) &lt; bytesread: <br>        ProcessBufferOccupied = 0 # set the count for how much space is occupied to 0 so it just begins rewriting from the beginning.<br><br>    # copy the bytes we just received in the rxBuffer into the ProcessBuffer, byte by byte (one by one)<br>    for i in range(0, bytesread):<br>        ProcessBuffer[ProcessBufferOccupied + i] = rxBuffer[i]<br><br>    # increment how much of the ProcessBuffer is now occupied<br>    ProcessBufferOccupied = ProcessBufferOccupied + bytesread<br><br># Step 2: Do we have a complete line to work with (a &quot;\r\n&quot; terminator is there)<br>while True: # continuously search until there are no more left<br>    TerminatorLoc:int = ProcessBuffer.find(terminator, 0, ProcessBufferOccupied)<br>    if TerminatorLoc == -1: # if a terminator (\r\n) was not found...<br>        break # break out of the while loop<br>    else:<br><br>        # Process the line <br>        if ProcessBuffer.startswith(TIMHPING): # PING: simple check of life.<br>            uart_hc12.write(TIMHPONG) # PONG back<br>        elif ProcessBuffer[0] &amp; 0b00000001 == 0: # if bit 0 is 0, it is a control packet<br>            unpack_successful:bool = tools.unpack_control_packet(ProcessBuffer, control_input)<br>            if unpack_successful:<br>                input_throttle_uint16 = control_input[0]<br>                input_pitch_int16 = control_input[1]<br>                input_roll_int16 = control_input[2]<br>                input_yaw_int16 = control_input[3]<br>                control_input_last_received_ticks_ms = time.ticks_ms() # mark that we just now got control input<br>        elif ProcessBuffer[0] &amp; 0b00000001 != 0: # if bit 0 is 1, it is a settings update<br>            settings:dict = tools.unpack_settings_update(ProcessBuffer)<br>            if settings != None:<br>                pitch_kp = settings[&quot;pitch_kp&quot;]<br>                pitch_ki = settings[&quot;pitch_ki&quot;]<br>                pitch_kd = settings[&quot;pitch_kd&quot;]<br>                roll_kp = settings[&quot;roll_kp&quot;]<br>                roll_ki = settings[&quot;roll_ki&quot;]<br>                roll_kd = settings[&quot;roll_kd&quot;]<br>                yaw_kp = settings[&quot;yaw_kp&quot;]<br>                yaw_ki = settings[&quot;yaw_ki&quot;]<br>                yaw_kd = settings[&quot;yaw_kd&quot;]<br>                i_limit = settings[&quot;i_limit&quot;]<br>                send_special(&quot;SETUPOK&quot;) # send special packet &quot;SETUPOK&quot;, short for &quot;Settings Update OK&quot;.<br>            else:<br>                print(&quot;It was settings but it failed.&quot;)<br>        else: # unknown packet<br>            print(&quot;Unknown data received via HC-12&quot;)<br>            send_special(&quot;?&quot;) # respond with a simple question mark<br><br>        # Move the conveyer belt back so the new unprocessed data is right at the beginning<br>        NewDataStarts:int = TerminatorLoc + 2<br>        NumberOfBytesToMove:int = ProcessBufferOccupied - NewDataStarts<br>        ProcessBufferMV[0:NumberOfBytesToMove] = ProcessBufferMV[NewDataStarts:NewDataStarts + NumberOfBytesToMove]<br>        ProcessBufferOccupied = ProcessBufferOccupied - NewDataStarts</pre><p>If you’re at all familiar with reading incoming binary data from UART, you might think to yourself, <em>“can’t all of this be done in one line?”</em></p><p>And you wouldn’t be entirely wrong! MicroPython’s UART class has a read() function that hands you whatever data is available on the line. So why not just use that and skip all this reading <em>into</em> a buffer, the memoryview slicing, and so on?</p><p>The answer is <strong>performance</strong>. Every call to UART.read() allocates a <em>new</em> bytes object. That additional memory allocation will eventually, within a few loops, push memory to a critical mass and trigger MicroPython&#39;s <a href="https://docs.micropython.org/en/latest/library/gc.html">garbage collector</a> to clear the heap, and that takes <em>time</em>! <em>Precious</em> time! In a normal Python project, a 200 ms pause for garbage collection goes unnoticed. But here, we <em>must</em> maintain a fixed 250 Hz control loop, so the entire process has to complete within 4 ms. Our time budget is tiny and we can&#39;t afford garbage collection, so we must avoid allocating new memory each loop.</p><p>In the code above, you’ll see the handling of the three types of packets the quadcopter may receive from the pilot’s transmitter (revisit <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319">chapter 2</a> for a deeper look):</p><ul><li><strong>PING</strong>: a simple “ping” message: the pilot’s transmitter asking “are you there?”, encoded as TIMHPING in ASCII. The quadcopter responds TIMHPONG to confirm &quot;yes, I&#39;m here.&quot;</li><li><strong>Control Packet</strong>: the transmitter sending updated control input: new throttle, pitch, roll, and yaw values. The packet is unpacked and the input variables are updated (more on this later).</li><li><strong>Settings Packet</strong>: the transmitter sending updated flight settings (PID gains). The packet is unpacked and the onboard PID gains are updated.</li></ul><h3>Control Loop: Read IMU</h3><p>With any new control input from the pilot received and recorded, we move on to a crucial part: observing the quadcopter’s physical change in orientation by reading the IMU.</p><p>We do this by using I2C to read from specific registers on the MPU-6050:</p><pre>i2c.readfrom_mem_into(0x68, 0x43, gyro_data) # read 6 bytes, 2 for each axis for gyro data<br>i2c.readfrom_mem_into(0x68, 0x3B, accel_data) # read 6 bytes, 2 for each axis for accel data</pre><p>We just captured a total of <strong>12 bytes</strong> of data from the MPU-6050:</p><ul><li>6 bytes from the Gyroscope (2 for X axis, 2 for Y axis, 2 for Z axis)</li><li>6 bytes from the Accelerometer (2 for X axis, 2 for Y axis, 2 for Z axis)</li></ul><p>We now perform a minor transformation on those bytes to reconcile them into the actual measurement readings we need:</p><pre># Process &amp; Transform raw Gyroscope data<br>gyro_x = (gyro_data[0] &lt;&lt; 8) | gyro_data[1]<br>gyro_y = (gyro_data[2] &lt;&lt; 8) | gyro_data[3]<br>gyro_z = (gyro_data[4] &lt;&lt; 8) | gyro_data[5]<br>if gyro_x &gt;= 32768: gyro_x = ((65535 - gyro_x) + 1) * -1<br>if gyro_y &gt;= 32768: gyro_y = ((65535 - gyro_y) + 1) * -1<br>if gyro_z &gt;= 32768: gyro_z = ((65535 - gyro_z) + 1) * -1<br>roll_rate = gyro_x * 10000 // 328<br>pitch_rate = gyro_y * 10000 // 328<br>yaw_rate = gyro_z * 10000 // 328</pre><p>I know that looks complicated! For the sake of brevity, I won’t dive too deep, but here are a few notes on what’s happening:</p><ol><li>The two bytes per axis are combined via bitwise operations into a <em>single</em> larger number.</li><li>That number, ranging from 0 to 65,535 (an <em>unsigned</em> uint16), is converted to range from -32,768 to 32,767 (a <em>signed</em> int16).</li><li>That raw value is converted to degrees per second by dividing by 328.</li></ol><p>If you want to understand how we arrived at the 328 value in #3, see the comments for this section in the actual <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py">flight controller code</a>.</p><p>And now we have the actual degrees-per-second reading from the IMU’s gyroscope! One last step: subtract out the bias we calculated earlier during the IMU calibration phase (during the boot sequence):</p><pre>pitch_rate = pitch_rate - gyro_bias_y<br>roll_rate = roll_rate - gyro_bias_x<br>yaw_rate = yaw_rate - gyro_bias_z</pre><h3>Control Loop: PID Calculations</h3><p>Now for the PID calculation, which determines exactly what each of the four motor throttles should be.</p><p>In the PID loop, we compare the pilot’s <strong>desired rate of orientation change</strong> with the <strong>actual rate of orientation change</strong>. There will be a difference, and the PID calculation determines how to correct it by varying thrust across the four motors.</p><p>In a previous step we collected the control input from the pilot; we now convert it into a desired pitch, roll, and yaw rate:</p><pre># convert the desired pitch, roll, and yaw from (-32,768 to 32,767) into (-90 to +90) degrees per second<br># Multiply by 90,000 because we will interpret each as -90 d/s to +90 d/s<br># We are multplying by 90,000 instead of 90 here so we can keep it in units of 1,000 and do integer math instead of floating point math<br>desired_pitch_rate:int = (input_pitch_int16 * 90000) // 32767<br>desired_roll_rate:int = (input_roll_int16 * 90000) // 32767<br>desired_yaw_rate:int = (input_yaw_int16 * 90000) // 32767</pre><p>We then use these values to calculate the <strong>error</strong> on each axis (the difference between goal and actual):</p><pre># error = desired - actual<br>error_pitch_rate:int = desired_pitch_rate - pitch_rate<br>error_roll_rate:int = desired_roll_rate - roll_rate<br>error_yaw_rate:int = desired_yaw_rate - yaw_rate</pre><p>Now, with the error values for all three axes, we can perform the PID calculation. I won’t do a deep dive into how PID controllers work, but in essence there are three “forces” that each contribute to how much effort is applied to close a gap: the <strong>proportional</strong>, <strong>integral</strong>, and <strong>derivative</strong> forces. Each can be tuned independently, with the <em>combination</em> of all three applied together to close the gap. The PID calculation for the pitch axis is shown below:</p><pre># Pitch PID calculation<br>pitch_p:int = (error_pitch_rate * pitch_kp) // PID_SCALING_FACTOR<br>pitch_i:int = pitch_last_i + ((error_pitch_rate * pitch_ki) // PID_SCALING_FACTOR)<br>if pitch_i &lt; -i_limit: # constrain within I limit. I originally was using min(max()) here but that takes 210 us. Way too slow. Doing it this way uses only 40 us.<br>    pitch_i = -i_limit<br>elif pitch_i &gt; i_limit:<br>    pitch_i = i_limit<br>pitch_d = (pitch_kd * (error_pitch_rate - pitch_last_error)) // PID_SCALING_FACTOR<br>pitch_pid = pitch_p + pitch_i + pitch_d</pre><p>Now we have pitch_p, pitch_i, and pitch_d, which we combine at the end into pitch_pid, all three terms together. pitch_pid is important because we use it to calculate each motor&#39;s throttle level to resolve the &quot;errors.&quot; I&#39;m not showing the calculations for roll and yaw, but they work exactly the same way.</p><p>Finally, to calculate the pulse width of each of the four motor signals, we put everything together:</p><pre># Calculate the mean pulse width the PWM signals will use<br>mean_pwm_pw:int = 1_000_000 + ((input_throttle_uint16 * 10_000) // 65535) * 100<br><br># calculate throttle values for each motor using those PID influences<br>m1_pwm_pw = mean_pwm_pw + pitch_pid + roll_pid - yaw_pid<br>m2_pwm_pw = mean_pwm_pw + pitch_pid - roll_pid + yaw_pid<br>m3_pwm_pw = mean_pwm_pw - pitch_pid + roll_pid + yaw_pid<br>m4_pwm_pw = mean_pwm_pw - pitch_pid - roll_pid - yaw_pid</pre><p>Above, we first calculate the “mean” pulse width from the throttle input (think of it as a percentage of the range between 1,000,000 ns and 2,000,000 ns). We then apply the combined PID influences for each of the three axes in a pattern reflecting each motor’s position and thrust orientation on the airframe.</p><h3>Control Loop: Update Throttle Signal</h3><p>Now we have the pulse width for each of the four motors, representing its throttle level, ready to send to the ESCs!</p><p>But before sending these directly to the ESCs, we put a few safety filters in place.</p><p>First, we constrain the pulse widths to between 1,000,000 ns and 2,000,000 ns (the min/max values the ESCs recognize), in case the math pushed them below or above that range:</p><pre># takes ~60 us<br># you may think why not just use the min/max functions here - I originally was! But those are very slow, taking ~440 us to min/max all four. Saving a lot of time doing it manually like this.<br>if m1_pwm_pw &lt; 1000000:<br>    m1_pwm_pw = 1000000<br>elif m1_pwm_pw &gt; 2000000:<br>    m1_pwm_pw = 2000000<br>if m2_pwm_pw &lt; 1000000:<br>    m2_pwm_pw = 1000000<br>elif m2_pwm_pw &gt; 2000000:<br>    m2_pwm_pw = 2000000<br>if m3_pwm_pw &lt; 1000000:<br>    m3_pwm_pw = 1000000<br>elif m3_pwm_pw &gt; 2000000:<br>    m3_pwm_pw = 2000000<br>if m4_pwm_pw &lt; 1000000:<br>    m4_pwm_pw = 1000000<br>elif m4_pwm_pw &gt; 2000000:<br>    m4_pwm_pw = 2000000</pre><p>Second, we check for “red flag” scenarios that, for safety reasons, immediately shut the motors down entirely, even if the PID calculation says otherwise:</p><pre># MOTOR SHUTDOWN CONDITIONS (safety)<br>if input_throttle_uint16 == 0 or time.ticks_diff(time.ticks_ms(), control_input_last_received_ticks_ms) &gt; 2000:<br>    <br>    # shut off all motors<br>    # 1,000,000 nanoseconds = 1 ms, the minumum throttle for an ESC (0% throttle, so no rotation)<br>    m1_pwm_pw = 1000000<br>    m2_pwm_pw = 1000000<br>    m3_pwm_pw = 1000000<br>    m4_pwm_pw = 1000000<br><br>    # reset cumulative PID values (I and D related)<br>    pitch_last_i = 0<br>    roll_last_i = 0<br>    yaw_last_i = 0<br>    pitch_last_error = 0<br>    roll_last_error = 0<br>    yaw_last_error = 0</pre><p>The code above detects two “red flag” situations and shuts off the motors if either occurs:</p><ol><li><strong>Pilot’s throttle is at 0%</strong>: this may seem obvious: <em>if the pilot’s input is 0%, how could the motor throttles be anything but 0%?</em> Keep in mind the PID loop is always running. Even if the pilot isn’t touching the controls, the flight controller is actively trying to maintain orientation, so if you pick the quadcopter up and move it, the motors may spin up to compensate. This check prevents that.</li><li><strong>2+ seconds since control input was last received</strong>: while flying, the quadcopter risks wandering out of range of the pilot’s transmitter. Unable to receive new inputs to reduce throttle or shut down, the flight controller would keep acting on the pilot’s most recent input, leading to an out-of-control quadcopter, which is VERY dangerous. To mitigate this, the logic above shuts the motors down entirely if no new control input has been received for 2 seconds or more.</li></ol><p>After passing through those two “red flag” filters and making any necessary adjustments, we’re ready to update the throttle signal for each of the four ESCs!</p><pre># adjust throttles on PWMs<br>M1.duty_ns(m1_pwm_pw)<br>M2.duty_ns(m2_pwm_pw)<br>M3.duty_ns(m3_pwm_pw)<br>M4.duty_ns(m4_pwm_pw)</pre><h3>Control Loop: Record &amp; Stream Telemetry</h3><p>After adjusting the motor thrusts by updating the pulse width fed to each ESC, the control loop checks whether it’s time to record <em>or</em> stream telemetry.</p><p>The first thing this section does is check whether it’s time to record again. It does so by checking whether the time elapsed since telemetry was <em>last</em> recorded now exceeds the interval between recordings:</p><pre>if time.ticks_diff(time.ticks_ms(), telemetry_last_recorded_ticks_ms) &gt;= record_telemetry_every_ms: # proceed to store a snapshot if it is time</pre><p>If it’s time to record new telemetry, it packs all the values to be recorded: current battery voltage, the pitch/roll/yaw rates, current G-force level, current control input, and more:</p><pre># first, get a ADC reading<br>vbat_u16:int = vbat_adc.read_u16() # read the value on the ADC pin, as a uint16 (0-65535)<br><br># Using the ADC reading, estimate the actual supply voltage<br>vbat:int = ((-248_065 + (vbat_u16 * 297)) + 50_000) // 100_000 # results in a value between 60 and 168 (6.0 and 16.8 volts respectively)<br><br># Prepare input values to packet as expected: rates<br>packable_pitch_rate:int = pitch_rate // 1000<br>packable_roll_rate:int = roll_rate // 1000<br>packable_yaw_rate:int = yaw_rate // 1000<br><br># Prepare input values to packet as expected: angles<br>packable_pitch_angle:int = pitch_angle<br>packable_roll_angle:int = roll_angle<br><br># Prepare input values to packet as expected: gforce<br>packable_gforce:int = (gforce + 50) // 100<br><br># prepare input values as expected: input values<br>packable_input_throttle:int = (input_throttle_uint16 * 100) // 65535<br>packable_input_pitch:int = ((((input_pitch_int16 + 32768) * 100) // 65535) * 2) - 100<br>packable_input_roll:int = ((((input_roll_int16 + 32768) * 100) // 65535) * 2) - 100<br>packable_input_yaw:int = ((((input_yaw_int16 + 32768) * 100) // 65535) * 2) - 100<br><br># Prepare input values as expected: motor throttles<br>packable_m1_throttle:int = (m1_pwm_pw - 1000000) // 10000<br>packable_m2_throttle:int = (m2_pwm_pw - 1000000) // 10000<br>packable_m3_throttle:int = (m3_pwm_pw - 1000000) // 10000<br>packable_m4_throttle:int = (m4_pwm_pw - 1000000) // 10000<br><br># prepare packet last received ago<br>lrecv_ago_ms:int = time.ticks_diff(time.ticks_ms(), control_input_last_received_ticks_ms)</pre><p>I won’t describe the snippet above line by line, but if you’re interested, I highly encourage you to visit this section (lines 693–737) in the <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py">source code</a>, where I left verbose comments explaining each line!</p><p>After collecting all the values, it then packs them using the pack_telemetry function of the tools module:</p><pre>tools.pack_telemetry(time.ticks_ms(), vbat, packable_pitch_rate, packable_roll_rate, packable_yaw_rate, packable_pitch_angle, packable_roll_angle, packable_gforce, packable_input_throttle, packable_input_pitch, packable_input_roll, packable_input_yaw, packable_m1_throttle, packable_m2_throttle, packable_m3_throttle, packable_m4_throttle, lrecv_ago_ms, telemetry_packet_store)</pre><p>The line above packs the telemetry into the pre-defined telemetry_packet_store bytearray (intentionally not allocating new memory for a new object).</p><p>We now have a bytearray containing an encoded snapshot of telemetry; great! To <em>record</em> it, we do <em>not</em> immediately write to the Raspberry Pi Pico&#39;s flash storage; that would take too long given the tight timing of a flight controller. Instead, we write it to a temporary memory buffer that collects a series of these while in flight (much faster), and <em>later</em>, when <em>not</em> flying, the actual &quot;flush&quot; to flash storage happens.</p><pre># Record it by adding it to the temporary memory buffer we have going while in flight<br>if (temp_telemetry_storage_len - temp_telemetry_storage_used) &gt; len(telemetry_packet_store): # if we have enough room for another telemetry packet store.<br>    for i in range(len(telemetry_packet_store)): # manually copy telemetry packet via loop. <br>        temp_telemetry_storage[temp_telemetry_storage_used + i] = telemetry_packet_store[i]<br>    temp_telemetry_storage_used = temp_telemetry_storage_used + len(telemetry_packet_store) # increment how many bytes are now used.</pre><p>The snippet above checks whether there’s enough room in the buffer to copy this snapshot in. If so, it copies it over byte by byte. We’re <strong>not</strong> using slicing here, as that allocates new memory and takes too long; believe it or not, I’ve found the byte-by-byte copy via the for loop is faster and more efficient.</p><p>Now we’ve “recorded” (saved to a temporary buffer) telemetry that will eventually reach the Pico’s onboard flash storage. But as described in previous chapters, I also wanted the <em>Centauri</em> quadcopter to <strong>transmit</strong> telemetry back to the pilot while operating, keeping them updated on its status. After recording with the snippets above, we <em>transmit</em> using the snippet below:</p><pre># if we also have the opportunity to send telemetry right now, send it<br># We only send under 2 conditions:<br># 1. We are unarmed (throttle = 0)<br># 2. It is due time!<br>if input_throttle_uint16 == 0: # if we are unarmed (throttle is 0%), we will consider streaming some telemetry periodically to the controller. It is important to only send data via HC-12 while unarmed because the HC-12 is half duplex, meaning it can&#39;t send and receive at the same time. Full focus should be put into receiving input commands while armed.<br>    if time.ticks_diff(time.ticks_ms(), status_last_sent_ticks_ms) &gt;= 1000: # send via HC-12 to controller every 1000 ms (1 time per second)<br>        <br>        # construct stream packet<br>        # we just packed all the data into the record buffer<br>        # so pull out the telemetry we will send from there directly<br>        telemetry_packet_stream[0] = 0b00000000                     # header byte. Bit 0 = 0 means it is a status packet.<br>        telemetry_packet_stream[1] = telemetry_packet_store[3]      # vbat<br>        telemetry_packet_stream[2] = telemetry_packet_store[4]      # pitch rate<br>        telemetry_packet_stream[3] = telemetry_packet_store[5]      # roll rate<br>        telemetry_packet_stream[4] = telemetry_packet_store[6]      # yaw rate<br>        telemetry_packet_stream[5] = telemetry_packet_store[7]      # pitch angle<br>        telemetry_packet_stream[6] = telemetry_packet_store[8]      # roll angle<br>        telemetry_packet_stream[7] = 13                             # \r<br>        telemetry_packet_stream[8] = 10                             # \n<br><br>        # send<br>        uart_hc12.write(telemetry_packet_stream) # no need to append \r\n to it because the bytearray packet already has it at the end!<br>        status_last_sent_ticks_ms = time.ticks_ms() # update last sent time</pre><p>You’ll see above that telemetry is <em>only</em> transmitted via the HC-12 when throttle is at 0% (we are NOT flying, NOT armed). I do this because the HC-12 is a <strong>half-duplex</strong> transceiver, not a <strong>full-duplex</strong> one, meaning it can only send or receive at any given moment, never both at once. If the pilot’s transmitter broadcasts an important message while the drone is transmitting its own, the pilot’s message will <strong>not</strong> be received. That’s detrimental during flight, where low latency is critical; missing an updated control packet, even for a fraction of a second, could cause a crash.</p><p>Once throttle is confirmed at 0% and status telemetry hasn’t been broadcast for at least 1 full second, the stream packet is “constructed” by copying over the leading bytes from the full-sized telemetry packet we recorded earlier: just the critical data the pilot cares about, such as battery. Again, slicing would be simpler here, but it allocates a new object, which costs memory and drags down performance. After copying, it sends the data by writing to the HC-12’s UART interface!</p><p>Finally, the temporarily recorded telemetry data (in the large buffer) is “flushed” (saved) to local file storage:</p><pre>if input_throttle_uint16 == 0: # if we are unarmed<br>    if temp_telemetry_storage_used &gt; 0: # if we have some telemetry to write<br><br>        # flush to flash storage<br>        # takes ~40,000 us, uses ~2,496 bytes of new memory<br>        log = open(&quot;log&quot;, &quot;ab&quot;)<br>        for i in range(temp_telemetry_storage_used):<br>            if free_bytes &gt; 0: # if we have free bytes in capacity<br>                log.write(bytes([temp_telemetry_storage[i]]))<br>                free_bytes = free_bytes - 1 # decrement the number of bytes that are now free<br>        log.close()<br><br>        # clear out the temporary storage bytearray<br>        # takes ~259,000 us, uses 0 bytes of new memory<br>        for i in range(temp_telemetry_storage_len):<br>            temp_telemetry_storage[i] = 0<br>        temp_telemetry_storage_used = 0 # reset used counter</pre><p>It checks two conditions: throttle is at 0% (we’re not flying, so timing isn’t critical right now) and there is data to flush. If both pass, it flushes to local storage.</p><p>You’ll notice in the comments above that this is a very time-consuming process: at roughly 300 ms, it most certainly breaks the timing of the control loop. But that’s acceptable here because <strong>this does NOT happen during active flight</strong>. It only runs when throttle is at 0%, meaning a timing-tight control loop (PID loop) isn’t necessary.</p><h3>Control Loop: Wait Excess Time</h3><p>The final task in the control loop is to <strong>wait</strong>… to do nothing! As described above, the <em>Centauri</em> control loop runs at 250 Hz, or 250 times per second. That means each loop must execute consistently every <strong>4 ms</strong>, no more, no less.</p><p>In testing the control loop timing, I found that execution time varies but is usually around 2.5 ms. To ensure the loop runs consistently every 4 ms, we check how far along we are in the 4 ms window and wait out any gap between the elapsed time and the required 4 ms:</p><pre># Wait if there is excess time<br>excess_us:int = cycle_time_us - time.ticks_diff(time.ticks_us(), loop_begin_us) # calculate how much excess time we have to kill until it is time for the next loop<br>if excess_us &gt; 0:<br>    time.sleep_us(excess_us)</pre><h3>Close</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_m3AGBuh8GWNyYil.png" /><figcaption>The flight controller running for the first time! (no motors yet)</figcaption></figure><p>We’ve now covered arguably the most challenging part of the entire <em>Centauri</em> ecosystem! We designed and printed the airframe in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-3-quadcopter-part-1-designing-a-3d-printed-airframe-9d4f9021a68c">chapter 3</a>, added and wired up the hardware in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-4-quadcopter-part-2-hardware-and-electronics-package-69a5c26bc30b">chapter 4</a>, and have now programmed the flight controller firmware here in chapter 5!</p><p>The <em>Centauri</em> quadcopter is now complete! Next, we’ll move on to the other half of the duo: <strong>the Pilot’s Transmitter</strong>, the device the pilot uses to control the quadcopter in flight.</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-6-transmitter-part-1-transceiver-platform-7aee3793da9a">Full-Stack Flight, Chapter 6: Transmitter, Part 1: Transceiver Platform</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=310b3f288975" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 4: Quadcopter, Part 2: Hardware and Electronics Package]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-4-quadcopter-part-2-hardware-and-electronics-package-69a5c26bc30b?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/69a5c26bc30b</guid>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <category><![CDATA[wiring]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[quadcopter]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 11:54:42 GMT</pubDate>
            <atom:updated>2026-08-14T12:14:15.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jgnb4eRdnPTfHyc8.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>. This article contains Amazon affiliate links. If you make a purchase through them, I may earn a small commission at no extra cost to you.</em></p><p>With the <em>Centauri Airframe</em> now 3D-printed and fully assembled in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-3-quadcopter-part-1-designing-a-3d-printed-airframe-9d4f9021a68c">the last chapter</a>, we are ready to move on to understanding the onboard hardware that makes flight possible, and then how it is all wired together into one fully working system!</p><p>Like any flight system, the full hardware and electronics package can appear sophisticated and complex, particularly to someone new to this area. In this chapter, however, I’ll do my best to thoroughly describe the role of each and every component onboard the <em>Centauri</em> quadcopter.</p><p>The image below shows all hardware onboard <em>Centauri</em>, classified into four sections:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OBBy4mCUsKaNYCPc.png" /></figure><ul><li><strong>Avionics</strong>: the central nervous system and “brain” of the operation.</li><li><strong>Propulsion</strong>: the active elements that directly make the drone fly.</li><li><strong>Power</strong>: the components responsible for taking raw battery power and conditioning it for safe distribution to the rest of the system.</li><li><strong>Passive</strong>: the elements that are present but play no active role in the direct operation of the quadcopter.</li></ul><p>The two most important categories to understand are <strong>Avionics</strong> and <strong>Propulsion</strong>, as these are the “bread and butter” of quadcopters. The diagram below gives a high-level visualization of the basic process chain a quadcopter flight controller follows, and how the <strong>avionics</strong> and <strong>propulsion</strong> hardware work together to achieve stable flight:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c2okJTArksX_EXaB.png" /></figure><p>In the diagram above, each blue box is a different hardware component onboard the quadcopter. Each component plays a unique and vital role during flight. <strong>If you are new to quadcopters and want to grasp how they work, focus on understanding how each of these components work together to achieve flight!</strong> I’ll provide a crash course below to get you started.</p><h3>Quick Reference: Complete Hardware List</h3><p>Before diving in, here’s a one-stop shopping list of every component used, for easy reference! Just in case you visited this chapter specifically to find a link to something you needed to buy. 😊</p><p><strong>Avionics</strong></p><ul><li><a href="https://amzn.to/4vZ5DkH">Raspberry Pi Pico</a> (microcontroller) — 1x</li><li><a href="https://amzn.to/4yh76Ev">MPU-6050</a> (IMU) — 1x</li><li><a href="https://amzn.to/4eWx48V">HC-12</a> (wireless transceiver) — 1x on the quadcopter (a 2nd is needed later for the transmitter)</li></ul><p><strong>Propulsion</strong></p><ul><li><a href="https://amzn.to/3QQwuAt">5-inch tri-blade propellers, 16-pack</a> — 1x</li><li><a href="https://amzn.to/44lyILf">Readytosky 2300 KV Brushless Motors (4-pack)</a> — 1x</li><li><a href="https://amzn.to/3SMnnBr">ESC 4-pack</a> — 1x</li></ul><p><strong>Power</strong></p><ul><li><a href="https://amzn.to/4g6kKSM">4S LiPo Battery</a> — 1x</li><li><a href="https://amzn.to/4vwD25n">XT60 connector pack</a> — 1x</li><li><a href="https://amzn.to/4vp6zh8">LM2596 Buck Converter</a> — 1x</li><li><a href="https://amzn.to/4bFcebU">10 uF capacitor</a> and <a href="https://amzn.to/44lKKUT">0.1 uF capacitor</a> — 1x each</li><li><a href="https://amzn.to/3SVQRNa">Ferrite bead pack</a> — 1x</li></ul><p><strong>Passive</strong></p><ul><li><a href="https://amzn.to/4aNJ0Yb">Resistor pack (100k + 22k ohm)</a> — 1x</li><li><a href="https://amzn.to/4yjdSJW">AKK BA3 AIO FPV module</a> — 1x</li><li><a href="https://amzn.to/4fwKjxb">SoloGood FPV Monitor</a> — 1x</li><li><a href="https://amzn.to/4guRMOn">JST-PH 2.0 Connector</a> — 1x</li><li><em>Optional (extended-range antenna configs):</em> <a href="https://www.digikey.com/en/products/detail/taoglas-limited/TI-10-0111/3131969">TI.10.0111 433 MHz antenna</a> and <a href="https://amzn.to/4f92Hee">U.FL to SMA coax cable, 12-inch</a></li><li><em>Optional (diagnostics):</em> <a href="https://amzn.to/44UV46q">RTL-SDR</a> and <a href="https://amzn.to/4pmRmw0">NanoVNA</a></li></ul><h3>Avionics</h3><p>The first area we’ll focus on is <em>Centauri’s</em> avionics package. As mentioned in the opening section above, the avionics package is like the central nervous system and “brain” of the quadcopter. Generally speaking, it observes the real-world environment, compares it to a set angular velocity goal, and then determines how to <strong>close the gap</strong> between the two; and <em>that</em> is a flight controller described in a single sentence!</p><p>Several components make up the avionics package:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r1jrGgVCdm7GAzaa.png" /></figure><p><strong>Microcontroller</strong>: the microcontroller is the “brain” of the entire quadcopter operation. It runs firmware, called the “flight controller”, that performs a number of operations at a very rapid rate to achieve flight — but more on that in the next chapter! Within the propulsion chain, the microcontroller’s role is to provide the <strong>throttle signal</strong> (in <a href="https://en.wikipedia.org/wiki/Pulse-width_modulation">Pulse Width Modulation</a>, or PWM, format) to each of the four ESCs (throttle from 0–100%), controlling the speed of each of the four motors to vary the thrust each propeller provides.</p><p>For <em>Centauri</em>, I used a low-cost, widely available, and easily accessible microcontroller: the <a href="https://amzn.to/4vZ5DkH">Raspberry Pi Pico</a>. The Raspberry Pi Pico is a development board built around the Raspberry Pi RP2040 microcontroller chip, and it can be programmed in MicroPython, C, or C++.</p><p><strong>Inertial Measurement Unit (IMU)</strong>: in order for the microcontroller to determine what level of throttle to apply to each of the four motors, it must be able to observe its current orientation (or rather, more likely, the <em>rate of change in its current orientation</em>). The onboard IMU is a sensor that allows the microcontroller to continuously observe this many times per second!</p><p>In <em>Centauri</em> I used the <a href="https://amzn.to/4yh76Ev">MPU-6050</a>, a very common, low-cost IMU that has both a 3-axis accelerometer and a 3-axis gyroscope built into it, providing 6 degrees of freedom.</p><p><strong>Wireless Serial Transceiver</strong>: the quadcopter needs to be in constant communication with the pilot, who provides constantly-changing control commands. While there are many wireless communication modules I could have used for this project, I opted for the low-cost, widely available, and easy-to-implement <a href="https://amzn.to/4eWx48V">HC-12</a>. The onboard <strong>HC-12</strong> wireless communication module allows for bidirectional serial communication between the quadcopter and the pilot’s transmitter device, which also uses an HC-12.</p><p>As described in the previous chapter, all three critical avionics elements are securely mounted on the <strong>lower level</strong> of the airframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qXySjsnJpZENOrKT.png" /></figure><h3>Propulsion</h3><p>What physical components onboard the quadcopter allow it to actually lift off? Enter the <strong>propulsion</strong> package!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-tvQWQ2rOukm6PKS.png" /></figure><p><strong>Propellers</strong>: the propellers on a quadcopter are arguably the most important component! The propellers are what spin and push air downward, producing the downward pressure that creates lift and allows the quadcopter to achieve flight.</p><p>Trust me, you could do a <em>very</em> deep dive into the science behind propellers and get very particular about exactly which propeller is best for the job. Material, diameter, pitch, shape, tip — there are <em>a lot</em> of factors you can evaluate and get very picky about! In my case, I purchased <a href="https://amzn.to/3QQwuAt">this 16-pack of 5-inch, tri-blade propellers</a> (4 sets) and had a ton of success! These were exactly what I needed for my project and have proved quite durable after many crashes.</p><p><strong>Brushless Motors</strong>: as the name <em>quadcopter</em> suggests, the drone has <strong>four</strong> motors, each independently controlled in thrust level to achieve stable flight and perform maneuvers. The motors are a critical component, as they are what spin the propellers to produce lift!</p><p>While I went with very high-performance motors in my previous quadcopter build, <a href="https://timhanewich.medium.com/taking-flight-with-the-raspberry-pi-pico-micropython-diy-quadcopter-drone-61ed4f7ee746">Scout</a>, for <em>Centauri</em> I opted for middle/low-performance motors. I used four Readytosky 2300 KV Brushless DC Motors, purchased on Amazon <a href="https://amzn.to/44lyILf">here</a>. The <strong>KV value</strong> of 2300 means that for every one volt applied to the motor, it is capable of spinning an additional 2,300 RPM. So at 14.8 volts (4S LiPo), these motors can spin at 34,000 RPM under no load. A high KV value like this is important for spinning propellers, as high speed is needed to move air and create lift efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WPe2SYthC_aqdcw7.png" /></figure><p>The image above shows all four motors securely fastened to the 3D-printed arms early in assembly. Note that each motor’s wires came with banana plugs, but I cut those off to instead solder the wires directly to the ESCs.</p><p><strong>Electronic Speed Controllers</strong>: in the picture of the motors above, you’ll notice each motor has <strong>three</strong> wires stemming from it. That may surprise you at first if you’re more familiar with traditional <em>brushed</em> DC motors, which have only two wires: a positive and a negative. A brushless DC motor (“BLDC”) has three wires to allow for the rapid switching of magnetic poles within the motor itself, which is what causes the rotor to begin rotating.</p><p>However, that switching of the magnetic poles within the motor is <em>very</em> fast — as in many tens of thousands of times per second! This switching rate, usually between 20,000 and 100,000 times per second, exceeds what a normal microcontroller can achieve. Because of this, quadcopters that use BLDCs typically have four <strong>Electronic Speed Controllers</strong> (ESCs) onboard, solely responsible for rapidly switching the supply of electricity to each of the four motors, changing the polarity of the stator within each motor and causing the rotor to turn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*puTizKeACcGZa2e6.png" /></figure><p>In the image above you’ll see the ESCs I used for <em>Centauri</em> mounted to the frame. I purchased these ESCs as a <a href="https://amzn.to/3SMnnBr">4-pack from Amazon</a> and was very pleased with their compact footprint and light weight.</p><p>Note that, if it’s your first time using ESCs with a brushless DC motor, you may find they don’t work right out of the box! This is because they need to be calibrated: in other words, they need to be “taught” the <em>minimum</em> and <em>maximum</em> throttle signal values they’ll be provided. There are plenty of videos online covering this calibration process — be sure to watch those and familiarize yourself with it! For my previous quadcopter, <em>Scout</em>, I wrote a lightweight 4-way (all-at-once) ESC calibration script that you can find <a href="https://github.com/TimHanewich/scout/blob/master/bonus_code/esc_calibration.py">here</a> and use to calibrate your own ESCs.</p><p>IMPORTANT: be mindful of motor direction! In a quadcopter, two of the motors turn <em>clockwise</em> while the other two turn <em>counter-clockwise</em>, in an “X” pattern: the front-left and rear-right motors turn clockwise, while the front-right and rear-left turn counter-clockwise. You don’t need to keep this in mind while mounting the motors to the frame; the direction a motor turns has everything to do with how the ESC is wired to it. While wiring the motors to the ESCs, if you have a motor turning in the <em>wrong</em> direction, simply swap any two of its three leads to the ESC and it will reverse direction! It’s also important to match the correct CW or CCW propeller orientation to the matching CW or CCW motor rotation to achieve the downward lift we’re looking for.</p><h3>Power</h3><p>The <em>Centauri</em> quadcopter is designed to be powered by any lithium battery supply ranging from <strong>2S to 4S</strong> (two, three, or four lithium cells in series); this means the overall system is capable of accepting a supply voltage <strong>as high as 16.8 volts</strong> (4S, fully charged) and <strong>as low as 6.0 volts</strong> (2S, fully discharged).</p><p><strong>Battery</strong>: You can use any battery you’d like, but I have used and had success with a <a href="https://amzn.to/4g6kKSM">4S Lithium Polymer Battery</a>. Normally a smaller battery pack with much less capacity is used on FPV quadcopters, but a high thrust-to-weight ratio was never my goal anyway, so I don’t mind using these ones I had lying around!</p><p>The battery you purchase will almost certainly use the <a href="https://www.google.com/search?q=xt60+connectors">XT60</a> connector, a very common connector in RC vehicles, drones, and other robotics. I purchased an inexpensive <a href="https://amzn.to/4vwD25n">pack of XT60 connectors</a> and used one as the female end to plug the battery in, supplying electrical power to the entire Centauri system.</p><p>Note that I have experimented with alternative supplies: a <a href="https://x.com/TimHanewich/status/1993492243664265347/video/1">2S 18650 Li-ion pack</a>, a <a href="https://x.com/TimHanewich/status/1993667177304707417/video/1">2S 21700 Li-ion pack</a>, a <a href="https://x.com/TimHanewich/status/1993678881501376795/video/1">3S 21700 Li-ion pack</a>, and a <a href="https://www.youtube.com/watch?v=FT0rBtNr84A">4S 18650 Li-ion pack</a>, all with limited success. The 3S 21700 pack and the 4S 18650 pack provided decent results, but did not pack the same punch as my 4S LiPo workhorse.</p><p>The supply current from the battery directly powers the ESCs and motors. But what about the other onboard components that require a much lower voltage?</p><p><strong>LM2596 Buck Converter</strong>: the first component in this section is the <a href="https://amzn.to/4vp6zh8">LM2596 Buck Converter</a>. The role of the LM2596 is to step down the raw battery voltage (which ranges from 16.8v to 12.0v) to a much lower, stable, regulated 5 volts. While the ESCs and motors are supplied the raw battery voltage, the “logic” components — the microcontroller, sensors, and so on — all require 5 volts. Anything beyond 5 volts will fry them, so <em>stepping down</em> the supply voltage to 5v is very important!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vmdS7VLFWcx6gIM_.png" /></figure><p>The LM2596 is a variable buck converter, meaning it has a small screw that can be turned to adjust its output to whatever voltage is needed. <strong>Be sure to continuously monitor the output voltage and adjust the screw until you reach 5v!</strong> The great thing about the LM2596 is that, as long as the input voltage exceeds the output voltage, the output will <em>always</em> stay at a fixed and stable 5v; so whether the input is 16.8v (fully charged 4S LiPo) or 12v (fully discharged 4S LiPo), the output remains 5v!</p><p>Excellent! Now, with a stable 5v supply, we have a 5v line to feed all onboard logic components that require it; at this point, we have the <em>bare minimum</em> needed to achieve flight! If you’re looking for the simplest possible design — you just want to achieve flight and keep things simple for now — you can stop here. And that’s where I originally stopped too!</p><p>While building <em>Centauri</em>, I learned that managing and regulating the power supply fed to the other critical and highly-sensitive modules onboard is very important for performance and reliability. The ESCs, described in the “Propulsion” section above, rapidly switch the current provided to the motors (at several thousand times per second), and this rapid switching can introduce serious <a href="https://claude.ai/share/f9b4ea50-dac4-44b4-b492-9cfcd169bb15"><strong>electrical noise</strong></a> that ripples throughout the electrical system. The good news is that I figured out a decent way to combat this (for the most part), and I’ll share all about it below!</p><p>I discovered this after some pretty severe accidents. The <em>Centauri</em> quadcopter was severely limited in range — at only tens of meters away, it would struggle to receive clean signals from the pilot’s transmitter, often resulting in crashes. Upon further testing with an <a href="https://amzn.to/44UV46q">RTL-SDR</a>, I found there was a <em>serious</em> amount of noise coming from the antenna on the quadcopter, even while idling at a low RPM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*JQPwbtqSS8AX8GxD.gif" /></figure><p><em>The above shows an example of a crash due to a Rx communication issue.</em></p><p>I made some changes, described below, that drastically reduced the noise in the system, leading to a much cleaner signal received by the antenna and HC-12, and boosting range and performance:</p><p><strong>10 uF Capacitor</strong> and <strong>0.1 uF Capacitor</strong>: this two-capacitor combo is placed directly at the HC-12’s power pins, filtering out electrical noise caused by the ESCs. The <a href="https://amzn.to/4bFcebU">10 uF capacitor</a> filters out low-to-mid frequency noise while the <a href="https://amzn.to/44lKKUT">0.1 uF capacitor</a> filters out high-frequency noise. Both act as a small local charge reservoir that can be drawn upon when minor disturbances in the supply voltage occur, “smoothing” out the stability of the voltage supplied to the HC-12.</p><p><strong>Ferrite Beads</strong>: two ferrite beads are also used in the electrical system to further keep unwanted electrical noise from affecting the highly sensitive HC-12. A ferrite bead is like a selective gatekeeper: it lets desired electrical signals, like DC power, pass through while blocking high-frequency interference (like that created by four noisy ESCs!) from getting through. In a way, ferrite beads act as resistors to unwanted high frequencies. I purchased <a href="https://amzn.to/3SVQRNa">a pack of ferrite beads</a> and placed one on the HC-12’s VCC line and one on the GND line.</p><p>After implementing the capacitors and ferrite beads, I saw quite a bit of improvement in the ambient electrical noise present while the ESCs are operating:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5EAXHzq55-JzgrZ0.png" /></figure><p>As you can see above, the severe noise pollution from the ESCs was drastically reduced by implementing the capacitors and ferrite beads; this improves the ability of the highly-sensitive HC-12 to receive messages from the transmitter.</p><h3>Passive Components</h3><p>In addition to the “active” components above, which play a direct role in the functioning of the all-up quadcopter system, there is also a “passive” category that is part of the electrical design purely for informational purposes. As I mentioned in a previous chapter, a big goal I had with <em>Centauri</em> that my first quadcopter project, <em>Scout</em>, lacked was the ability to detect onboard battery voltage and relay it back to the pilot.</p><p><strong>100,000 Ohm Resistor</strong> and <strong>22,000 Ohm Resistor</strong> as a <strong>voltage divider</strong>: the Raspberry Pi Pico I used as the microcontroller has several analog-to-digital pins that allow it to read the voltage on a pin, ranging from 0.0 volts to a maximum of 3.3 volts. A voltage divider lets us “divide” the raw supply voltage down into a portion that falls within that readable range, from which we can infer the full voltage of the battery. I used resistors from <a href="https://amzn.to/4aNJ0Yb">this pack</a> that I purchased.</p><p>You can read more about voltage dividers <a href="https://ohmslawcalculator.com/voltage-divider-calculator">here</a>, but the gist is that a voltage divider with an R1 resistor of 100,000 ohms and an R2 resistor of 22,000 ohms divides the supply voltage down to 18% of itself, meaning a fully charged 16.8v 4S LiPo battery would be divided down to 3.03v and a fully depleted 12v 4S LiPo battery would be divided down to 2.164v — both well within the safe range for the Pico’s ADC pins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hd78daL-nE20_sLd.png" /></figure><p>Knowing the fixed proportion of divided voltage to full voltage, and reading the divided voltage within that range, we can then do some basic math onboard the quadcopter to infer the <em>actual</em> voltage of the battery! We simply divide whatever voltage is read on the Pico’s ADC pin by 0.18 to get the actual supply voltage of the battery.</p><p><strong>All-in-one FPV Module</strong>: another capability I had very much wanted in my previous quadcopter, <em>Scout</em>, was the ability to fly via an onboard camera! By adding an onboard camera that streams an FPV video feed back to the pilot, you become able to perform significantly more complex maneuvers using the onboard perspective. For this, I added the <a href="https://amzn.to/4yjdSJW">AKK BA3</a>, an AIO (“all-in-one”) camera, transmitter, and antenna module. All it needs is a stable 5v power supply, and it will continuously broadcast an analog video signal, viewable through analog-capable FPV goggles or monitors!</p><p>While flying with the FPV AIO module onboard, I noticed that the very tip, where the 5.8 GHz antenna attaches to the body, is very fragile and <em>very</em> prone to breaking if the quadcopter flipped over and drove this tip into the ground. So I designed this simple yet effective two-piece frame that extends above the height of the fragile tip, designed to take the brunt of any impact and protect the FPV AIO module itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0jMLOf-q8IE90gn4.png" /></figure><p>This AIO module frame and all other assets are available on <a href="https://github.com/TimHanewich/centauri">Centauri’s GitHub repo</a>.</p><p>With the FPV AIO module onboard the quadcopter body with a 5v supply, all we have to do to watch its live transmission is get our hands on analog FPV goggles or a FPV monitor! I purchased the <a href="https://amzn.to/4fwKjxb">SoloGood FPV Monitor</a> and have had a lot of success with it for flying the quadcopter <em>and</em> recording the video feed via its onboard DVR.</p><p><strong>433 MHz Antenna</strong>: the HC-12 wireless communication module operates in the 433 MHz frequency band and comes with a small “spring” antenna that you can attach directly to the HC-12, giving it enough range to fly in the immediate vicinity (maybe ~30 meters). If that’s enough for you (it was for me at first), great! Use the spring antenna for simplicity — that would be “Configuration A” from the last chapter. But if you want to pursue longer range and better performance, you’ll turn to Configuration B, C, or D, which use a proper externally mounted antenna.</p><p>Let me tell you, finding and using <em>the right</em> antenna proved harder than I thought! I assumed it would be as simple as picking a 433 MHz antenna off of Amazon and being done. This is <em>not</em> the case; in the world of antennas, none is <em>exactly</em> perfect, and you have to be very discriminating about which you use.</p><p>Long story short, I purchased and used the <a href="https://www.digikey.com/en/products/detail/taoglas-limited/TI-10-0111/3131969">TI.10.0111</a> by Taoglas Limited, purchased through Digikey. I bought a pack of four, and all four tested with SWRs of 2.0 and below, <a href="https://i.imgur.com/I65SBzN.jpeg">one even at 1.05</a>. I also purchased <a href="https://amzn.to/4pmRmw0">a NanoVNA</a> to test the resonance (performance) of the antennas. Warning: I do not recommend trusting antennas purchased on Amazon or other consumer retail sites; I did originally and found <em>awful</em> performance from these antennas: poor SWRs and incorrect tuning bands. I highly recommend purchasing your 433 MHz antenna from a reputable retailer that provides datasheets; the quality control should be much better!</p><p><strong>U.FL to SMA Coaxial Cable</strong>: if you <em>do</em> go down the “Configuration B, C, or D” route with an external antenna, you will need to purchase a U.FL to SMA coaxial cable: this is the cable that connects the 433 MHz antenna to the HC-12. The antenna screws into one end of the cable while the other snaps into the HC-12.</p><p>If you are building <em>Centauri</em> in Configuration B or C (side-mounted or rear-mounted antenna), I found a 6-inch cable provides enough slack to connect the two in their positions, though it may be <em>a bit</em> tight in Configuration C (rear-mounted). In Configuration D (mast-mounted), you’ll need a significantly longer cable. I purchased and used <a href="https://amzn.to/4f92Hee">these 12-inch U.FL to SMA coaxial cables</a>, which provided plenty of slack to reach between the somewhat forward-mounted HC-12 and the mast-mounted 433 MHz antenna.</p><h3>Wiring</h3><p>Now that we’ve discussed every component onboard, let’s now look at how everything is wired together in one cohesive system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X-8qUo3yHy4I2YNM.png" /></figure><p><em>Note: click </em><a href="https://app.diagrams.net/#Uhttps%3A%2F%2Fraw.githubusercontent.com%2FTimHanewich%2Fcentauri%2F880aef867fc2f1b2ec5d29fdde0b9acc81f665ad%2Fcomponents%2Fquadcopter%2Fwiring.drawio#%7B%22pageId%22%3A%22W1gebfnubh0FSxZTr-fW%22%7D"><em>here</em></a><em> to open that wiring diagram as an interactive design on draw.io!</em></p><p>In the above wiring diagram, you can see that the 4S LiPo battery supply is immediately split into three paths:</p><ul><li><strong>Propulsion</strong>: the ESCs are directly hooked up to the raw input supply from the battery, using this to power the motors. (<em>note that ESCs are usually capable of handling a range of voltages, typically in the 2S-4S voltage range</em>)</li><li><strong>Avionics</strong>: the raw supply lines from the battery are passed through an LM2596 buck converter set to 5 volts, which then powers all logic components onboard. Downstream of the buck converter, that 5 volt output feeds:</li><li><strong>Raspberry Pi Pico</strong> (microcontroller)</li><li><strong>HC-12</strong> (wireless serial communication module) — <em>note the implementation of the ferrite beads</em></li><li><strong>FPV All-in-One Module</strong> (camera, transmitter, antenna for FPV video) — <em>you’ll see I also used a </em><a href="https://amzn.to/4guRMOn"><em>JST-PH 2.0 Connector</em></a><em> to allow this to be easily added or removed.</em></li><li><strong>MPU-6050</strong> (inertial measurement unit) — <em>note that this is actually powered by a 3.3 volt supply, directly from the Pico!</em></li><li><strong>Voltage Divider</strong>: the supply from the battery is also passed through two resistors as part of a voltage divider design, with the divided line read on one of the Pico’s analog-to-digital pins, allowing it to infer the voltage of the battery (and thus its state of charge).</li></ul><p>With power distributed, the Pico takes control of each of the four ESCs’ signal wires, commanding the throttle of each motor:</p><ul><li>GP21 controls Motor 1 throttle (front left)</li><li>GP20 controls Motor 2 throttle (front right)</li><li>GP19 controls Motor 3 throttle (rear left)</li><li>GP18 controls Motor 4 throttle (rear right)</li></ul><h3>The Finished Product</h3><p>So what does the airframe, fully printed, look like with all of this hardware onboard and wired up together? See below!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rUI8DKHrrkXZlTGK.jpeg" /><figcaption>Centauri from the front</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NKd0oae23Jj1h2TN.jpeg" /><figcaption>Centauri from the side</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P89s1d7RhzzKrYFz.jpeg" /><figcaption>Centauri from the rear</figcaption></figure><p>I’ll acknowledge it up front: the wiring job on this implementation of <em>Centauri</em> is very sloppy! I made the mistake of leaving so much extra slack in all of the wires before putting it together, and then had to find ways to secure the extra wiring to the frame so it wouldn’t get caught in the propellers — so I just zip-tied everything down. In my next iteration, I’ll be much more careful with wiring so as not to leave <em>so much</em> extra slack, which later creates a problem. But regardless, it works! It flies!</p><p>And it is a bit on the heavy side for a 5-inch quadcopter. Fully kitted out in Configuration D (antenna mast), it weighs 824 grams:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xk3JoalSVaaLttvb.jpeg" /></figure><p>Of the 824 grams above, 347 is the 4S 3300 mAh battery, leaving 477 grams for the fully assembled body without the battery.</p><h3>Close</h3><p>And now, with our body printed, the hardware assembled onto it, and everything wired up, we are ready to move on to the software phase: the Centauri Flight Controller! In the next chapter I’ll detail the role of a flight controller and describe exactly how the Centauri flight controller works to achieve stable flight.</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-5-quadcopter-part-3-the-flight-controller-310b3f288975">Full-Stack Flight, Chapter 5: Quadcopter, Part 3: The Flight Controller</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69a5c26bc30b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 3: Quadcopter, Part 1: Designing a 3D-Printed Airframe]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-3-quadcopter-part-1-designing-a-3d-printed-airframe-9d4f9021a68c?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d4f9021a68c</guid>
            <category><![CDATA[aerospace]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[3d-printing]]></category>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[full-stack-flight]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 11:51:19 GMT</pubDate>
            <atom:updated>2026-07-28T11:51:19.914Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-ESe4CTGUC5w4AQQ.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>. This article contains Amazon affiliate links. If you make a purchase through them, I may earn a small commission at no extra cost to you.</em></p><p>As mentioned in a previous chapter, one of my goals with the new <em>Centauri</em> quadcopter was to design my own custom airframe that I could 3D-print. My previous flight controller, <a href="https://timhanewich.medium.com/taking-flight-with-the-raspberry-pi-pico-micropython-diy-quadcopter-drone-61ed4f7ee746">Scout</a>, relied on a Flamewheel F450 body I purchased off the shelf.</p><p>After a month and change of planning and designing, I had a finished body!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/0*bY9Uep9wADhhBwki.gif" /></figure><p>You can find the design files for the <em>Centauri</em> airframe <a href="https://www.thingiverse.com/thing:7194383">on Thingiverse</a>!</p><p>In this chapter I’ll walk through the design decisions and the process behind developing the <em>Centauri</em> quadcopter body.</p><h3>Criteria</h3><p>Designing a quadcopter airframe, as I quickly discovered, is challenging! The design has to satisfy <em>a lot</em> of competing criteria:</p><p><strong>5-Inch Quadcopter</strong>: I wanted this quadcopter to be significantly smaller than <em>Scout</em>, which was very large. Specifically, I was targeting a <strong>5-inch</strong> body. In the quadcopter world, “5-inch” refers to the propeller diameter on each of the four motors; props are commonly measured by their diameter in inches, and quadcopters are usually “sized” the same way. So a 5-inch frame must be wide enough to fit 5-inch propellers, the maximum diameter it can support. A 5-inch frame is the “gold standard” in FPV racing and prints efficiently, but it’s small, which leaves little room for onboard hardware!</p><p><strong>It must fit all hardware</strong>: Once I settled on the 5-inch goal, I had to figure out how to <em>fit</em> all of the onboard hardware. There are a lot of components to embed! I list them below, but I’ll cover each one and its role in the next chapter; trust me, that could be an entire chapter on its own!</p><p><strong>MCU programmable port must be accessible</strong>: Whenever I update the flight controller firmware or pull telemetry off the MCU, I need to connect to it over USB. The Raspberry Pi Pico I’m using as the MCU has to be positioned where it’s easy to plug into without taking the frame apart.</p><p><strong>Onboard Prong (GoPro) Mount</strong>: Something I wished <em>Scout</em> had was the ability to capture onboard video! This quadcopter needed a “prong” mount so I could screw in my GoPro (or any compatible device) to record in-flight footage.</p><p><strong>IMU Close to Center of Mass</strong>: As you may know, one of the things a flight controller does to achieve stable flight is continuously monitor the <em>actual</em> change in orientation (gyro rates) during flight. Because clean gyro readings are <em>absolutely critical</em> to stable flight, it’s essential that the IMU sits as close to the quadcopter’s center of mass as possible. Off-center placement skews these readings, introducing error and, in turn, instability.</p><p><strong>Antenna line-of-sight</strong>: I’ll expand on this in the next chapter on the hardware package, but there’s a 433 MHz “rubber ducky” antenna onboard for bidirectional communication with the pilot (transmitter). Maintaining that link is <em>vital</em> in flight. Even a half-second delay could be catastrophic mid-maneuver. So optimal antenna positioning, with little to no obstruction, was a primary concern.</p><p><strong>Future Expansion</strong>: I wanted this body to be future-proof for near-term iterations. What do I mean by that? Down the road, I may add a <a href="https://en.benewake.com/TFLuna/index.html">TF Luna</a> LiDAR unit to the underbelly to enable altitude tracking and controlled landings. I didn’t plan to include it in the first build of <em>Centauri</em>, but I wanted to design with it in mind so that adding it later wouldn’t require a full redesign! That meant including mounting holes at the bottom for the LiDAR unit, plus the option to add a “stand” so the unit doesn’t scrape the ground when the quadcopter is at rest.</p><p><strong>Simplicity</strong>: As with any engineering design, the real measure of success is meeting <em>all</em> of the criteria in as efficient a package as possible. My goal was <em>not</em> to over-engineer the airframe, but to arrive at a simple, intuitive solution that achieves the goal with minimal complexity.</p><h3>Design Solution</h3><p>In this section I’ll document, in detail, the airframe design I developed to accommodate all of those criteria. I spent <em>a lot</em> of time in Blender mocking up the hardware components the drone would have to fit, designing a frame around them, and shifting their positions until I found the optimal layout!</p><p>Given my 5-inch goal (prop diameter) and my desire to keep the frame 3D-printer friendly (not huge!), my first decision was to space the motors exactly 200mm apart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZxxWabAJcrGKlNrb.png" /></figure><p>At 200 millimeters between motors, the 5-inch props (127mm) have plenty of clearance from each other and won’t strike any onboard components.</p><p>To hold all of the planned hardware and electronics, I designed the airframe with two levels: a lower level (“level 1”) and an upper level (“level 2”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XWafsoLUn9laMqMz.png" /></figure><p>The two levels are separated by 19.5 mm, a gap conveniently set by the height of the arms themselves. I sized this height to exactly match what an M3*30mm screw provides!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AxC_bE77wS40PXtT.png" /></figure><p>The arms incorporate several design considerations:</p><ul><li>The 19mm x 16mm hole pattern at the end (where the motor mounts) perfectly matches the mounting screw positions of <a href="https://amzn.to/4pgOY9G">the motors I used</a>.</li><li>The middle is hollowed out to save weight, but with a “bridge” across it for mounting the ESC.</li><li>A 2mm “tunnel” through that bridge lets a small zip tie pass through and clamp the ESC firmly in place.</li><li>Two M3 holes at the base of the arm let two M3*30mm screws pass through, holding the two levels together while the arm acts as a natural spacer between them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gxaSjl8YVmvBX3dm.png" /></figure><p>The arm above is shared by all four positions, with only minor modifications on some versions to accommodate an antenna mast.</p><p>Now let’s take a closer look at the onboard components inside the airframe. The lower level holds:</p><ul><li>The Raspberry Pi Pico (microcontroller)</li><li>HC-12 radio communications module</li><li>MPU-6050 IMU</li><li>LM2596 5V voltage regulator</li><li>A small gap at the bottom right that holds down the pigtail connecting the battery to the electronics system (input).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ccep1YOE46tAKm7H.png" /></figure><p>As you can see above, the lower level (“level 1”) contains the bulk of the electronics package needed for flight.</p><p>First, the Raspberry Pi Pico (the microcontroller, or “brain,” that runs the flight controller) is mounted at the very front of the lower level, fastened with M2 screws. This placement keeps its USB port accessible from the outside, making it easy to flash new firmware or recover recorded telemetry!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GHq-9k0xfO3XPZy1.png" /></figure><p>Just behind the Raspberry Pi Pico sits the HC-12 radio control module. Unlike the Pico, the HC-12 has no mounting holes, so I added slots where two very thin zip ties can pass through the lower level and clamp it down tightly. It doesn’t budge!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ldicFwEjMb_aH6ll.png" /></figure><p>Just behind the HC-12 is the <a href="https://amzn.to/4yh76Ev">MPU-6050</a> (IMU). As mentioned, the IMU’s position is <em>very</em> important! Here, the MPU-6050 sits in the exact middle of the airframe, right at the center of gravity, giving it the most accurate gyroscope readings.</p><p>You’ll also notice the MPU-6050 sits in a 3D-printed frame I designed for it. The MPU-6050 does have a hole for screwing it directly into the body, but doing so would transmit vibrations that throw off the IMU readings and inhibit stable flight. Instead, the board rests on double-sided foam tape inside this frame, a lightweight but effective filter against the high-frequency vibrations from the motors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DMM3hEheUPE8KgLF.png" /></figure><p>At the rear of the lower level lives the LM2596 module, a voltage regulator (“buck converter”) that steps the LiPo battery’s voltage (12+ volts) down to the stable 5V supply the logic electronics need. Like the MPU-6050, it sits in a 3D-printed frame, not for vibration damping this time, but for organization and secure mounting (I’d used this frame in previous projects).</p><p>Next to the LM2596 frame is an open space where the positive and negative input lines are fastened down with zip ties. At the end of these lines is a female <a href="https://amzn.to/4yjAuKt">XT60 connector</a> that the onboard LiPo battery plugs into.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b2QmFB6WCNZkWsPU.png" /></figure><p>The upper level holds three components:</p><ul><li>The battery, which takes up the vast majority of this level. As mentioned, I used a rather large 4S 3,300 mAh battery!</li><li>A 3-prong GoPro mount at the very front of the drone. It can hold a GoPro, or really any device with a compatible 2-prong mount!</li><li>The antenna mast at the rear of the drone (shown in red). While it isn’t technically <em>on</em> the upper-level plate, antenna line of sight is very important, so I positioned the antenna at the very top of this mast, away from electronics that could interfere or obstruct it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PvQ5olP6X-i-8bze.png" /></figure><h3>Unused Design Aspects</h3><p>As mentioned earlier, the Centauri airframe includes several design elements that aren’t used in the current iteration of <em>Centauri</em> but are available to leverage in the future.</p><p>One of those future ideas was mounting a LiDAR unit to the underbelly, letting the flight controller get an accurate altitude reading in close proximity to the ground. With a unit on the underbelly, though, I had to make sure the quadcopter could rest on something <em>other than</em> the LiDAR unit, which would damage it.</p><p>The simple solution was four M4 screw holes on the lower level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pp4d8Z4RrN-ZXe8x.png" /></figure><p>Four M4*30mm screws can thread through to act as “landing legs”, keeping the LiDAR module off the ground. I would <em>not</em> recommend landing on these on cement, as they’re rigid with no flexibility or “cushion.” Instead, I gently set the quadcopter on them before takeoff and always do a soft landing on grass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H-rUZKVb0fLOyJhq.png" /></figure><p>For mounting the LiDAR unit itself (a <a href="https://amzn.to/4fk1hxM">TF Luna</a>), two small M2 holes at the center let the unit attach to the underbelly. If you scroll up, you’ll see this M2 hole also penetrates the MPU-6050 frame!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DpXladWqjIbXvvMf.png" /></figure><h3>Four Configurations</h3><p>The section above described the Centauri airframe in “Configuration D”, its most advanced and capable form. There are actually <em>four</em> configurations, each only slightly different from the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBhJa8pLUvFzdMv6.png" /></figure><p>As seen above, the only thing that changes across the four configurations is the <strong>antenna position</strong>. I found the 433 MHz antenna’s position significantly affects the quadcopter’s range; each configuration achieves a different antenna position, and thus a different range:</p><ul><li><strong>Configuration A: Internal Spring Antenna = Least Range</strong> — this configuration uses <em>no</em> externally mounted 433 MHz antenna at all! It relies on the HC-12’s <a href="https://www.google.com/search?udm=2&amp;q=hc12+spring+antenna">standard spring antenna</a> soldered directly to the HC-12 and bent into a compromised position to fit the tight gap between levels 1 and 2. I <strong>do not recommend</strong> this configuration, as it severely limits range, but I’ll grant that it’s the quickest to get running, the simplest, the most durable, and perfectly fine for a first iteration just to validate that the quadcopter works.</li><li><strong>Configuration B: Side-Mounted Antenna</strong> — the first of the externally mounted 433 MHz antenna configurations. With a high-quality antenna mounted externally, range improves significantly. However, I found it less than ideal at distance: the quadcopter can turn into an orientation that puts the LiPo battery <em>directly</em> between the antenna and the pilot’s transmitter, breaking the line of sight.</li><li><strong>Configuration C: Rear-Mounted Antenna</strong> — this moves the externally mounted antenna to the rear of the airframe, directly behind the battery. That solves most of the “LiPo blocking” problem from Configuration B, letting the antenna keep direct line of sight to the transmitter in many more orientations. However, during resonance testing with a NanoVNA, I found that positioning the antenna so close to a dense battery hurt its ability to receive reliably.</li><li><strong>Configuration D: Mast-Mounted Antenna = Greatest Range</strong> — the “final” configuration, with the externally mounted antenna perched atop a “mast” at the rear of the body. The mast puts space between the LiPo battery and the antenna, getting the antenna into free air. This configuration delivers the greatest range but it’s also by far the most fragile. Any roll the quadcopter makes will almost certainly snap the mast and end your day of flying, so be careful! I’ve successfully flown at ~100 meters with no problems in this configuration.</li></ul><p>If you’re just starting out and only want to confirm your quadcopter works, I recommend <strong>Configuration A</strong>: it’s simple, low-cost, and durable enough for the early crashes you’ll inevitably take.</p><p>If you’re experienced or want to make sure your build goes the distance, I recommend <strong>Configuration D</strong>: it’s more complex, but it’s the best configuration for performance. You can also <em>start</em> with Configuration A and later move to <strong>Configuration D</strong> by printing the rear-left arm with the antenna mast and swapping it in.</p><p><strong>Configuration B</strong> and <strong>Configuration C</strong> are comfortable middle grounds between A and D.</p><p>All parts required to assemble every configuration are available in the design <a href="https://www.thingiverse.com/thing:7194383">on Thingiverse</a>.</p><p><em>If you’d like to quickly compare the “complete” designs in each configuration, you can download a fully assembled airframe for each one here: </em><a href="https://github.com/TimHanewich/centauri/releases/download/67/centauri_config_A.stl"><em>Config A</em></a><em>, </em><a href="https://github.com/TimHanewich/centauri/releases/download/67/centauri_config_B.stl"><em>Config B</em></a><em>, </em><a href="https://github.com/TimHanewich/centauri/releases/download/67/centauri_config_C.stl"><em>Config C</em></a><em>, </em><a href="https://github.com/TimHanewich/centauri/releases/download/67/centauri_config_D.stl"><em>Config D</em></a><em>.</em></p><h3>Printing</h3><p>With the design covered, let’s talk about printing!</p><p>There are <strong>twelve</strong> unique parts to the Centauri airframe (in “Configuration D”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5f9xRWn7wE8RzGXa.png" /></figure><p>Printing every component at 30% infill takes <strong>164 grams</strong> of PLA, as shown below:</p><p>PartPLA @ 30% InfillLevel 1 (Lower Level)30 gLevel 2 (Upper Level)30 g4 Arms68 gMPU-6050 Frame4 gLM2596 Frame9 gGoPro Mount8 gAntenna Mast (3 components)15 g</p><p>At <strong>164 grams</strong> of PLA, and assuming roughly $15.00 per 1,000-gram roll, that comes out to just <strong>$2.46</strong> in PLA to print the entire Centauri body!</p><p>Below are some photos I got while printing a few of the parts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DWEc7zeXWq2E4WPq.jpeg" /><figcaption>printing the lower level</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVqhIM9im4bxa1Dk.jpeg" /><figcaption>printing the arms</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i1LKI-WnF-frTbTd.jpeg" /><figcaption>arms printed</figcaption></figure><h3>Close</h3><p>With the body designed and printed, the next chapter details the hardware package and electronics wiring mounted onboard: the sensors and components that make flight possible in the first place!</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-4-quadcopter-part-2-hardware-and-electronics-package-69a5c26bc30b">Full-Stack Flight, Chapter 4: Quadcopter, Part 2: Hardware and Electronics Package</a>.</p><p><em>Read to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d4f9021a68c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Full-Stack Flight, Chapter 2: Defining a Communication Protocol]]></title>
            <link>https://timhanewich.medium.com/full-stack-flight-chapter-2-defining-a-communication-protocol-41bfc589a319?source=rss-77c9bad82740------2</link>
            <guid isPermaLink="false">https://medium.com/p/41bfc589a319</guid>
            <category><![CDATA[full-stack-flight]]></category>
            <category><![CDATA[hc12]]></category>
            <category><![CDATA[radio]]></category>
            <category><![CDATA[quadcopter]]></category>
            <category><![CDATA[communication]]></category>
            <dc:creator><![CDATA[Tim Hanewich]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 11:51:08 GMT</pubDate>
            <atom:updated>2026-07-28T11:51:08.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y_4QcGEoudVqE1Mf.jpeg" /></figure><p><em>This article is part of a 10-part series on how the </em><a href="https://github.com/TimHanewich/centauri"><em>Centauri Quadcopter</em></a><em> was created. For a list of all other articles, please visit the introductory article found </em><a href="https://medium.com/@timhanewich/full-stack-flight-building-a-quadcopter-ecosystem-from-scratch-18d43386bb6d"><em>here</em></a><em>. This article contains Amazon affiliate links. If you make a purchase through them, I may earn a small commission at no extra cost to you.</em></p><p>As mentioned in <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-1-the-centauri-ecosystem-eacfcecc90f5">the previous article</a>, <em>Centauri</em> is an entire quadcopter ecosystem. Since in this project I take on designing and building both the drone and the pilot’s transmitter from the ground up, I am also responsible for designing how the two communicate with each other over radio. The communication protocol is an <em>extremely</em> important part of the Centauri ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A0_mL8K6JR1LnwAH.png" /></figure><p>There are 4 different classifications of information (data) that may be exchanged between the Transmitter and Drone:</p><ol><li><strong>Control Packet</strong> (<em>transmitter → drone</em>): an update in the throttle, pitch, roll, and yaw input the pilot is applying. (high frequency during flight)</li><li><strong>Settings Update Packet</strong> (<em>transmitter → drone</em>): an update in the PID gains that the drone will use to stabilize while flying. This allows for “on the fly” updates without having to “hard-code” these into the flight controller code!</li><li><strong>Telemetry Packet</strong> (<em>drone → transmitter</em>): periodic packet the drone will broadcast out to update the transmitter (pilot) of its status: battery level, IMU data, etc. Broadcasted every 2 seconds while <em>not</em> armed.</li><li><strong>Special Packet</strong> (<em>drone → transmitter</em>): a free-form text message that drone can transmit out to convey a direct message back to the pilot. Can contain any message. Used for things like confirming calibration, relaying problems.</li></ol><p>Designing a protocol to efficiently carry the data in each of these four exchanges was a big challenge! I’ll explain more on the design and decisions for each below, starting with the most important: the <strong>Control Packet</strong>.</p><h3>The “Control Packet”</h3><p>As mentioned above, the Control Packet is likely the most important packet of all. It is indeed where most of my time was spent optimizing efficiency, given its critical, high-bandwidth, low-latency requirement.</p><p>The primary role of this packet is rapid broadcasting of the pilot’s current inputs across four inputs: <em>throttle</em>, <em>pitch</em>, <em>roll</em>, and <em>yaw</em>. The transmitter will send these out at a high frequency (20 times per second); these packets will be received by the drone, unpacked, and used to update the PID equation which then calculates how to apply thrust across the four motors of the drone to accomplish the attitude change rates implied by the pilot.</p><p>Three challenges are presented in designing this packet that we must consider:</p><ol><li><strong>It is a bandwidth-constrained environment</strong>: discussed in further detail later in this series, both the transmitter and quadcopter will be using two low-powered, inexpensive, lightweight Tx/Rx radio modules, the <a href="https://amzn.to/4eWx48V">HC-12</a>. These are amazing devices but are not capable of high bandwidth comparable to the internet today.</li><li><strong>It must be efficient</strong>: the data being communicated must be read and processed by the Raspberry Pi Pico serving as the microcontroller of the <em>Centauri</em> quadcopter while operating consistently at several hundred PID loops per second. Efficiency in unpacking this data is <em>extremely</em> important!</li><li><strong>It must transmit quickly</strong>: the transmitter will <em>constantly</em> be sending updated control commands (updates of the pilot’s current inputs) many times per second. In commercial scenarios, this is often 100+ times per second, but in Centauri we will shoot for ~20 times per second to keep it manageable. At 20 Hz, that means each packet must be transmittable in less than 0.05 seconds by the HC-12. This means the packet must be rather short, only emphasizing how its binary footprint must be efficient and high-density at packing the control commands.</li></ol><p>The following depicts the binary design I developed to contain the required input data in an efficient package:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1HHKByomAHBYihvA.png" /></figure><p>As seen above, <strong>eleven</strong> bytes are used, each byte serving as either A) packet metadata (identifier), B) control data, or C) a checksum:</p><ul><li><strong>Byte 1</strong> = Metadata byte, a packet header. This identifies the packet as a control packet to the drone which then proceeds to unpack it as so.</li><li><strong>Byte 2 and Byte 3</strong>: the throttle input, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 4 and Byte 5</strong>: the pitch input, encoded as a int16 (-32,768 to 32,767) in big-endian format.</li><li><strong>Byte 6 and Byte 7</strong>: the roll input, encoded as a int16 (-32,768 to 32,767) in big-endian format.</li><li><strong>Byte 8 and Byte 9</strong>: the yaw input, encoded as a int16 (-32,768 to 32,767) in big-endian format.</li><li><strong>Byte 10 and Byte 11</strong>: both used as unique checksums.</li></ul><p>The design above allows for several things:</p><ul><li>A uint16 being used to express 0 to 100% for <em>throttle</em> allows for fidelity of 0.003%</li><li>A int16 being used to express -100% to 100% for <em>pitch</em>, <em>roll</em>, and <em>yaw</em> allows for fidelity of 0.003%</li><li>A 16-bit checksum only allows a 0.0015% chance of a random control packet pass (low risk of unintended data)</li></ul><p>What is <em>not</em> included in the graphic above but <em>is</em> included in the transmitted packet is the \r\n terminator at the very end of the packet (0x0D followed by 0x0A) to delineate between packets that were sent. So altogether, 13 bytes (11 in the packet and 2 as terminator) will be transmitted 20 times per second, a rate of <strong>260 bytes/second</strong>.</p><h3>The “Settings Packet”</h3><p>As I mentioned previously in the opening chapter of this series, one of the serious challenges I had with my previous flight controller, <em>Scout</em>, was updating PID gains while PID tuning. In <em>Scout</em>, the PID gains were “hard-coded” into the flight controller code, meaning the process of PID tuning involved me updating the code and re-flashing it to the flight controller every time I wanted to experiment with a minor PID adjustment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*VU5vr6nHyJwOkKfs.gif" /></figure><p><em>PID tuning is arguably one of the most important aspects of a flight controller — and it isn’t easy!</em></p><p>Unlike <em>Scout</em>, <em>Centauri</em> would have an onboard radio communication module (the HC-12) that allowed me to theoretically exchange <em>any</em> information between the transmitter and quadcopter, so long as I wrote the code that would package it up, send it, receive it, and then unpackage it. With this capability I wanted to add a very important feature to <em>Centauri</em>: the ability to flash <strong>new</strong> flight settings (PID gains) on the fly.</p><p>During development of <em>Centauri</em>, this would enable me to enter in any PID gains I’d like on the transmitter side and then send them over to the quadcopter to then be updated live, obviously while unarmed (not flying). Thus, the <strong>Settings Packet</strong> was created to allow for the exchange of this flight settings data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bs0_4ESqbtrt8aFn.png" /></figure><p>As seen above, the settings packet is 22 bytes:</p><ul><li><strong>Byte 1</strong>: Metadata byte, a packet header. This identifies the packet as a settings packet to the drone which then proceeds to unpack it as so.</li><li><strong>Byte 2 and Byte 3</strong>: Pitch Kp, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 4 and Byte 5</strong>: Pitch Ki, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 6 and Byte 7</strong>: Pitch Kd, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 8 and Byte 9</strong>: Roll Kp, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 10 and Byte 11</strong>: Roll Ki, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 12 and Byte 13</strong>: Roll Kd, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 14 and Byte 15</strong>: Yaw Kp, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 16 and Byte 17</strong>: Yaw Ki, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 18 and Byte 19</strong>: Yaw Kd, encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 20 and Byte 21</strong>: I-Term Limit (safety to prevent uncontrolled spooling), encoded as a uint16 (0 to 65,535) in big-endian format.</li><li><strong>Byte 22</strong>: unique checksum.</li></ul><p>The <em>Centauri Transmitter</em> has the ability to <strong>pack</strong> these settings update values into a 22-byte settings packet via the pack_settings_update function in its tools.py module, shown <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/tools.py#L52">here</a>. You can see this function used live in the transmitter code on <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py#L378">line 378 of </a><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/transmitter/PC/src/main.py#L378">main.py</a>.</p><p>The <em>Centauri Flight Controller</em> (on the quadcopter) has the ability to <strong>unpack</strong> this 22-byte settings packet into a dict via the unpack_settings_update function in its own tools.py module, shown <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/tools.py#L45">here</a>. You can see this function used live in the flight controller code on <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py#L443">line 443 of </a><a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py#L443">main.py</a>.</p><p>Note that after the <em>Centauri Flight Controller</em> receives the settings update, unpacks it, and updates the settings values internally, it sends out a SETUPOK message (special packet) to confirm to the transmitter it was successful in receiving and implementing the updated settings values.</p><h3>The “Telemetry Packet”</h3><p>In addition to the inability to send PID gain updates over-the-air, another critical issue with <em>Scout</em>, my previous quadcopter flight controller, was the inability to get telemetry back from the quadcopter to the transmitter, visible to the pilot. Now with the two onboard transceiver radio modules, I could send anything back and forth… and this meant I could also send telemetry updates from the drone to the transmitter, visible to the pilot!</p><p>Enter the “Telemetry Packet”: a packet for sending high-level telemetry data to the pilot to update them on its status. There is a lot of data that could be sent over, but the only <em>very</em> important data point that I <em>really</em> wish I had on Scout is the <strong>battery voltage</strong>. Knowing the battery voltage without the need to unplug power from the drone and check with a multi-meter would allow for much safer, low-risk flying as I no longer would be only guessing how much battery I have left based on flight time.</p><p>Before proceeding, I want to explain that the telemetry packet actually has a dual purpose. There are two uses of telemetry in the <em>Centauri</em> ecosystem:</p><ul><li><strong>Use #1 = recording</strong>: for recording to storage on the quadcopter for later analysis.</li><li><strong>Use #2 = transmitting</strong>: sending the live telemetry to the transmitter for it to be shown to the pilot. At a much lower rate than in use case #1.</li></ul><p>Due to Tx/Rx constraints and to keep communication fast and lightweight, only a <em>subset</em> of all the telemetry collected and recorded will be sent to the transmitter. In other words, <em>all</em> of the telemetry collected will be <strong>recorded</strong> to onboard storage while only a select few data points will be <strong>transmitted</strong> back to the transmitter.</p><h3>The “Recorded” Telemetry Packet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BnsGTcJJ610yoTW3.png" /></figure><p>As seen above, the “recorded” version of the telemetry packet is 19 bytes in length; with the traditional \r\n terminator appended to the end, that is a total frame length of 21 bytes.</p><p>The recorded version of the telemetry packet consists of the following structure:</p><ul><li><strong>Byte 1, Byte 2, and Byte 3</strong>: the timestamp at which this telemetry was captured, encoded as a 24-bit unsigned integer (3 bytes).</li><li><strong>Byte 4</strong>: Battery Voltage, from 6.0 volts to 16.8 volts, expressed without the decimal point (e.g. 140 would be 14.0 volts, 152 would be 15.2 volts, 90 would be 9.0 volts).</li><li><strong>Byte 5</strong>: the rate of pitch change, in degrees per second, expressed as an int8.</li><li><strong>Byte 6</strong>: the rate of roll change, in degrees per second, expressed as an int8.</li><li><strong>Byte 7</strong>: the rate of yaw change, in degrees per second, expressed as an int8.</li><li><strong>Byte 8</strong>: the pitch angle, in degrees, expressed as an int8.</li><li><strong>Byte 9</strong>: the roll angle, in degrees, expressed as an int8.</li><li><strong>Byte 10</strong>: the current G-load (G-force), expressed without the decimal point (e.g. 12 would be 1.2 G’s).</li><li><strong>Byte 11</strong>: the throttle input from the pilot, expressed literally (0–100).</li><li><strong>Byte 12</strong>: the pitch input, expressed as an int8 (-100 to 100).</li><li><strong>Byte 13</strong>: the roll input, expressed as an int8 (-100 to 100).</li><li><strong>Byte 14</strong>: the yaw input, expressed as an int8 (-100 to 100).</li><li><strong>Byte 15</strong>: Motor 1 Throttle, expressed literally as a percentage (0 to 100).</li><li><strong>Byte 16</strong>: Motor 2 Throttle, expressed literally as a percentage (0 to 100).</li><li><strong>Byte 17</strong>: Motor 3 Throttle, expressed literally as a percentage (0 to 100).</li><li><strong>Byte 18</strong>: Motor 4 Throttle, expressed literally as a percentage (0 to 100).</li><li><strong>Byte 19</strong>: Last Received, in ms. The time elapsed since a Control Packet was last received (for tracking continuity). Expressed as 10x the actual ms time, e.g. “5” would be “50 ms”, “12” would be “120 ms”, allowing for a maximum duration of 2,550 ms to be expressed.</li></ul><p>Note that unlike other packets, there is <em>not</em> a checksum for the “Recorded” version of the telemetry packet; this is because this packet is only recorded directly to the flash storage onboard the microcontroller, <em>not</em> transmitted over-air where it is more susceptible to errors and bad data.</p><p>By recording the live telemetry periodically and storing to flash storage, this allows the user of <em>Centauri</em> to later download the telemetry, unpack it, and analyze it, or overlay it against a live in-flight video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*LHapyYIA78yXd-W9.gif" /></figure><h3>The “Transmitted” (Sent) Telemetry Packet</h3><p>The 19-byte full telemetry packet described as the “Recorded” packet in the section above captures all of the relevant telemetry and records that to the onboard flash storage (low latency). As described earlier, a subsection of this telemetry is also periodically <em>transmitted</em> from the quadcopter to the transmitter (pilot) over radio communication.</p><p>Specifically, the following data points are delivered: <strong>Battery Voltage</strong>, <strong>Pitch/Roll/Yaw Rates</strong> (degrees per second), and <strong>Pitch/Roll Angles</strong>. I selected these fields as the bare minimum that would allow the pilot to A) check battery voltage before flying and B) validate the IMU is working as expected, two items that are critical to flying safely!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JUm2VlOSSIRPet5n.png" /></figure><p>If you look closely, you can tell that <strong>Bytes 2–7 are direct transpositions of Bytes 4–9 from the “Recorded” version of the Telemetry Packet</strong>. In Chapter 4, when we look closely at how the Flight Controller works, you’ll see this design choice was chosen specifically for its efficiency over the need to “repack” <em>another</em> packet version.</p><p>Also, note: despite this being a <em>transmitted</em> packet (over the air via radio communications), this also does NOT have a checksum. Why? The information transmitted is not highly sensitive to the point where bad data would cause a catastrophic problem. If a periodic packet is received with bogus data, it will likely be very apparent to the pilot reading it and then quickly be replaced with an updated packet that contains the valid, correct data.</p><h3>Telemetry Packet Example</h3><p>The following example depicts how the <em>Centauri Flight Controller</em> uses the pack_telemetry function (found <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/tools.py#L87">in tools.py</a>) to pack a telemetry packet into a binary structure:</p><pre>from tools import pack_telemetry<br><br># Values sent in telemetry packet<br>ticks = 5345             # example system ticks, in ms<br>vbat = 125               # battery voltage, 60-168, representing 6.0 volts to 16.8 volts<br>pitch_rate = 3           # pitch change rate, in degrees per second (literal)<br>roll_rate = -1           # roll change rate, in degrees per second (literal)<br>yaw_rate = 0             # yaw change rate, in degrees per second (literal)<br>pitch_angle = 2          # pitch angle, in degrees (literal)<br>roll_angle = -2          # roll angle, in degrees (literal)<br><br># Values recorded to onboard telemetry, but not sent to transmitter<br>gforce = 12              # the current g-force level, expresed as 0 to 255 (0 = 0.0, 10 would be 1.0, 14 would be 1.4, etc)<br>input_throttle = 55      # throttle input, 0 to 100, expressed as a literal percentage<br>input_pitch = -13        # pitch input, -100 to 100, expressed as a literal percentage<br>input_roll = 3           # roll input, -100 to 100, expressed as a literal percentage<br>input_yaw = 0            # yaw input, -100 to 100, expressed as a literal percentage<br>m1_throttle = 65         # M1 (front left) motor throttle, expressed as a literal percentage (0 to 100)<br>m2_throttle = 63         # M1 (front left) motor throttle, expressed as a literal percentage (0 to 100)<br>m3_throttle = 42         # M1 (front left) motor throttle, expressed as a literal percentage (0 to 100)<br>m4_throttle = 37         # M1 (front left) motor throttle, expressed as a literal percentage (0 to 100)<br>lrecv_ago_ms = 62        # how many milliseconds ago a control packet was last received from the transmitter (for tracking Rx continuity)<br><br># pack into a bytearray<br>to_pack_into = bytearray(19)<br>pack_telemetry(ticks, vbat, pitch_rate, roll_rate, yaw_rate, pitch_angle, roll_angle, gforce, input_throttle, input_pitch, input_roll, input_yaw, m1_throttle, m2_throttle, m3_throttle, m4_throttle, lrecv_ago_ms, to_pack_into)<br><br># print the example<br># All of this will be saved to onboard telemetry<br>print(str(to_pack_into)) # bytearray(b&#39;\x00\x14\xe1}\x83\x7f\x80\x82~\x0c7WgdA?*%\x06&#39;)<br><br># only the vbat, rates, and angles are sent via to transmitter<br>telemetry_packet = bytearray(7)<br>telemetry_packet[0] = 0b00000000           # header byte. Bit 0 = 0 means it is a status packet.<br>telemetry_packet[1] = to_pack_into[3]      # vbat<br>telemetry_packet[2] = to_pack_into[4]      # pitch rate<br>telemetry_packet[3] = to_pack_into[5]      # roll rate<br>telemetry_packet[4] = to_pack_into[6]      # yaw rate<br>telemetry_packet[5] = to_pack_into[7]      # pitch angle<br>telemetry_packet[6] = to_pack_into[8]      # roll angle<br><br>print(str(telemetry_packet))               # bytearray(b&#39;\x00}\x83\x7f\x80\x82~&#39;)<br><br>for b in to_pack_into:<br>    print(str(b))</pre><h3>The “Special Packet”</h3><p>The final packet type is the “Special Packet”. This packet allows for the transmission of otherwise unstructured data, usually expressed in very short text-based messages (only a few characters). While designing <em>Centauri</em>, I wanted the ability for the drone to transmit miscellaneous messages to the pilot about various things from successful bootup or calibrations, to errors it encountered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O69Zu-LC6H_bBi4u.png" /></figure><p>As seen above, the special packet has a very simple structure. The first byte is always 0b00000001 (equivalent to 1), with bit 0 set to 1 to identify it as a Special Packet. The following 50 bytes each contain the decimal equivalent of each character of a message. This allows for small messages like &quot;SETUPOK&quot;, for example, to be sent. Finally, the \r\n terminator is appended at the end to mark the end of the packet.</p><p>At a maximum number of characters of 50, that means the maximum length of a Special Packet is 51, or 53 if you are counting the \r\n that is also transmitted. Note that not all packets will be of this length. If a message is only a few characters, only a few bytes will be used to represent those characters in the Unstructured Message section.</p><p>Because of its simplicity, packing a Special Packet and sending it to the transmitter via HC-12 is handled via a function drafted directly within the flight controller’s main.py, shown <a href="https://github.com/TimHanewich/centauri/blob/880aef867fc2f1b2ec5d29fdde0b9acc81f665ad/components/quadcopter/src/main.py#L149">here</a>.</p><h3>Close</h3><p>And with that, we’ve covered all four packet types that make up the <em>Centauri</em> communication protocol: the Control Packet, Settings Update Packet, Telemetry Packet, and Special Packet. Together, these four packets form the entire “language” the transmitter and drone use to talk to each other. Designing this communication to be efficient, low-latency, and reliable was a challenging but very important engineering aspect of this project.</p><p>With the protocol now defined, we can move on to actually building the physical hardware that will use it! In the next chapter, we’ll dive into the design of the <em>Centauri</em> quadcopter itself, starting with its 3D-printed airframe.</p><p>Click here to continue reading in this series: <a href="https://medium.com/@timhanewich/full-stack-flight-chapter-3-quadcopter-part-1-designing-a-3d-printed-airframe-9d4f9021a68c">Full-Stack Flight, Chapter 3: Quadcopter, Part 1: Designing a 3D-Printed Airframe</a>.</p><p><em>Ready to start building? </em><a href="https://discord.gg/wwqfmCUzGg"><em>Join the Full Stack Flight Discord</em></a><em> to ask questions, share progress, and connect with other makers building their own version of Centauri!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41bfc589a319" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>