This article explains what FC looptime is and whether faster looptime is really better for your quadcopter. We’ll also talk about gyro update frequency and ESC refresh rate which is equally important.
With all the new technologies coming out every day in the FPV multirotor world, it can be hard to keep up. “Looptime”, “Gyro update frequency” and “ESC protocols” are one of the concepts being discussed a lot in the FPV community, with regards to the FC and ESC.
What is Looptime in flight controllers?
Generally there are 2 things you need to know about when talking about looptime:
- Gyro sampling rate – how often gyro data is read
- FC looptime – how often PID loop acts on the gyro data
You sometimes see people talking about 4K/2K or 8K/8K, the first number is Gyro update rate, while the latter is FC looptime.
- 1000us = 1khz
- 500us = 2khz
- 250us = 4khz
- 125us = 8khz
The Different Looptime in Firmware
Today, the four main flight controller firmware for mini quad’s are Betaflight, Cleanflight, Raceflight, and the KISS FC firmware. Each firmware might or might not allow FC to run at different looptimes.
For example KISS FC is forced to operate at 1kHz (1000us looptime), while the fastest Betaflight can run is 8kHz (125us looptime). Raceflight can even do that at 32kHz.
PID Looptime Isn’t Everything
The reason we want higher looptime is to reduce latency in the system. But there are so many other factors that can cause delay than just PID loops, for example:
- Gyro Sensor Delay (such as the built-in Low-Pass filter and sampling rate)
- FC PID Looptime
- ESC Protocol (time for data to travel from FC to ESC) and motor refresh rate (how often ESC updates motor)
- Motor/Propeller Physical Delay (aka, the reaction time or change of RPM)
- Moment of inertia of a quadcopter (related to frame and weight distribution)
- FPV camera/VTX delay in a FPV quadcopter
- Radio transmission delay (TX to RX, RX to FC)
In this article we will focus on the first 3 things in this list, which are more related to FC looptime and can be improved in the software.
Most F3 FC these days are capable of 8KHz looptime, while some F4 can even do 32KHz. However apart from processor speed, Gyro sampling rate also has an impact on how fast you can run your looptime.
Learn about the difference of F1, F3, F4 and F7 flight controllers.
Gyro Sampling Rate
PID looptime is limited by Gyro sampling rate, basically gyro sampling must be equal or faster than PID loop.
Gyro sampling rate is affected by 2 things: the type of Gyro and the connection protocols between processor and Gyro.
The most popular MPU6000 Gyro with SPI can only go up to 8KHz sampling rate (with i2C, 4KHz), while the ICM-20602 can reach 32KHz.
You should always run your Gyro at the fastest sampling rate whenever possible, because there is no downsides to running higher sampling rate. I.E. for Gyro with i2c protocol, use 4KHz, for SPI protocol use 8KHz.
Gyro has some physical delay when sampling data, but it’s so small we can normally ignore (some micro seconds). However they have built-in low pass filter that can cause much noticeable delay. They are designed to reduce the amount of noise that can get through above certain frequency. For example in Cleanflight, the default Gyro_LPF is 42Hz, which would introduce a 4.8ms delay. That’s nearly 5 times as much as the PID loop delay!!
It seems to be a no brainier to use higher Gyro LPF frequency right? But the downside is it might give you a noisier quad that is hard to tune. While gyro delay doesn’t impact looptime, it does introduce latency to your quad and make it less responsive.
ESC Protocol determines how fast the ESC signals are sent from the FC. Standard PWM has a delay of 2ms, and that’s twice of much delay as 1KHz looptime. Therefore by improving what ESC protocol you use would give a very noticeable improvement on your quad’s flight performance.
Oneshot125 (250us delay at 100%) and Oneshot42 are invented later on to reduce the latency. Then Multishot are implemented which can reduce delay further down to 25us. And more recently, D-Shot was introduced which is even faster (with DShot1200) and more reliable than Multishot!
ESC Protocols vs FC Looptime
There are limitation on what max looptime you can use when using different ESC protocols.
As mentioned, delay of Oneshot125 protocol is between 250us and 125us depending on throttle level. Likewise, Oneshot42 is between 84us and 42us and Multishot is between 25us and 5us.
It makes perfect sense to have your ESC protocol running faster than FC looptime, otherwise your ESC will get behind in its data and can overload the ESC.
This is why Oneshot125 does not work with 8kHz FC looptime which is way too high. It can cause the ESC’s to get behind if the ESCs are picking up the signal at the 250us trailing edge of the PWM signal (see below diagram).
Likewise, if the multirotor is at full throttle, there won’t be any gap in the PWM signal between the leading and trailing edges so the throttle would be a straight line which will cause issues with reading and writing the PWM data.
Therefore when running Oneshot125, you shouldn’t run anything above 3.8kHz looptime on your flight controller. This ensures a small gap in the PWM signal can be created to allow the ESC’s to identify the signal properly. Otherwise invalid signal can cause ESC to shut-down.
Oneshot42 is capable of managing 8KHz looptime, while for 32KHz looptime you will have to use Multishot.
Benefits of Faster Looptime
There are benefits to running faster looptime and gyro sampling rate, but there are also some negative impacts with it.
Nyquist Frequency tells us that frequencies can be measured accurately that are lower than half of the sampling frequency. That means by setting looptime at 1KHz, we can accurately measure frequencies below 500Hz.
The problem is when there is vibration with frequency higher than the Nyquist Frequency (which is 500Hz in our example), they will not be ignored due to Aliasing, but show up at different and lower frequencies in the system. For example if there is a signal of 510Hz it could appear as 10Hz, while 1010Hz could also appear as 10Hz. As you can see, this could cause confusion to our flight controller.
That’s why we have digital low pass filter (LPF) in the Gyro to cut off noise above certain frequency. However you need to understand it only reduces the noise and doesn’t eliminate them completely, stronger noise could still get through due to Aliasing.
Running a higher sampling frequency increases the Nyquist limit, and higher frequencies can be measured more accurately. It also reduces the aliasing at lower frequencies. Not to mention the less latency in control loop can make the copter react faster.
Faster Looptime In Practice – Noise
Most experienced pilots would agree it makes a significant difference to flight performance by running higher looptime and use faster ESC protocol. Just think about back in the days when we were running 1KHz looptime with Oneshot125, and now 8KHz with DShot. :)
By making looptime faster, you are also raising the noise floor as it’s now open to a broader spectrum of frequency. It’s also known as the “D-Term” vibration in blackbox data, making your quad harder to tune and causing hot motors. Some quadcopters actually run better at slower looptime because it gets so noisy and has so much vibration at faster looptime.
And therefore additional filtering will be required when running fast looptime, and it will eat up any latency advantage with the phase delay. And even then there are some issues that even the increased filtering can’t handle.
A good example would be the Raceflight Revolt. Currently for Gyros that are doing 32KHz sampling rate are quite noisy, flight controllers like it need soft mounting.
Setting faster looptime isn’t going to make you a better pilot overnight. Only practice and tuning is going to do that. I have flown the KISS flight controller which runs at 1kHz, and with the tune I had the quad feels as locked in as I want it to be. I have also tried 8kHz on the Betaflight F3 and despite the quad flies very responsively, I had to soft mount the motors to reduce oscillations.
Unsynced Motor Update Speed
Not long ago, “unsynced motor update speed” was made possible, to allow motor update faster than Gyro/Looptime up to 32KHz.
When motor update rate is faster than looptime, we can expect the same value to be written to the motors repeatedly. Some argue this is useless work and doesn’t bring any benefit.
There is no exhaustive data to support if this is of any advantage to running faster motor update rate. However here is one of the reasons why I think it can be beneficial doing so. Because of the analog signal protocols we use in our FC/ESC (such as Multishot), noise can get into the system and affect the inaccuracy of values sent to the motors. By writing to the motors faster, we might be able to increase the accuracy of the value we want to write to the motors.
This shouldn’t matter to DShot and that’s why motor update rate was removed in the Betaflight configurator when using DShot.
For Betaflight: PID Looptime and Gyro Sampling Rate
Here is what we recommend for Betaflight which I am also currently running:
|F1 with I2C||2K/2K||2K/2K||2K/2K||2K/2K||Naze32|
|F1 with SPI||4K/2K||4K/2K||4K/2K||4K/2K||CC3D|
|F3/F4 with I2C||4K/2K||4K/4K||4K/4K||4K/(2K)(4K)||XRacer V2|
|F3/F4/F7 with SPI||8K/2K||8K/4K||8K/8K||8K/(2K)(4K)(8K)||Betaflight F3|
To free up resources for higher looptime, you might have to disable some of the features, such as accelerometer and soft-serial.
After setting your looptime, make sure to check your CPU load (CPU usage) is within 30% or 35% for stable performance.
Hope you find this article informative.