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.
The Different Looptime in Firmware
Some of these firmware can operate from 1kHz (1000us looptime) all the way up to 8kHz (125us looptime). (There are already experiments of running 32kHz in Raceflight)
For example in Betaflight, it’s possible to run 8kHz on it, while the KISS FC just runs 1kHz (1000us) looptime.
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 in the system than just PID loops:
- Gyro Delay (built-in Low-Pass filter)
- FC PID Looptime
- ESC Protocol (Refresh Rate)
- Motor/Propeller Physical Delay (change of RPM)
- Moment of inertia of a quadcopter (related to frame and weight distribution)
- FPV camera/VTX delay (if you fly FPV)
This article focuses on the first 3 things in the above list, as they can be improved right in the software.
FC looptime is basically the time it takes the FC to complete a PID loop. For looptime 1KHz, the delay would be 1ms.
- 1000us = 1khz
- 500us = 2khz
- 250us = 4khz
- 125us = 8khz
Most F3 FC these days can run up to 8KHz looptime, while some F4 can reach 32KHz.
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 brainer to use higher Gyro LPF frequency right? But the downside is it might give you a noiser quad that is hard to tune.
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) and Oneshot42 are invented later on to reduce the latency. More recently Multishot are implemented which can reduce delay down to 25us. And only a couple of months ago (Sep 2016), D-shot was born which is even faster and more reliable than Multishot!
We will discuss these ESC protocols in a bit more detail below.
Oneshot125, Oneshot42, and MultiShot Relation to FC Looptime
There are limitation on what looptime you can use when using different ESC protocols.
As mentioned, delay of Oneshot125 protocol is between 250us and 125us. Likewise, Oneshot42 is between 84us and 42us and Multishot is between 25us and 5us. Oneshot125/42 can be run on almost all ESC’s with Blheli installed. Multishot can only be run well on F39X Silabs ESCs such as the DYS XM20A, and BLHeli_S ESC’s.
It is preferred to have your ESC protocol is 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 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, it’s not recommended to run anything above 3.8kHz looptime on the FC, in order to create a small gap in the PWM signal which allows the ESCs to identify the signal properly. (Invalid signal can cause ESC shut-down)
With ESC’s capable of running Multishot, this isn’t really an issue. This is something to be aware of when selecting your FC looptime and ESC protocol.
Gyro Update Frequncy
Nyquist Frequency tells us that frequencies can be measured accurately that are lower than half of the sampling frequency. That means if the Gyro is synced with looptime at 1KHz, we can accurately measure frequencies below 500Hz.
The problem is when there is vibration with frequency higher than Nyquist Frequency (which is 500Hz in our example), they will not be ignored due to Aliasing, but shows up at different frequencies) in the system. If there is a signal of 510Hz it could appear as 10Hz, while 1010Hz could also appear as 10Hz.
This is where the Gyro built-in digital low pass filter (LPF) comes into play here, it cuts off noise that are above certain frequency. However you need to understand it only reduces the noise and doesn’t eliminate them, stronger noise could still get through due to Aliasing.
Therefore that’s why it’s important to use higher Gyro sampling rate (update frequency), to get more data and gives more accurate result.
Betaflight recently has separated Gyro update frequency from PID loops, so you can run Gyro sampling rate as high as possible. Of course there is also restriction from what kind of communication system is used in the Gyro, as far as I know, I2C BUS can allow Gyro to do up to 4KHz, while SPI can do 32KHz.
It makes a big difference to run highest Gyro Update Frequency and use the fastest ESC protocol, which gives you the higher state of tune you’re able to have. This should make the quad feel more responsive and more locked in.
It also helps to run faster the looptime, although there are many more other factors that contributes to bigger delay in the system, it might not make the biggest difference.
The most important thing to note though is that in practice, the lower looptimes on the FC, control loop tend to have the filters turned off, this allows all additional noise to pass through in higher frequency. Most flight controllers have low-pass filter (LPF), which reduces noise above certain frequency. The downside of a filter is increase in delay.
Therefore, when reducing looptime your quad might also get “noisier”, and the flight controller isn’t always reading the clearest possible data as the noise can interfere with the values going through the PID control loop. The added noise gets worse on less rigid frames and it can make tuning harder.
Be aware that flying either 1kHz or 8kHz isn’t going to make you a worse/better pilot. Only practice and tuning is going to do that. I personally fly the KISS flight controller which runs at 1kHz. With the tune I have the quad feels as locked in as I want it to be. That is my personal preference. I’ve also tried 4kHz on the Cyclone on a 4 inch quadcopter and found that despite the noise that was generated (though not bad) the quadcopter felt very locked in and fun to fly.
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 would 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 of 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, 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.