Cleanflight is dead…

Only 5 weeks ago I’ve written that Cleanflight has a problem. Looks like, the problem was much bigger than I expected. Today in the morning, Dominic Clifton aka. Hydra essentially killed the project by resetting GitHub repository to Betaflight 3.1.

It was announced on Facebook:

Cleanflight v2.0.0-RC1 is out now, with all the new features from Betaflight v3.1 – please share this post!

Thanks to the hard-working betaflight developers especially Boris B, Jason Blackman and Martin Budden who have been doing fantastic work for us all!

Also, all GitHub Issues and Pull Requests were deleted.

What does that means? More less the following:

  1. Cleanflight lost all it’s uniqueness and is Betaflight under different name
  2. Pilots that were using Cleanflight on airplanes or big multirotors are left alone. Betaflight aims on mini-quads, not airplanes!
  3. Why anyone would want to use CF when BF is there and this moment it offers better community support?

The way I see it, it was a nice ride, but now it is over and Cleanflight is dead. Too bad, since it had a huge impact on multirotor community over last few year…

Read More

SmartPort inverter for F4 flight controllers

While STM32F4 family processors installed in newest flight controllers are superior to STM32F3 (and F1 of course) in terms of raw speed, they are inferior to F3 family in terms of IO handling capabilities. For example, F4 family is not equipped with UART port inverters. And that creates a series of problems when it comes to connecting various serial RX receivers and telemetry systems.

The most popular FrSky (Futaba) S.Bus serial RX protocol and FrSky SmartPort telemetry require inverted UART signal. If there is no hardware inverter on hardware UART port, they will not work. While S.Bus requires only one data line, external inverter is not a big issue. Some time ago I’ve published The Simplest Harware Inverter. One MOSFET transistor, one resistor and that’s all.

In case of SmartPort, it’s slightly more complicated. Not only signal is inverted, SmartPort also combines TX and RX UART line into single wire. That means the following:

  1. More complicated inverter is required
  2. Software has to support this case and fallback to unidirectional UART mode

Hardware

Continue reading “SmartPort inverter for F4 flight controllers” »

Read More

PID looptime: why it is not only about frequency

Last 18 months was an extremely good period of time for all mini-quad enthusiasts. Progress, hardware and software both, was just incredible. Who could have guessed that in less than 2 years mini-quads will evolve into main group of drones with such excellent flight characteristics. Just take a look at looptime. When I entered the hobby, standard looptime was 3500us (285Hz). Then, someone noticed that mini-quads fly much better when looptime is lowered and it started. Right now, standard looptime is 2000us (500Hz), while Betaflight starts with 1000us (1kHz) or even 500us (2kHz) in case of faster flight controllers.

Just by looking at numbers one might come to a conclusion, that looptime should be kept as low as possible and higher control loop frequency is better. Hey, 2kHz should be twice as good as 1kHz, right? One might even thing that it’s really about frequency. Well, this is both false and true: sometimes it is not about frequency, sometimes it is about frequency after all.

Continue reading “PID looptime: why it is not only about frequency” »

Read More

How to install and configure Betaflight 3

Latest Betaflight 3.0 is a new quality for flight controller software. It brings many new, cool, features comparing to previous versions. If you fly mini-quad or micro-quad, you have to check what Betaflight 3 has to offer.

This tutorial will show how to install Betaflight 3 and how to configure it so mini-quad can go into the air in under 20 minutes.

To play with Betaflight 3.0 you will need latest Betaflight Configurator! Install or update to latest version.

Flashing

Open Betaflight Configurator

Betaflight Configurator

Continue reading “How to install and configure Betaflight 3” »

Read More

How to measure gyro noise frequency with Blackbox

Cleanflight / Betaflight / INAV lowpass filter tuning can be a hard thing to do if you have not idea what is noise frequency you want to cancel. Sure, you can blind test or read tutorials. But what if I tell you, you can measure it quite precisely using only Blackbox logs? Or measure rotation speed of motors? That would be nice, isn’t it? The only requirement are few seconds of Blackbox log with visible gyro (it can be also motor output or Pterm or even ACC reading) noise.

blackbox measure frequency 1

Continue reading “How to measure gyro noise frequency with Blackbox” »

Read More

INAV: unsynced gyro updates

Until recently, INAV concentrated on GPS and navigation support. Comparing to Betaflight, or even Cleanflight, its acro capabilities were rather limited. Flyable, but limited. Now we are trying to catch up. While upcoming INAV 1.2 will rather not change much in this topic, there are few experimental code versions that might greatly improve INAV acro capabilities. One of them is separation of gyroscope readouts from PID loop.

INAV and FP-PID with extensive floating point logic are rather slow. Looptime 2000us (500Hz update rate) is a limit for F1 targets and 1000us (1kHz mode) is barely reachable by most F3 targets. Version from mentioned above pull request separates gyroscope readouts and filtering from main PID loop. Thanks to that, gyro is updated much faster (up to 2.6kHz in case of F3 with I2C gyro). Faster gyro update means better signal signal quality, lower delay, better filtering and less aliasing. One the other hand, motors does not have to be updated that often. Not only they are unable to change rotation speed as fast as we can drive them, they are unable to notably change thrust as fast as we would like them to.
Let's do some math: what will the distance that tip of a 5" propeller running 12,000PRM will travel during 500us (2kHz update frequency)? About 40mm. More less 10% of a circuit. Not much distance to change generated thrust…

