# Quadcopter stability vs (PID error signal lag and sample time)

The question I am asking is that, what is the effect on stability of increasing or decreasing both the sample time and lagging of error signal to PID. Does it helps in stability or degrade it?

A PID can provide great control, but it's a very unsophisticated technique -- it only understands error and correction. The longer you wait between measurements, the larger your error will be each time. (No surprises here, right? It's the difference between moving 60 miles every hour and moving 1 mile every minute.)

The best performance that you can get from a PID happens when it runs (1) as fast as your sensor can supply accurate measurements, or (2) as fast as your actuator can make accurate adjustments -- whichever is slower. If your sensor measurements aren't updating between PID ticks, your PID will overcompensate. If your actuators aren't updating between PID ticks, you will notice that your PID gains only work for a limited range of the output (e.g. it works fine at 75% thrust but goes crazy at 55% or 95%).

Regarding accuracy: it may be necessary to average out individual measurements from a noisy sensor, which sacrifices the sample rate. If that's the case, there really isn't much you can do here except lower your maximum speed. You can experiment a bit to see how much averaging is sufficient for your application, but you can't really get around the limitations of the hardware itself.

• Could you elaborate that bit in the last line of your second paragraph? About actuators being slower creating limited effective PID range? – a-Jays Oct 19 '15 at 17:26
• Sure. Think of the lag as a non-linear effect on your system, similar to a dead band or a stick-slip cycle. In that scenario, the $K_d$ component can line up with that lag effect over some range; you can tune as normal and things will appear to work fine. But when you move out of that range, things will seem to be out of tune again. There are many, many nonlinear effects to watch out for (like I said, PID is very unsophisticated), but I mentioned this one because it relates to lag. – Ian Oct 19 '15 at 18:58
• Interesting! That makes me want to revisit PID controllers in a more critical and contrasted analysis. Any directions you could recommend? – a-Jays Oct 21 '15 at 3:43
• Most of what I know comes from hands-on testing, not the literature. (And with a hardware system that's already set in stone, your options are limited: to slow down the PID frequency, decrease the operating range, or try to improve your actuation model -- usually some hack -- to make things fit what a PID expects.) I'd look for articles on finding the proper PID frequency for a given system. – Ian Oct 21 '15 at 16:46

In general, a system that is "discrete" will always be less stable, the less samples per time, the less stable it will be.

Imagine you are driving a car. You are only allowed to turn the steering wheel every 10 minutes. Can you keep the car on a curvy road this way?

To expand the example to answer your second question: don't drink and drive. If your sensors are lagging, your ability to control the car are evidently reduced.

• ok, so the sample rate is proportional to stability; but the sensors on high sensitivity gives more noise while on lower sensitivity(lagging signal) gives less error. So what do to with that. that is: non lagging => noise. lagging => lesser noise. – Bilal Ayub Oct 9 '15 at 11:01