Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 36 ยท Controllers

Fuzzy Control Compared with PID Control

Compare a fuzzy controller with a PID controller on the same delayed heating plant: overshoot, settling time and error, and learn when each approach is the better choice.

PID control is the workhorse of industry. It is three terms added together, has decades of tuning rules and runs on the cheapest hardware. So why would you reach for fuzzy control? In this lesson you will run both controllers against the same plant, measure them with the same numbers, and learn an honest answer: sometimes fuzzy wins, sometimes PID wins, and often a mix is best.

What PID does in one minute

A PID controller computes its output from three parts of the error e = setpoint - measurement:

  • P (proportional): Kp * e, pushes in proportion to how far off you are.
  • I (integral): Ki * sum(e), accumulates past error so a small persistent error eventually causes a push (this removes steady-state error).
  • D (derivative): Kd * (e - e_previous), reacts to how quickly the error is changing and damps overshoot.

The output is a smooth formula with three numbers to tune. A fuzzy controller instead has a rule table and set shapes to tune; its output is a smooth but nonlinear function of the same inputs.

PID or fuzzy?

PID Three gains, a formula
Fuzzy Rules and set shapes
Both Same inputs, smooth output

Both are feedback controllers

1 / 2

A fair test bench

To compare, we need the same plant and the same measurements. The plant is the leaky room from the thermostat lesson with two extra problems controllers hate: a delay (the heater takes 3 minutes to show an effect) and a limit (power is clipped to 0 to 100 percent).

We measure three things on a step from 10 to 22 degrees:

  • Overshoot: how far the temperature goes above 22.
  • IAE (integral of absolute error): the sum of |setpoint - T| over the run; smaller is better.
  • Settling time: the last minute at which the temperature is more than 0.5 degrees from the target.
Python Fuzzy versus PID on a delayed room

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the numbers carefully. On the plant the PID was tuned for, it has no overshoot and the smallest IAE, while the fuzzy controller settles into the band sooner but overshoots by more than a degree. When the heater is half as strong, the PID slows down a lot because its gains were tuned for the old plant, while the fuzzy controller degrades less. Neither result is a law of nature: with more tuning effort you could improve either one. What the experiment shows is how each design behaves when the plant is not what you assumed.

Where each approach is stronger

Situation Better fit
Linear, well-modeled plant, tight performance spec PID (well-understood tuning, stability analysis)
Nonlinear plant, behavior changes with operating zone Fuzzy (different rules for different zones)
You have an experienced operator but no model Fuzzy (translate their advice into rules)
Tiny microcontroller, very fast loop PID (cheaper per cycle)
Safety certification that requires proofs PID or classic control (stability theory is mature)

Combining them

You do not have to choose. Common hybrids are:

  • Fuzzy PID gain scheduling: a fuzzy system adjusts Kp, Ki and Kd depending on the error size. Far from the target it uses large Kp and no integral; near the target it uses small Kp and a larger integral.
  • Fuzzy supervisor: a fuzzy layer watches the loop and switches between PID parameter sets.
  • Fuzzy PI plus D: the incremental fuzzy controller from the last lesson already behaves like a PI controller with nonlinear gains.

The next experiment sketches the first idea: choose Kp from the size of the error with two overlapping sets.

Python Fuzzy gain scheduling of Kp

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The gain rises smoothly from 2 to 6 as the error grows, with no switching glitch. Replacing a hard if error > 5 with overlapping sets is a typical use of fuzzy logic inside an otherwise classical design.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the integral term in PID do?

    The integral keeps pushing as long as any error remains, which removes steady-state error.
  2. 2. Which situation favors a fuzzy controller?

    Fuzzy rules can capture zone-dependent expert behavior without a model.
  3. 3. In our test, why did the PID slow down when the heater was weaker?

    A PID's gains encode an assumption about the plant gain; if the plant changes, performance changes.
  4. 4. What is a fuzzy gain scheduler?

    It uses fuzzy sets on the error to blend different gain values smoothly.

Summary

  • PID computes a formula from error, accumulated error and error change; fuzzy computes a nonlinear rule-based function of similar inputs.
  • Compare controllers on the same plant using overshoot, IAE and settling time.
  • Fuzzy often copes better with nonlinear or changing plants; PID is simpler and better understood where a linear model fits.
  • Hybrids (fuzzy gain scheduling, fuzzy supervisors) use both strengths.

Next: Tuning Fuzzy Controllers