Robotics & Control
Advanced

PID Controller

Control output from proportional, integral and derivative of the error.

Formula

u(t)=Kpe+Ki ⁣∫e dt+Kddedtu(t) = K_p e + K_i \!\int e\,dt + K_d \frac{de}{dt}

Variables

uControl output
eError
K_pProportional gain
K_iIntegral gain
K_dDerivative gain

Example

Tuning K_p, K_i, K_d balances speed, overshoot and stability.

How it works

A PID controller computes a correction signal from three pieces of information: how large the current error is, how long that error has persisted, and how quickly it is changing. The proportional term reacts immediately to the present error, the integral term removes long-term bias by accumulating past error, and the derivative term anticipates future behavior by damping rapid changes. Together they form a practical feedback law because they combine fast response, steady-state accuracy, and stability in one control rule.

When to use it

Use a PID controller when you need a system to track a target value or reject disturbances using feedback, such as in motor speed control, temperature regulation, drone attitude control, or robotic position control. It is especially useful when the plant is too complex for a simple exact model, but you can measure the error over time.

Worked example, step by step

Given: K_p = 2.5, K_i = 0.8, K_d = 0.3 Current error: e = 4 Past error area over time: \int e\,dt = 6 Error rate of change: de/dt = -1.5 Step 1: Proportional term K_p e = 2.5 \times 4 = 10 Step 2: Integral term K_i \int e\,dt = 0.8 \times 6 = 4.8 Step 3: Derivative term K_d \frac{de}{dt} = 0.3 \times (-1.5) = -0.45 Step 4: Add the three contributions u(t) = 10 + 4.8 - 0.45 = 14.35 Final answer: the controller output is u(t) = 14.35

Common mistakes to avoid

  • Forgetting that the integral term depends on accumulated error over time, not just the current error
  • Using the raw derivative of noisy measurements without filtering, which can make the control signal unstable
  • Choosing gains independently of the physical system, leading to overshoot, slow settling, or oscillation

Did You Know?

PID control dates to ship autopilots of the 1920s and still runs the vast majority of industrial systems today.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026