Vous êtes sur la page 1sur 13

Embedded PID Temperature Control, Part 6:

Ziegler–Nichols Tuning
March 07, 2016 by Robert Keim (/author/robert-keim)

In this article we will use a simple, proven tuning procedure


to find effective values for proportional, integral, and
derivative gain.
Supporting Information
• This project makes use of a custom-designed PCB; please refer to
Custom PCB Design with an EFM8 Microcontroller
(https://www.allaboutcircuits.com/projects/custom-pcb-design-with-an-
efm8-microcontroller/) for guidance on incorporating EFM8 devices into
your custom hardware.
• You can find a brief overview of thermocouples along with some general
information about the MAX31855 in Make an EFM8-Based System for
Monitoring and Analyzing Thermocouple Measurements
(https://www.allaboutcircuits.com/projects/efm8-based-system-for-
monitoring-and-analyzing-thermocouple-measurements/).
• An Introduction to Control Systems: Designing a PID Controller Using
MATLAB’s SISO Tool (https://www.allaboutcircuits.com/technical-
articles/an-introduction-to-control-systems-designing-a-pid-controller-
using-matlabs/)
• Negative Feedback, Part 1: General Structure and Essential Concepts
(https://www.allaboutcircuits.com/technical-articles/negative-feedback-
part-1-general-structure-and-essential-concepts/)
• This article (https://www.allaboutcircuits.com/projects/displaying-
characters-on-an-lcd-with-an-efm8-microcontroller/) introduces Scilab.
• Two previous articles provide information on incorporating USB
communication into an EFM8 project: Communicating with an EFM8
Microcontroller via USB
(https://www.allaboutcircuits.com/projects/communicating-with-an-efm8-
microcontroller-via-usb/) and EFM8 Sound Synthesizer: Playing
Melodies via USB (https://www.allaboutcircuits.com/projects/efm8-
sound-synthesizer-playing-melodies-via-usb/).
Previous Articles in This Series
• Embedded PID Temperature Control, Part 1: The Circuit
(https://www.allaboutcircuits.com/projects/embedded-pid-temperature-
control-part-1-the-circuit/)
• Embedded PID Temperature Control, Part 2: Board-Level Integration
(https://www.allaboutcircuits.com/projects/embedded-pid-temperature-
control-part-2-board-level-integration/)
• Embedded PID Temperature Control, Part 3: Implementation and
Visualization (https://www.allaboutcircuits.com/projects/embedded-pid-
temperature-control-part-3-implementation-and-visualization/)
• Embedded PID Temperature Control, Part 4: The Scilab GUI
(https://www.allaboutcircuits.com/projects/embedded-pid-temperature-
control-part-4-the-scilab-gui/)
• Embedded PID Temperature Control, Part 5: Adjusting Gains
(https://www.allaboutcircuits.com/projects/embedded-pid-temperature-
control-part-5-adjusting-gains/)

Before we get started, here is the PID control system diagram presented
previously:

And here are PID-related portions of the schematic:


The Limitations of Guess-and-Check
In the previous article we employed some basic system analysis followed by
crude experimentation to determine workable PID gain parameters. The
resulting performance was quite good—but then again, we only tested the
system with one specific control task, so we don’t know much about what the
controller might do under different operating conditions. We also don’t know
how much better the performance could be. It’s all well and good to be
satisfied when you see adequate performance, but what if the system could
be significantly improved simply by changing the gain values? The guess-
and-check approach is also rather impractical, or at least tiresome. The
process was time-consuming even with this little experimental temperature
controller—what would you do if each control run took an hour instead of a
few minutes? My point here is that efficient, effective PID tuning is an
essential part of control-system design.

It should come as no surprise that the people designing jet fighters and Mars
rovers need something way better than guess-and-check. Sophisticated PID
software packages or simulation environments are probably the method of
choice for most modern control systems; we, on the other hand, will use a
simple, time-tested technique known as the Ziegler–Nichols method.

Ziegler–Nichols
This procedure was first described in a paper published in 1942—credit to
Ziegler and Nichols for coming up with a tuning method that has survived
almost 75 years of overwhelming technological development. The process
starts with a proportional-gain-only system. You increase the P gain until the
system exhibits oscillations that are sustained (i.e., stable in terms of
amplitude) and regular (i.e., stable in terms of period); the oscillation does not
need to be centered around the setpoint. This is the only tiresome part of the
Ziegler–Nichols method. The rest is just math.

Once you have sustained, regular oscillation, you record the proportional gain
and measure the oscillation period. These values are referred to as the
ultimate gain (KU) and the ultimate period (PU), respectively. Now you
calculate KP, KI, and KD according to the following table:

KP TI

P-only control KU/2


PI control KU/2.2 PU/1.2

PID control KU/1.7 PU/2

Note that the integral and derivative columns are labeled TI and TD instead of
KI and KD. These “T” variables refer to the time constant used when
calculating the integral or derivative. For our discrete-time controller, we use
the following relationships to determine KI and KD:

KI = KP ( ) KD = KP ( )
T TD
TI T
where T is the PID interval, i.e., the amount of time between successive
executions of the routine that calculates the PID output and updates the
control circuitry. The current version of our temperature controller uses a PID
interval of 2 seconds.

Seeking Oscillation
So first we need to find the ultimate gain and period. Feedback systems often
burden engineers with the problem of preventing oscillation; there is
something relaxing about encouraging oscillation and even feeling a sense of
satisfaction when it occurs with sufficient regularity.

In the previous article we saw that a P-only system with KP = 70 does not
produce stable oscillation:
So let’s increase KP to 90 and see what happens.

This is looking better, but the amplitude of the oscillations clearly decreases
over time. Let’s try KP = 100:
I would consider this borderline. The oscillations are regular but not quite
sustained (the decreasing amplitude is not really apparent until the last three
cycles). Here’s KP = 110:

This looks good to me. I don’t notice any significant irregularity or reduction in
amplitude. So we will say that the ultimate gain is 110.

KP for sustained, regular oscillation is 110 ⇒ KU = 110


As indicated in the following plot, the ultimate period is about 55 seconds.

TU = 55 seconds
Calculations
The first table shows the Ziegler–Nichols values for the proportional gain,
integral time constant, and derivative time constant assuming KU = 110 and
TU = 55 seconds. The second table has gain values instead of time constants
for the integral and derivative terms, assuming that the PID interval is 2
seconds. All values in the second table are rounded to the nearest integer;
these are the values that we will actually use in the system, which does not
support non-integer gains.

KP TI

P-only control 55

PI control 50 45.8

PID control 64.7 27.5

KP KI KD
P-only control 55

PI control 50 2

PID control 65 5 223

Results
We will compare the performance of different system configurations based on
convergence time, which we will define as follows: the interval between the
time at which the measured temperature first reaches the setpoint and the
time at which the measured temperature remains directly on top of or
immediately adjacent to the setpoint line. (This convergence criterion
corresponds to a range of about 1°C above or below the setpoint
temperature.) We want the interval to begin when the measured temperature
first reaches the setpoint (rather than at the beginning of the control run)
because this should minimize errors associated with variations in the initial
system state (the dominant concern being variations in the measured
temperature at the beginning of the control run).

First let’s look at the Ziegler–Nichols P-only system:


Unsurprisingly, this system doesn’t even converge. There’s only so much you
can do with a P-only system.

Vous aimerez peut-être aussi