ENع
→What control is
الدرس 01 · What control is

What a control system is

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

12 دقيقة11 خطوة5 أسئلةBeginner
عن هذا الدرس

A control system keeps something where you want it without a person watching. Follow one room and one heater: first with the heater fixed at a power worked out in advance (open loop), then with a thermometer feeding the temperature back to a three-line Python rule (closed loop). A cold snap shows why feedback is worth the trouble.

ستتعلّم

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

شكل 1 · تفاعلي
01 / 11

Keep a room at 20 °C

A control system makes something behave the way we want, on its own, with nobody watching. Our job: keep a room at 20 °C while it is 10 °C outside. The value we ask for is the goal, also called the setpoint.

goal (setpoint)   20 °C
outside           10 °C
room right now    10 °C

A control system = something that keeps an
output where we ask, without a person
adjusting it by hand.
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Keep a room at 20 °C

    A control system makes something behave the way we want, on its own, with nobody watching. Our job: keep a room at 20 °C while it is 10 °C outside. The value we ask for is the goal, also called the setpoint.

    goal (setpoint)   20 °C
    outside           10 °C
    room right now    10 °C
    
    A control system = something that keeps an
    output where we ask, without a person
    adjusting it by hand.
  2. The plant and its output

    The thing being controlled is called the plant; here it is the room. The quantity we care about, its temperature, is the output. Right now the room is 10 °C, as cold as outside.

    plant    the room
    output   room temperature, 10 °C now
    
    The room loses heat through its walls.
    The warmer it is than outside, the faster
    it loses heat. Time constant 40 min:
    about how long it takes to get two-thirds
    of the way to where it is heading.
  3. The heater is our handle

    We cannot set a temperature directly. We can only choose how hard the heater works, from 0 to 3 kW. The part that pushes on the plant is the actuator, and its setting is the plant's input.

    actuator   electric heater, 0 to 3 kW
    input      heater power (kW)
    output     room temperature (°C)
    
    Every kW held long enough warms the
    room 7.5 °C above the outside.
  4. Open loop: set and forget

    We work out once that 1.33 kW holds 20 °C on a 10 °C day and fix the heater there. The controller, the part that decides the heater power, never looks at the room. That is open-loop control. After three hours: 19.9 °C.

    # open loop: the power is decided once
    import math
    TAU, R = 40, 7.5        # min, °C per kW
    temp, power, dt = 10.0, 1.33, 0.1
    for n in range(1800):        # 180 min
        target = 10.0 + R * power
        temp = target + (temp - target) * math.exp(-dt / TAU)
    print(round(temp, 1))        # 19.9
  5. A cold snap

    At three hours the outside drops to 4 °C. Nothing tells the controller, so the heater stays at 1.33 kW and the room slides down to 14.1 °C. A change nobody asked for, like this one, is a disturbance.

    t = 180 min   outside 10 °C → 4 °C
    heater           still 1.33 kW
    room at 360 min  14.1 °C (heads for 14.0 °C)
    
    Open loop only works if the world stays
    exactly as we assumed when we set it.
  6. Measure the output

    Start again, and this time add a thermometer, the sensor. It measures the room and sends the reading back to the controller. That path backwards, from the output to the controller, is feedback. It closes the loop.

    sensor     thermometer in the room
    reading    10.0 °C → controller
    
    feedback   the output is measured and
               sent back to the controller
    closed loop  goal → controller → heater
                 → room → sensor → controller
  7. Compare: the error

    The controller subtracts the reading from the goal. The difference is the error: 20 − 10 = +10 °C. A positive error means too cold, a negative one too warm, and zero means spot on.

    error = goal - temp
          = 20.0 - 10.0
          = +10.0 °C   (too cold)
    
    error > 0   too cold
    error < 0   too warm
    error = 0   on target
  8. Act on the error

    Our rule: 5 kW of heat for every °C of error, kept between 0 and 3 kW. An error of 10 °C asks for 50 kW, more than the heater has, so it runs flat out at 3 kW.

    power = 5 * error         # 5 × 10 = 50 kW
    power = min(max(power, 0), 3)  # → 3 kW
    
    The bigger the error, the harder the
    heater works. This rule is called
    proportional control.
  9. Round and round

    Measure, compare, act, every six seconds. As the room warms, the error shrinks and the heater eases off. The room passes 19 °C after 21 minutes and settles at 19.7 °C, where 1.3 kW balances the heat lost.

    # closed loop: decide again every 0.1 min
    import math
    TAU, R, goal = 40, 7.5, 20.0
    temp, dt = 10.0, 0.1
    for n in range(1800):        # 180 min
        error = goal - temp      # compare
        power = min(max(5 * error, 0), 3)
        target = 10.0 + R * power
        temp = target + (temp - target) * math.exp(-dt / TAU)
    print(round(temp, 1))        # 19.7
  10. Feedback fights the cold

    The same cold snap hits at three hours. The error grows a little, so the heater turns itself up to 2.1 kW. The room settles at 19.6 °C. Open loop fell to 14.1 °C.

    t = 180 min   outside 10 °C → 4 °C
    
                 open loop   closed loop
    heater       1.33 kW     1.3 → 2.1 kW
    room at 360   14.1 °C     19.6 °C
    
    Nobody told the controller about the
    weather: the thermometer did.
  11. Why it is worth the trouble

    Feedback cost us a sensor and a rule, and it still leaves a small error (0.4 °C). In return it corrects for changes nobody predicted. Cruise control, autopilots and your body's temperature all work round this loop.

    feedback costs   a sensor, a rule, wiring
    it gives          corrects disturbances
                      nobody predicted
    still left        error 0.4 °C (later lessons
                      show how to remove it)
    
    open loop  14.1 °C   closed loop  19.6 °C

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