PID control and tuning guide

PID Control and PID Tuning Guide: Stabilisation, Calibration and Filters for RC

A drone holding position in the wind, a plane keeping its altitude and a gimbal keeping the picture steady all rely on the same algorithm: PID control. This guide explains how PID works, how P, I and D affect flight, a step-by-step tuning method and the groundwork a good tune needs (firmware, calibration and filters).

4 min read
In this article 7
  1. How does PID control work?
  2. Where is PID used?
  3. Before tuning: firmware, calibration and filters
  4. Step-by-step PID tuning
  5. How hardware affects PID
  6. Frequently asked questions
  7. Related guides

How does PID control work?

PID continuously calculates the difference (error) between the desired value and the measured value and produces a correction to reduce it. When you tell a drone to stay level, the gyro measures that it is tilted 3 degrees; PID turns that 3-degree error into corrections for the motors.

The output is the sum of three terms:

Output = Kp × error + Ki × (error accumulated over time) + Kd × (rate of change of error)

TermWhat it doesToo lowToo high
P (proportional)Reacts directly to the current errorVehicle feels sluggish and looseFast oscillation
I (integral)Corrects error that builds up over time (wind, off-centre weight)Slowly drifts, can’t hold an angleSlow oscillation, bounce-back after manoeuvres
D (derivative)Damps changes in error, reduces overshootOvershoot and bounce after quick movesHot motors, more noise

Flight controllers use separate PID values for the roll, pitch and yaw axes. On drones this loop runs thousands of times per second.

Where is PID used?

  • Stability and heading control on multirotors
  • Roll, pitch, altitude and speed control on fixed-wing planes
  • Speed hold or heading hold on autonomous cars and boats
  • Camera gimbal stabilisation
  • Self-balancing robots and path following in autonomous vehicles

Ready-made stabilisation systems such as AS3X and SAFE use similar control loops behind the scenes. See AS3X and SAFE for details.

Before tuning: firmware, calibration and filters

A good PID tune needs a solid foundation. Sort these out first:

Firmware

  • Choose the correct target for your flight controller, for example the target for your specific STM32F405 board.
  • Back up your settings before updating (in Betaflight, CLI diff all).
  • Don’t blindly paste old settings after an update; read the release notes, as some parameters may have changed name or meaning.

Calibration

  • Accelerometer: Calibrate with the vehicle level and still. A bad calibration causes constant drift in one direction.
  • Compass: On GPS systems, calibrate by rotating the vehicle through all three axes.
  • ESC: ESCs using analog PWM need throttle range calibration. Digital protocols such as DShot don’t.
  • Transmitter: Check endpoints and centre values.

Filters and vibration

Motor and propeller vibration in the gyro data enters PID as noise, especially through the D term. Betaflight’s dynamic notch and RPM filters track this noise by motor speed and suppress it. Filters can’t fix mechanical problems, though: start with balanced props, a solid frame and a soft-mounted flight controller. Too much filtering adds delay and makes the vehicle feel sluggish.

Step-by-step PID tuning

The default values in modern flight controllers already fly well on most standard builds. Tuning means improving them for your particular vehicle.

  1. Start with defaults: Fly on default values and check motor temperatures. Hot motors point to a filter or D-term problem.
  2. Tune P: Increase P gradually until fast oscillation starts, then back off a little.
  3. Cut overshoot with D: If it bounces back after hard moves, raise D. Stop if motors start getting warm.
  4. Improve hold with I: If it can’t hold its angle in wind or during throttle changes, raise I. Lower it if you see slow oscillation.
  5. Feedforward and rates: Adjust stick responsiveness separately with feedforward and rates.
  6. Test after every change: Change one value at a time and take notes.

Blackbox and autotune

Betaflight blackbox logs let you review gyro and PID data as graphs after a flight, so you can see noise and overshoot instead of guessing. ArduPilot and INAV AutoTune modes fly automatic manoeuvres and calculate PID values themselves, which is a very practical starting point for fixed-wing planes and larger multirotors.

How hardware affects PID

The same PID values behave differently on different vehicles. The deciding factors are:

  • Motor and propeller size, and weight distribution
  • ESC protocol and response time (for example DShot600)
  • IMU quality and mounting
  • Battery voltage and internal resistance: response changes as voltage drops

Check motor and prop choices with the thrust-to-weight and propeller and KV calculators.

Frequently asked questions

My drone oscillates in the air. What should I check first?

Check mechanical issues first: damaged or unbalanced props, loose screws, the flight controller mounting. If those are fine, P or D may be too high; review your filter settings too.

Is PID tuning the same in every flight controller?

The principle is the same but the scales differ. Betaflight, INAV and ArduPilot use different units and extra terms. Don’t copy values directly from one to another.

What role does PID play in autonomous flight?

Autonomous systems run nested loops: an outer loop controls position and velocity, an inner loop controls angular rate. Position comes from sensor fusion. For the full picture, read autonomous flight control for drones.

Found this useful?Share it with a friend or follow us on Instagram for new projects.

Similar Posts