4 Tuning the PID

To tune a PID system, there are two basic approaches; manual tuning and simulation. While simulation has a definite appeal, creating sufficiently accurate simulations is not a trivial task and well beyond the scope of this application note. Therefore, a manual tuning procedure is the only procedure that will be presented here.

There are several strategies for manual tuning of PID controllers. The following is a simple technique that usually produces reasonably stable results.

  • Connect a scope to the PWM output
  • Start with Kp, Ki and Kd at zero
  • Increase Kp until the system oscillates. This will appear as two overlapped pulses
  • Increase Kd until the oscillations stop
  • Increase Ki until the fan speed is within an acceptable tolerance desired
  • Switch the setpoint between the minimum and maximum speeds, at 30-40 second intervals
  • If the speed overshoots or undershoots, increase Kd until the system is critically damped
  • Increase Kp until the acquisition time is acceptable
  • If oscillation occurs, increase Kd until the oscillations stop
  • If necessary, tune Ki until the fan speed is back within the acceptable tolerance
  • Repeat 6-10 until response time, stability and speed tolerance are acceptable
Note: Different fans, ducting and power supply voltages will affect PID tuning. To determine the production values for Kp, Ki and Kd, tune multiple systems (different fans, power supplies, ducting) to establish a range for each of the constants and then chose values that will remain within the specification over the range of systems.

To tune the project, three 10k potentiometers were added to the design and connected to RC2, RC3 and RC4. Originally, they drove the Kp, Ki and Kd constants of the PID. After tuning, it was discovered that the Kd constant is not needed and, therefore, has no effect on the stability of the system. At that point, RC2 was redefined at the target speed. The lack of effect from the Kd constant is likely due to the uni-directional drive of the PWM, which can increase the speed. However, slowing is due to inertia and the load on the fan, so the derivative term does not have a means of actively slowing the speed of the fan. Subsequent discussions with a co-worker with experience in fan design indicated that the manufacturers of digitally controlled fans do not use the derivative term either.