This might sound strange, but looks like it is working. Below is a short video of my 3S 250 quad running gyro loop at 2kHz and PID loop at 666Hz. Honestly? This quad never flew better! Please ignore my lame flying skills 🙂

If anybody would like to try asynchronous gyroscope on INAV, please drop me a message, I will compile and share this special version.

Read More

iNav: RTH with land mission

This video was taken last weekend during tests of latest changes implemented in iNav, as well as new GPS module Beitian BN-880 I shortly described here.
Mission plan:

  • Take off in Angle mode,
  • Engage 3D Position Hold
  • Fly away 100m
  • Return to Position Hold
  • Engage Return To Home mode

Summary:

  • Beitian BN-880 performed well. Quadcopter returned home with 1m accuracy. Constant fix on 15 sats all the time and HDOP at 1.2
  • No problems with magnetometer inside GPS module
  • No bigger problems during whole mission. I still have to work on yaw behavior. At the moment FP-PID and linear mixer from Betaflight can cause some strange yaw behavior on bigger quads. Fix should be available soon

Read More

Cleanflight 1.12 released

3 days ago, new version of Cleanflight, STM32F1 and STM32F3 flight controller software has been released. I already wrote few words about it a month ago, but final list of changes and improvements is bigger. Main changes are:

  • Looptime sync to gyro readouts, enabled by default (!),
  • New task scheduler,
  • Air Mode. Finally this awesome feature was merged from Betaflight. If you want to know more what Air Mode is, read this article,
  • Failsafe improvements. And what more important, failsafe can now be configured via Cleanflight Configurator. It has its own tab. To use it you will need Cleanflight 1.12 and Configurator 1.2 or newer,
  • MSP telemetry is gone. It’s replaced with LTM telemetry. Important notice: it is not MSP protocol. Only MSP telemetry was removed, not MSP protocol,
  • New hardware targets,
  • Documentation improvements. OK, this is minor, but I had some input there, and I’m quite pride of it!

I did not installed Cleanflight 1.12 on any of my quads yet, so no idea how it behaves. But 3 days without a path means that there should be no problems. Full release notes are available here

Read More

What is Betaflight Air Mode?

Better late than never, so here is mine explanation what is AirMode implemented in Cleanflights fork Betaflight and hopefully soon available also in Cleanflight. Before we will go to any details, please read this to understand how PID controller works. If you know, you might skip it.

In normal flight mode, No Air Mode, flight controller is not using I term from PID controller when throttle stick is low. Why? To make landing nice and easy. It zeroes it. If it would not do it, drone would want to fight pilot attempts to land. That makes sense, right? I term is also not desired during take off. Why? Gyro error might accumulate in I term even before drone takes off, that would result in spinning motors faster and faster (since machine can not correct anything while still on the ground) and in worst case scenario, drone might flip before going into the air. So, zeroing I term on low throttle is good. Or is it not?

Continue reading “What is Betaflight Air Mode?” »

Read More

Cleanflight software low pass filters

Back in version 1.9, Cleanflight introduced new software low pass filters for gyro readouts, P term and D term of PID controller. They are designed to smooth control loop output and filter gyro inputs from undesired high frequency noise. Unfortunately, Cleanflight documentation was not yet updated and says very little about them. Here are few things that I was able to find out about them.

gyro_cut_hz

This low pass filter (LPF) is a software filter for gyroscope readouts. Most probably the less useful from software LPF filters in Cleanflight. Why? It duplicates (sits on top) of hardware gyro_lpf LPF filter build into MPU6050 or other gyroscope used in flight controller. The only advantage of gyro_cut_hz is a possibility to set any frequency while gyro_lpf accepts only limited set of frequencies. Can be left at 0 (disabled) unless there is a good reason to use it.

To enable it and set cutoff frequency to, for example, 64Hz, enter CLI mode and type:

set gyro_cut_hz=64
save

pterm_cut_hz

This LPF is slightly more useful than gyro_cut_hz since P term of PID controller depends on both gyro readout (filtered by hardware gyro_lpf) and user input. So, in some cases P term frequency can be higher than gyro trace. On the other hand, frequency change is so small, that gain from using pterm_cut_hz is minimal. Setting it below gyro_lpf or gyro_cut_hz will make PID control loop react slower than expected and decrease flight performance. Can be left at 0 (disabled) unless there is a good reason to use it.

To enable it and set cutoff frequency to, for example, 32Hz, enter CLI mode and type:

set pterm_cut_hz=64
save

dterm_cut_hz

Finally something useful! D term of PID controller, since it is trying to look into a future, can be a source of huge noise and vibrations. After all, looking into a future is always a tricky business. This is why D term and change with totally different frequency than gyro input and there is a very good reason to limit D term change. Too see how excess D noise can affect gyro traces take a look at my Blackbox tutorial.

Limit how much? I have no idea, since it all depends on a machine PID controller is trying to stabilize. Betaflight (Cleanflight fork aiming at 250 and smaller racers) sets it at 42Hz. My personal experience with big and prone to vibration Reptile 500 frame ended at dterm_cut_hz at 14Hz. Rule of thumb is: smaller and more rigid frames allows for higher D term cutoff frequency and 42Hz is a good place to start. Bigger frames might require lower cutoff frequency and 10Hz is lower boundary. On the other hand, I was using dterm_cut_hz at 16Hz on a 250 quad and was happy with results.

To enable it and set cutoff frequency to, for example, 16Hz, enter CLI mode and type:

set dterm_cut_hz=64
save

This entry is outdated, please refer to June 2016 update

Read More