PID Controllers
Proportional, integral and derivative actions combined — the most widely used controller in industry.
Intermediate
- P — reacts to the present error; alone it leaves a steady-state error.
- I — removes steady-state error; too much causes overshoot and oscillation.
- D — reacts to the rate of change, adding damping; sensitive to noise (filter it).
float pid_update(PID *c, float setpoint, float measured, float dt) {
float error = setpoint - measured;
c->integral += error * dt;
if (c->integral > c->i_max) c->integral = c->i_max; // anti-windup clamp
if (c->integral < -c->i_max) c->integral = -c->i_max;
float derivative = (error - c->prev_error) / dt;
c->prev_error = error;
return c->kp * error + c->ki * c->integral + c->kd * derivative;
}
Tuning: manual (raise until it oscillates, back off, then add and ), Ziegler–Nichols or auto-tune. Implement anti-windup whenever the actuator can saturate.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.