ENع
→Oven temperature
الدرس 52 · Control in the real world

Temperature control of an oven

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

18 دقيقة10 خطوات5 أسئلةAdvanced
عن هذا الدرس

One whole design, start to finish: measure an oven with a bump test, read its gain, dead time and time constant, tune a PID with the Ziegler-Nichols reaction-curve rule, then meet the problems real hardware adds. A heater that cannot cool and integrator windup turn a textbook design into a 262 °C overshoot; one extra line of Python fixes it.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 52 · تفاعلي
01 / 10

Hold an oven at 180 °C

The job: bring an oven from 20 °C to 180 °C and keep it there. Our only handle is a heater that gives 0 to 2.5 kW. It can heat but never cool. A thermocouple, the sensor, reads the temperature.

setpoint    180 °C
oven now    20 °C (room temperature)
heater      0 to 2.5 kW, heats only
sensor      thermocouple inside the oven

The design, in order:
  1. measure a model of the oven
  2. tune a controller from the model
  3. fix the problems the real parts add
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Hold an oven at 180 °C

    The job: bring an oven from 20 °C to 180 °C and keep it there. Our only handle is a heater that gives 0 to 2.5 kW. It can heat but never cool. A thermocouple, the sensor, reads the temperature.

    setpoint    180 °C
    oven now    20 °C (room temperature)
    heater      0 to 2.5 kW, heats only
    sensor      thermocouple inside the oven
    
    The design, in order:
      1. measure a model of the oven
      2. tune a controller from the model
      3. fix the problems the real parts add
  2. The bump test

    We have no equation for the oven, so we measure one. With no controller, we fix the heater at 1 kW and record the temperature for an hour. This open-loop experiment is called a bump test or step test.

    heater fixed     1 kW from t = 0
    oven at 16 min   89.5 °C
    oven at 60 min   127.8 °C (still creeping up)
    
    The curve is the oven's step response:
    what any model we fit must reproduce.
  3. Read three numbers

    Gain K: 1 kW would end 110 °C up, so K = 110 °C/kW. Dead time θ: nothing moves for 1 minute. Time constant τ: 63 % of the rise comes 15 minutes after that. Model: G(s) = 110e^(−s)/(15s + 1).

    gain        K = 110 °C per kW   (final rise / power)
    dead time   θ = 1 min           (flat start)
    time const  τ = 15 min          (63.2 % point at θ + τ = 16 min:
                                     20 + 0.632 × 110 = 89.5 °C)
    
             110 e^(−1·s)
    G(s) = ─────────────
               15s + 1
    
    The hour stops short of the final 130 °C. By θ + 4τ
    the curve is 98 % of the way there, so the
    final value is read where it levels off.
    
    held at 180 °C needs (180 − 20) / 110 = 1.45 kW
  4. First try: a thermostat

    Suppose our thermostat just switches: full heat below 178 °C, off above 182 °C. The dead time spoils it. Each switch acts a minute late, so the oven keeps swinging between 167.8 and 189.3 °C.

    on below 178 °C, off above 182 °C
    swing after warm-up   167.8 to 189.3 °C
    
    Why so wide: in the 1 min dead time the
    oven keeps heating at about 7.7 °C/min
    and cools at about 10.7 °C/min, long after
    the switch has flipped.
  5. Tune a PID from the model

    Ziegler and Nichols turned the bump-test numbers into PID settings: Kp = 1.2τ/(Kθ) = 0.164 kW per °C, Ti = 2θ = 2 min, Td = 0.5θ = 0.5 min. The rule is a known starting point, not a final answer.

    Ziegler-Nichols, reaction-curve method (PID)
      Kp = 1.2 τ / (K θ) = 1.2 × 15 / (110 × 1) = 0.164 kW/°C
      Ti = 2 θ          = 2 min
      Td = 0.5 θ        = 0.5 min
    
    A PID adds three terms: P reacts to the error
    now, I to the error added up over time, D to how
    fast the temperature is changing. Kp is the gain,
    Ti the integral time, Td the derivative time.
    The lesson "The PID controller" teaches them.
    
    power = Kp (e + ∫e dt / Ti − Td dT/dt)
    
    The D term uses the measured temperature,
    not the error, so a setpoint jump gives
    no kick.
  6. Run it: a huge overshoot

    Start from cold. The oven reaches 180 °C after 14.1 minutes, then keeps climbing to 262.6 °C at 33.1 minutes. Any cake inside is ruined. The model was right and the rule is standard, so what went wrong?

    import math
    K, TAU, LAG, DT = 110, 15, 100, 0.01   # °C/kW, min, steps of dead time, min
    a = math.exp(-DT / TAU)
    def oven(temp, power_then):       # one 0.6 s step
        target = 20 + K * power_then
        return target + (temp - target) * a
    Kp, Ti, Td = 1.2 * TAU / (K * 1), 2.0, 0.5   # Ziegler-Nichols
    temp, last, I, queue, peak = 20.0, 20.0, 0.0, [0.0] * LAG, 0.0
    for n in range(4001):              # 40 min
        e, dT = 180 - temp, (temp - last) / DT
        I += e * DT
        power = min(max(Kp * (e + I / Ti - Td * dT), 0), 2.5)
        queue.append(power); last = temp
        temp = oven(temp, queue.pop(0)); peak = max(peak, last)
    print(round(peak, 1))             # 262.6
  7. Integrator windup

    All through the warm-up the PID asked for far more than 2.5 kW, so the heater sat at its limit. The integral kept adding up error anyway. At 180 °C it alone still asks for 86.5 kW. That is integrator windup.

    at t = 14.1 min the oven first reaches 180 °C
      error        0 °C
      integral     Kp·I/Ti = 86.5 kW
      heater       stays at 2.5 kW until 32.1 min
    
    The integral piled up error during the
    warm-up that the heater could not act on.
    It must unwind before the heater eases off.
  8. An oven cannot cool

    Too hot, the best the heater can do is switch off; it cannot pull heat out. It sits at 0 kW for 10.8 minutes while the oven loses heat through its walls, and is back under 185 °C only at 39.1 minutes.

    peak             262.6 °C at 33.1 min
    heater off       from 32.4 min, for 10.8 min
    under 185 °C      at 39.1 min
    
    A one-sided actuator: overshoot costs
    time, because the only way down is the
    oven's own heat loss.
  9. Fix: clamp the integral

    Same gains, one new line: add to the integral only while the heater is not at a limit. Now the warm-up peaks at 182.1 °C and stays within 1 °C of 180 °C after 17.4 minutes.

    import math
    K, TAU, LAG, DT = 110, 15, 100, 0.01   # °C/kW, min, steps of dead time, min
    a = math.exp(-DT / TAU)
    def oven(temp, power_then):       # one 0.6 s step
        target = 20 + K * power_then
        return target + (temp - target) * a
    Kp, Ti, Td = 1.2 * TAU / (K * 1), 2.0, 0.5   # Ziegler-Nichols
    temp, last, I, queue, peak = 20.0, 20.0, 0.0, [0.0] * LAG, 0.0
    for n in range(4001):              # 40 min
        e, dT = 180 - temp, (temp - last) / DT
        u = Kp * (e + I / Ti - Td * dT)
        power = min(max(u, 0), 2.5)
        if u == power: I += e * DT   # clamp
        queue.append(power); last = temp
        temp = oven(temp, queue.pop(0)); peak = max(peak, last)
    print(round(peak, 1))             # 182.1
  10. Someone opens the door

    At 40 minutes the door opens for one minute and lets out heat, modelled as 2 kW. The oven dips to 165.8 °C. The PID goes to full power and is back within 1 °C 6.1 minutes after opening.

    door open        t = 40 to 41 min, losing 2 kW
    lowest           165.8 °C
    within 1 °C       6.1 min after opening
    
    The integral then settles back to the
    1.45 kW that holds 180 °C: no steady error,
    for any loss the heater can still make up.

اختبار يتاح بعد الخطوة الأخيرة.