Skip to content

Recommended Tuning Procedure

Alex edited this page Aug 18, 2026 · 1 revision

Recommended Tuning Procedure

The controller should normally be tuned in stages.

1. Start With P Only

Configure:

pid.setTunings(
    Kp,
    0.0,
    0.0);

Increase Kp until the system responds sufficiently fast without becoming excessively oscillatory.

A pure proportional controller may leave a steady-state error. That is acceptable during this step.


2. Add Derivative Action

Next configure:

pid.setTunings(
    Kp,
    0.0,
    Kd);

Increase Kd gradually.

The derivative term should reduce the output when the measured value approaches the setpoint quickly.

Desired behavior:

Process value

Setpoint -----------------------------------
                              +-------------
                           +--+
                        +--+
                     +--+
---------------------+

The objective is to slow the approach before the setpoint is crossed.

If the D term becomes noisy, increase the derivative filter time constant.

Example:

pid.setDerivativeFilter(0.5);

3. Add Integral Action

Only after P and D behave well should Ki be introduced.

Example:

pid.setTunings(
    Kp,
    Ki,
    Kd);

Use a small Ki.

The purpose of the integral term should primarily be to remove the remaining steady-state error.

For slow systems it is recommended to combine integral action with:

pid.setIntegralActivationRange(...);

This prevents the integral term from accumulating excessively while the process is still far away from the setpoint.


4. Configure the Integral Tolerance

Example:

pid.setTolerance(2);

This freezes the integral term within ±2 % of the setpoint.

P and D remain active.

This avoids unnecessary integral activity around the target value.


5. Add Slew-Rate Limiting if Necessary

Example:

pid.setOutputSlewRate(150.0);

Use the slew-rate limiter when the actuator or process reacts too aggressively to large controller output changes.

The slew-rate limiter should not be used as a replacement for correct PID tuning. It is an additional constraint on actuator dynamics.


Example Integral Behavior

Assume:

Setpoint                  = 100
Integral activation range = 10
Tolerance                 = 2 %

Then the integral term behaves approximately as follows:

Actual value          Integral behavior

< 90                  Disabled
90 ... 97             Active
98 ... 102            Frozen
103 ... 110           Active
> 110                 Disabled

P and D remain active over the entire range.


Clone this wiki locally