SENI
KECANTIKAN & KESEJAHTERAAN
KRAFTANGAN
BUDAYA & SEJARAH
HIBURAN
ALAM SEKITAR
MAKANAN & MINUMAN
KEJURUTERAAN TERBALIK
SAINS
SUKAN
TEKNOLOGI
WEARABLES
PID and Ziegler-Nichols Tuning
Emma

Dicipta oleh

Emma

31. Ogos 2026SE
1
0
0
0
0

PID and Ziegler-Nichols Tuning

The three terms answer three different questions about the same error. Proportional asks how wrong am I - it acts at once and always leaves some error behind, because zero error would mean zero output. Integral asks how long have I been wrong - it keeps pushing until the error is gone, and it is the only cure for the droop Maxwell described in 1868. Derivative asks how fast is it changing - it is Sperry's rate term, damping the loop. None of that was new in 1942. What John Ziegler and Nathaniel Nichols contributed at Taylor Instrument was a way to SET them without knowing anything about the process. Turn the proportional gain up, with the other two at zero, until the plant oscillates steadily; call that gain Ku and time the swings to get Tu. Then read six numbers off a table: for a full three-term controller, Kp is 0.6 Ku, the integral time is Tu over 2 and the derivative time is Tu over 8. A plant engineer with a stopwatch and no model could tune a loop in an afternoon, and eighty years later most of the loops running in the physical world were still set that way. It is worth knowing what the table is aiming at, because it is aggressive. Ziegler and Nichols targeted quarter-amplitude damping - each swing a quarter of the one before - which recovers from an upset quickly and overshoots hard on the way. That is right for a process that must shrug off disturbances and quite wrong wherever overshoot is expensive, so every handbook since has published gentler variants of the same six numbers. Two things the equation does not mention will decide whether your loop works. The derivative term differentiates the sensor's noise as happily as the signal, and the integral term keeps accumulating while the heater is already flat out - which is why a controller without anti-windup is not a PID controller but a PID controller with a fault.
Pertengahan
4 hours

Arahan

1

A plant with a real dead time

Bolt a 10 W power resistor to one end of a short aluminium bar and press the thermistor into a hole at the other end, with a smear of thermal paste in both. That gap is the point. Switch the heater on and time how long it takes the thermistor to move at all - several seconds of pure dead time, which is what makes this loop hard and what a bare thermistor on the resistor would hide.

Bahan untuk langkah ini:

Aluminum Bar StockAluminum Bar Stock150 mm
Power Resistor Kit - 10W (25 pack)Power Resistor Kit - 10W (25 pack)1 kit
NTC Thermistor Kit (50pcs, 10 Values)NTC Thermistor Kit (50pcs, 10 Values)1 kit
Thermal Paste (Arctic Silver, 3.5g)Thermal Paste (Arctic Silver, 3.5g)1 tube

Alatan diperlukan:

Cordless DrillCordless Drill
StopwatchStopwatch
Digital Multimeter (Lab Grade)Digital Multimeter (Lab Grade)
Bench Power Supply (30V/5A)Bench Power Supply (30V/5A)
2

The controller, with the two lines nobody mentions

One constant selects on/off, P, PI or PID; the gains come from Ku and Tu through the Ziegler-Nichols table. Measure Ku and Tu on YOUR block first - raise Kp with the other terms at zero until the temperature swings steadily, then time it. Run all four modes and you have the notebook's table in your own hardware.
pid_heater.inocpp
// A PID temperature loop, with the two things every textbook leaves out:
// integral anti-windup, and a derivative that does not scream at the sensor noise.
//
// Hardware: a 10 W power resistor bolted to a small aluminium block, driven by a logic-level
// MOSFET from a PWM pin; a 10k NTC thermistor in the block with a 10k series resistor to A0.
// The block is the plant, and it has exactly the two features that make control interesting:
// a long time constant (the block's heat capacity) and a DEAD TIME (heat takes seconds to
// reach the thermistor from the resistor).
//
// Set MODE to run the same rig as an on-off controller, a P, a PI or a PID, and read the
// four rows of the notebook's table off your own hardware.

const int PIN_HEATER = 9;      // PWM to the MOSFET gate
const int PIN_TEMP   = A0;     // thermistor divider

// 0 = on/off   1 = P only   2 = PI   3 = PID
const int MODE = 3;

// Ziegler-Nichols starts by finding these two on YOUR block. Raise KP with KI and KD at
// zero until the temperature oscillates steadily; that KP is Ku and the period is Tu.
const float Ku = 12.0;         // <-- measure this
const float Tu = 40.0;         // <-- and this, in seconds

const float SETPOINT = 45.0;   // degrees C - warm, safe, and far above the room
const float DT       = 0.5;    // seconds per loop
const float OUT_MAX  = 255.0;
const float N_FILTER = 8.0;    // derivative filter: limits the D gain to N times the P gain

float integral = 0.0, dFilt = 0.0, prevMeas = 0.0;
unsigned long tPrev = 0;

