What FC Looptime should I use?

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

Today, the four main flight controller firmware for mini quad’s are Betaflight, Cleanflight, Raceflight, and the KISS FC firmware. Each firmware can run at a different looptime.

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

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 Delay

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.

Gyro LPF Delay
256Hz 0.98ms
188Hz 1.98ms
98Hz 2.8ms
42Hz 4.8ms
20Hz 8.3ms
10Hz 13.4ms
5Hz 18.6ms

ESC Protocol

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).

lead-trail-edge-pwm-looptime

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.

In Practice

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.

25 thoughts on “What FC Looptime should I use?

  1. seth gunter

    i have switched to beta flight on an 250 size quad..with naze32 and older 16amp opto RW.RC blheli esc..the quad arms but once i take off it goes out of control totally.. i know i has something to do with the both loop times i just dont want to mess around for ever to figure it out..so what is the origanal loop time on cleanflight to match beta flight..cleanflight worked fine..i am not haveing so much luck with beta flight being a easy switch..even my newly built 180 tyrant with new escs and things needed work to get flying again..

    Reply
  2. Jim

    “If there is a signal of 510Hz it could appear as 10Hz, while 1010Hz could also appear as 10Hz.”

    All 510 hz signal sampled at 50hz will alias to 490 hz.

    Reply
  3. Bhargav

    hello ! I am making a quadrotor at stm32 microcontroller and using the traditional ESC running at 50 Hz. I am using the PID to control the copter but I don’t know at what frequency should i run the PID loop. Please guide me.

    Reply
  4. xhitm3n

    Hi, i have a questionar related to the how beneficial is running higher refresh rate on motors than kids? You mentioned inaccuracy because of noise, but this happens in analog signal, but with dshot, there isn’t any benefit at all? Since digital signals are precise and almost lossless? An example, running kiss at 1khz as it runs, andd running dshot600 which is around 37khz, so multiple unnecessary written signals to the motors? Is this theory right?
    Thanks

    Reply
  5. moosestang

    Betaflight now breaks looptime down into gyro looptime and pid looptime, so which is this article talking about? It’s my understanding that you want to run gyro as fast as the FC/gyro can handle.

    Reply
    1. Oscar Post author

      yes you are right, betaflight has advanced since this article was written. “Looptime” in this article was referred to PID looptime.

      Reply
      1. Yao Wei

        Hi guys, based on what was said and Betaflight’s documentation. So on ESCs with Oneshot125 I run PID Loop Freq at 4kHz. Now I have an X-racer SPI which supposedly runs up to 8kHz, so if I change Gyro Update Freq to 8kHz it automatically changes PID Loop Freq to 8kHz as well. Is that an inherent dummy code that tells users if you are running 8k on gyro update you should also run 8k on pid loop ?
        Thanks

    2. John Holmes

      The PID loop is what processes the gyro data, so there is no point in running the PID loop at a different speed than the gyro update rate. For example, If you have the gyro update rate at 8k, and the PID loop at 4K, only every other gyro read will be processed by the PID controller. Same thing the other way around, if you have your PID loop running at 8k and your gyro update rate at 4k, the PID loop will run twice with the same data. The whole point of these faster refresh rates, is to have the freshest data possible, for the PID loop to process, and the more times you update your data in a given period of time, the more precise and less drastic the FC can be in its corrections, IE smoother flight.

      Reply
  6. Luke Q

    I’m running some afro 12amp escs with the naze32. Hobbykings website says the afros run at 1khz so what would be the best looptime to run on the naze. I have flashed the escs with blheli (originally simonk).

    Reply
    1. Anthony Aery

      After flashing your ESC’s with the BLHeli firmware, use the BLHeli suite to configure your ESC’s to ensure Oneshot125 is on. As the author of the article mentioned the Loop time for the ESC using Oneshot125 is between 250us or 4Khz and 125us or 8Khz. The author also recommend not running your FCU any faster than 250us or 4Khz, as this gives the ESC’s the best opportunity to identify the signal properly.

      In short run your ESC’s with Oneshot125 enabled, and run your FCU(Naze32) 4Khz or 250us.
      Hope it helps.

      Reply
    2. Oscar Post author

      with their original firmware (old simonK), i think Looptime 2000 should do a pretty good job :)

      Reply
  7. Adam

    Hi all
    Just checking to see if I got this article right…
    I’m using littlebee’s 30a ESC’s which uses the SiLabs 390 48 MHz processor + SPRacing F3 FC on a HMB-230 frame (which is considered to be very rigid).
    Please correct if I’m wrong but with RaceFlight and BLheli can I run multishot over this setup?

    Reply
    1. Reuben Horner

      Pretty sure you need a modified version of blheli that supports multishot. But yea, those components are good to go

      Reply
      1. kubais

        And how about LB30A running multishot but with F1 board – Naze rev6 (ACC disabled). I have at the moment 2,6K looptime, which is what Boris said is safe margin for F1 with ACC disabled and I have no clue what motor_PWM_rate I should set it to? Have it same as looptime or go with unsynced rate at 32K? Or is there even any sense to run multishot when my PID loop time is just 375us and article stays that multishot is for looptimes 25us and lower.

  8. Pie

    I would love to see you do a writeup on dRonin and test it out. :) Thinking about testing it out. The autotuning stuff sounds really nice and a lot of people have been talking warmly about it lately.

    Reply
  9. Jocelyn Da Prato

    Maybe you can help ?
    I have blHeli SN20A oneshot (they said oneshot 123 ? ) And Naze clone, which is Flip32. If I don’t want my cf to be “faster” than my ESCs, I have to set looptime around 125us to 250us in cleanflight ?

    THx :)

    Reply
    1. Oscar Post author

      You mean oneshot125? LOL I think for your setup, setting looptime to 2Khz is probably the highest you can go with your setup…

      Reply
  10. Some Dude

    On Raceflight my looptime is at 125 which is 8KHz and my Motor PWM Rate is at 16KHz… The gyro is not synced with the ESCs.

    Reply
  11. Benjamin

    “Therefore, with lower looptime your quad can also be “noisier”, and the flight controller isn’t always reading the best data as the noise can interfere with the values going through the PID control loop. ”

    That actually depends on the implementation of the filter. If the filter is very simple and only processes a fixed number of values, it’s true – but that would also be a crappy filter design. If the filter works on an actual frequency level, the opposite holds. In this case, higher loop times will allow you to correctly sample and then filter noise of higher frequencies. This improves your sensor data quality and makes the FC less sensitive to noise.

    In my experience with betaflight on a noisy mini-quad, higher loop-times lead to cleaner logs and higher stability in flight. This leads me to believe that betaflight uses frequency-based filters in the right places. I may be wrong about betaflight, but maybe you could explain both possibilities (good filter/crappy filter) in the post. Just in case.

    Reply
    1. Adriel Perkins

      I may be mistaken as I haven’t kept up with the newer versions of Betaflight since I’ve been flying KISS. However, my understanding was that the LPF is turned off in Betaflight as soon as you go above 1khz because the filter can’t handle anything faster.

      Very interesting point you bring out using your black box logs though.

      Reply
  12. Alex

    “Therefore, with higher looptime your quad can also be “noisier”, ”
    are you sure? maybe “lower looptime” (and higher refresh rate)?

    Reply
    1. Oscar Post author

      Sorry, yes you are right i think the article meant to say lower looptime :) thanks for pointing that out.

      Reply
    2. Benjamin

      You’re right, I mixed it up all over my comment.

      Lower loop time -> higher acquisition frequency, less aliasing, higher quality sensor data. In case of betaflight: Lower loop time -> cleaner logs and better flight behaviour.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you Robot? *

I am moving all supports to this forum IntoFPV.com (at least for now)... So if you are looking for help, or want to help people, I strongly recommend joining this community. Feel free to share your projects, builds and knowledge too!