ENع
→Open vs closed loop
الدرس 02 · What control is

Open loop versus closed loop

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

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

Fill a tank with exactly 100 litres, two ways. An open-loop controller works out a timer in advance from the label on the valve; a closed-loop controller watches a level gauge and acts on the error. On a low-pressure day the timer stops 20 litres short, while feedback still reaches 100. Then weigh what each one costs.

ستتعلّم

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

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

Fill a tank to 100 litres

A controller can decide what to do in two ways: from the goal alone, or from the goal plus a measurement of the result. We compare both on one job: fill an empty tank with exactly 100 litres.

goal (setpoint)   100 L
tank right now    0 L

Two ways to decide:
  open loop    from the goal alone
  closed loop  from the goal AND a
               measurement of the result
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Fill a tank to 100 litres

    A controller can decide what to do in two ways: from the goal alone, or from the goal plus a measurement of the result. We compare both on one job: fill an empty tank with exactly 100 litres.

    goal (setpoint)   100 L
    tank right now    0 L
    
    Two ways to decide:
      open loop    from the goal alone
      closed loop  from the goal AND a
                   measurement of the result
  2. The valve is our handle

    The tank is the plant and the volume of water is its output. The valve is the actuator, fed by the water supply. The label on the valve says that, wide open, it passes 10 litres per minute.

    plant      the tank
    output     volume of water (L)
    actuator   the valve
    input      flow through the valve (L/min)
    
    label on the valve: 10 L/min wide open
    The tank only fills: no outlet, no leak.
    
    (These words are introduced in the lesson
    "What a control system is".)
  3. Open loop: plan in advance

    The open-loop controller does the sum before it starts: 100 L ÷ 10 L/min = 10 minutes. It opens the valve, runs a timer and shuts the valve at 10 minutes. It uses the goal and the label, and nothing else.

    t_stop = 100 / 10  →  10 min
    
    The plan rests on a model of the plant:
    "the valve gives 10 L/min".
    
    open loop: the action is worked out from
    the goal alone, before anything happens.
  4. When the model is right

    On a normal day the valve really does pass 10 L/min. After 10 minutes the timer shuts it with 100.0 litres in the tank. Open loop is simple, cheap and exact, as long as its model is right.

    # open loop: a timer, decided in advance
    flow, dt = 10.0, 0.05      # L/min, min
    t_stop = 100 / 10
    vol = 0.0
    for n in range(360):        # 18 min
        t = n * dt
        if t < t_stop - 1e-9:
            vol += flow * dt
    print(round(vol, 1))        # 100.0
  5. When the model is wrong

    Today the water pressure is low and the open valve only passes 8 L/min. The timer still shuts it at 10 minutes: 80.0 litres, 20.0 L short. Nothing tells the controller, because it never reads the tank.

    supply today   8 L/min (label says 10)
    timer          still 10 min
    tank at 18     80.0 L, 20.0 L short
    
    Open loop cannot correct what it does
    not measure. A toaster is the same: it
    heats for a set time and never looks at
    the colour of the toast.
  6. Measure the result

    Start again with an empty tank, and add a level gauge: the sensor. It reads how much water is in the tank and sends that back to the controller. That return path is feedback, and it closes the loop.

    sensor     level gauge on the tank
    reading    0.0 L → controller
    
    feedback   the output is measured and
               sent back to the controller
    closed loop  goal → controller → valve
                 → tank → gauge → controller
  7. Decide from the error

    The controller works out the error: goal minus reading, 100 − 0 = 100 litres missing. It asks for 1 L/min for every litre missing. 100 L/min is more than the valve can give, so it opens wide.

    error = 100 - level        # 100 - 0 = 100 L
    ask   = 1.0 * error      # 100 L/min
    valve gives min(ask, 10)  # → 10 L/min
    
    lots missing  → valve wide open
    little missing → valve nearly shut
    nothing missing → valve shut
  8. Slow down near the top

    Measure, compare, act, every three seconds. Below 90 litres the valve stays wide open. After that the error is small, so the valve eases shut. The tank holds 99 litres at 11.3 minutes and ends at 100.0 litres.

    # closed loop: decide again every 0.05 min
    goal, max_flow, dt = 100.0, 10.0, 0.05
    vol = 0.0
    for n in range(360):        # 18 min
        error = goal - vol      # compare
        ask = max(1.0 * error, 0)
        vol += min(ask, max_flow) * dt
    print(round(vol, 1))        # 100.0
  9. Low pressure again

    Same low-pressure day, 8 L/min. The valve stays open longer because the gauge still shows litres missing. The tank holds 99 litres at 13.6 minutes instead of 11.3, and still ends at 100.0 litres.

    # same loop, weaker supply
    goal, max_flow, dt = 100.0, 8.0, 0.05
    vol = 0.0
    for n in range(360):
        ask = max(1.0 * (goal - vol), 0)
        vol += min(ask, max_flow) * dt
    print(round(vol, 1))        # 100.0
  10. Which one to use

    Open loop needs no sensor, so it is simpler and cheaper: fine for a toaster or a washing-machine timer. Closed loop costs a sensor and a rule, but it ended at 100.0 litres on the bad day; open loop stopped at 80.0.

                 open loop       closed loop
    decides from goal only       goal − measured
    needs        a good model    a sensor
    low pressure 80.0 L          100.0 L
    cost         lower           higher
    
    The cistern of a flush toilet is closed
    loop: a float valve shuts the inflow as
    the water rises.

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