float readTempC() {
  // 10k NTC, beta 3950, in a divider with a 10k fixed resistor to 5 V.
  int raw = analogRead(PIN_TEMP);
  float r = 10000.0 * raw / (1023.0 - raw);
  float invT = 1.0/298.15 + log(r/10000.0)/3950.0;
  return 1.0/invT - 273.15;
}

void setup() {
  Serial.begin(115200);
  pinMode(PIN_HEATER, OUTPUT);
  Serial.println(F("t_s,temp_C,output,integral"));
  prevMeas = readTempC();
  tPrev = millis();
}

void loop() {
  if (millis() - tPrev < (unsigned long)(DT * 1000)) return;
  tPrev = millis();

  float meas  = readTempC();
  float error = SETPOINT - meas;

  // Ziegler-Nichols, ultimate-sensitivity method (1942).
  float Kp = 0.0, Ti = 1e9, Td = 0.0;
  if      (MODE == 1) { Kp = 0.50*Ku; }
  else if (MODE == 2) { Kp = 0.45*Ku; Ti = Tu/1.2; }
  else if (MODE == 3) { Kp = 0.60*Ku; Ti = Tu/2.0; Td = Tu/8.0; }

  float out;
  if (MODE == 0) {
    out = (meas < SETPOINT) ? OUT_MAX : 0.0;         // on/off, no gains at all
  } else {
    // Derivative on the MEASUREMENT, not the error: a setpoint change then does not
    // produce an infinite spike, and the sign works out the same for a disturbance.
    float dMeas = (meas - prevMeas) / DT;
    dFilt += (dMeas - dFilt) * (DT / (Td/N_FILTER + DT));
    float unclamped = Kp*error + Kp/Ti*integral - Kp*Td*dFilt;

    out = constrain(unclamped, 0.0, OUT_MAX);
    // ANTI-WINDUP: only accumulate while the actuator has somewhere to go. Without this
    // the integral fills up during the first slow warm-up and the block sails 15 degrees
    // past the setpoint before the term unwinds.
    if (unclamped == out) integral += error * DT;
  }
  prevMeas = meas;

  analogWrite(PIN_HEATER, (int)out);

  Serial.print(millis()/1000.0, 1); Serial.print(',');
  Serial.print(meas, 2);            Serial.print(',');
  Serial.print(out, 0);             Serial.print(',');
  Serial.println(integral, 1);
}

Bahan untuk langkah ini:

IRF540N N-Channel MOSFET (10-Pack)IRF540N N-Channel MOSFET (10-Pack)1 bungkus
1/4W Resistor Kit (600pcs, 30 Values)1/4W Resistor Kit (600pcs, 30 Values)1 kit
Dupont Jumper Wire Set (M-F, 40-Way)Dupont Jumper Wire Set (M-F, 40-Way)1 set

Alatan diperlukan:

Arduino Uno R3 SMDArduino Uno R3 SMD
Breadboard - ClassicBreadboard - Classic
Desktop ComputerDesktop Computer
Bench Power Supply (30V/5A)Bench Power Supply (30V/5A)
3

Ku, Tu, the table, and four controllers compared

Loading Jupyter Notebook...

Alatan diperlukan:

Desktop ComputerDesktop Computer
4

Compendium: the other method, and what Ku costs to find

Ziegler and Nichols published two methods and the one everybody quotes is the harder one to use. Finding Ku means deliberately driving a live process into sustained oscillation, which on a chemical plant, a furnace or anything with a safety case is not a reasonable thing to do. Their open-loop method avoids it entirely: put a step into the plant with the controller off, draw a tangent at the steepest point of the response curve, and read off the apparent dead time L and the slope R. The gains follow from those two numbers alone - for a PID, Kp is 1.2 over R L, the integral time is 2 L and the derivative time is 0.5 L - and the plant is never asked to misbehave. Both methods are really estimating the same thing, which is how much phase the plant spends before its gain runs out. That is Nyquist's question from ten years earlier, and the ultimate-sensitivity experiment measures the answer directly: at the point of steady oscillation the loop gain is exactly one and the phase exactly minus 180 degrees, so Ku and Tu ARE the coordinates of the critical point. The 1942 table is Nyquist's criterion reformulated as something you can do with a knob and a stopwatch, which is why it spread through industries that never read the 1932 paper.

Alatan diperlukan:

Notebook and PencilNotebook and Pencil

Bahan

7

Alatan Diperlukan

8
Jumlah anggaran
$6.00

CC0 Domain Awam

Blueprint ini dikeluarkan di bawah CC0. Anda bebas menyalin, mengubah, mengedar, dan menggunakan karya ini untuk sebarang tujuan, tanpa meminta kebenaran.

Sokong Pembuat dengan membeli produk melalui Blueprint mereka di mana mereka memperoleh Komisen Pembuat ditetapkan oleh Penjual, atau cipta iterasi baru Blueprint ini dan sertakan ia sebagai sambungan dalam Blueprint anda sendiri untuk berkongsi hasil.

Perbincangan

(0)

Log masuk untuk menyertai perbincangan

Memuatkan komen...