what is pid controller

What is a PID controller and how it works?

The whole FPV hobby, and especially multirotor drones, work only thanks to control theory and PID controllers. They are the only thing that separates chaos and immediate flip-over from a stable flight. A regular multirotor has at least 3 PID controllers. If you enable any mode with self-leveling, the number goes to 6. Any GPS assisted mode increases the number to at least 12.

Of course, the PID controllers we think when we think about when we say about multirotors, are Rate PID controllers. They keep our drones stable by keeping angular velocity at desired levels. And usually, they are the ones that have to be tuned to achieve a nice, smooth and stable flight.

Continue reading “What is a PID controller and how it works?” »

INAV fw_iterm_limit_stick_position – keep the Iterm under control

PIFF controller in INAV is with us for quite some time now. And it’s working just fine, much better than classic PID when it comes down to airplanes. There is, or rather was, a small problem tho: Iterm. When P and FF components of the controller are not tuned, Iterm might do crazy things that will surface themselves when you release the stick: airplane might either roll-back or do a follow-through.

In this video let’s discuss why this is happening and what INAV 2.1 did to mitigate this problem. Because it did and it’s called fw_iterm_limit_stick_position

What is Betaflight 3.5 Feedforward and how to use it

Betaflight 3.5 is just around a corner and it brings new cool things. There is no more Dterm setpoint weight and Dterm setpoint transition (relaxation ratio). They all were replaced by easier to understand Derivative and Feedforward (Feed Forward when you refer to the control theory tho).

Betaflight Derivative and Feedforward parameters are the new way of controlling "damping force" of the Dterm and responsiveness of a drone. The more Derivative gain you set, the more "damped", "delicate" and "swooshy" drone will be. The more Feedforward gain you apply, the more responsible to the sticks it will be. It's almost the same as with Dterm setpoint weight, but in my opinion, made simpler and can be set separately for each axis.

Betaflight 3.2 Dynamic Filtering Explained

With upcoming Betaflight 3.2, we will be given a new, outstanding, new feature: dynamic filtering. An belive me, it was worth waiting for Betaflight 3.2 only to get it. I do not care much about other changes that happened with version 3.2 but dynamic filtering it the thing! In this post I will explain, in simple words, what is dynamic filtering and how to enable it.

The problem of noise

Gyro has a nasty tendency to pick up a lot of noise. Vibrations. After all, there are a lot of things that can vibrate (motors, propellers) and resonate (frame). Without a good way to filter all that noise out, our racers would not fly as good as they fly now. And you would be replacing motors and ESCs even more often. I you want to know more about gyro noise sources and filtering, please watch my Gyroscope and filtering series on YouTube.

Continue reading “Betaflight 3.2 Dynamic Filtering Explained” »

Understanding Dterm: how Dterm really works

I will be very honest: until very recently I did not really understood how PID controller’s Dterm really works. Yes, something with dampening, something with “looking into future”, bla bla bla. But the reason for not understanding was because I was overthinking it. There is no “magic” only simple mathematics and few basic concepts which I will now explain.

Setpoint

Setpoint is the value which we request from our system. In case of multirotors, PID setpoint will be a rotation speed around axis given in degrees per second [dps]. Setpoint 0 means we do not want to rotate (keep current attitude) and setpoint 200 means we want to rotate at 200dps

Measurement

Measurement the value that represents actual state of the system measured by some kind of sensor. In our case, it will be the gyroscope and rotation-around-axis speed measured in degrees per second

Error

Error the difference between Setpoint and Measurement computed as Error = SetpointMeasurement. In our case, when Error is above 0, that means drone is rotating too slow and should speed up. If Error is below 0, drone is rotating too fast and should slow down

Understanding Dterm - setpoint measurement and error Continue reading “Understanding Dterm: how Dterm really works” »

INAV 1.6: Fixed Wing PIFF Controller

Another new feature of upcoming INAV 1.6 (BTW, INAV 1.6 ALPHA-1 has just been released) is brand new PID controller for fixed wings. I repeat: this new controller is used only on fixed wings, multirotors are not affected.

So, what is new about this new PID controller? First of all, it is no longer a PID (Proportional, Integral, Derivative). It is a PIFF (Proportional, Integral, Feed Forward) controller. What is the difference?

Traditional PID controller computes error between setpoint and measurement and feeds it to 3 modules: P, I and D.

PID controller

Continue reading “INAV 1.6: Fixed Wing PIFF Controller” »

JavaScript PID controller

I suppose this is the first time programing topic came up on this blog. Probably not the last time, since this is what I do most of the time.

While working on serial port usage balancing for INAV Configurator I’ve quite accidentally created a PID controller in JavaScript. Maybe it’s not the most advanced PID controller ever, but has all the things required:

  • computes P-term
  • computes I-term
  • computes D-term
  • has output limiting
  • has I-term accumulator limiting

Continue reading “JavaScript PID controller” »

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” »