ENع
←Parts of a loop
Lesson 03 · What control is

Parts of a loop: sensor, controller, actuator and plant

12 min10 steps5 questionsBeginner
About this lesson

Every feedback loop is built from the same four parts. Follow a car's cruise control round its loop: the wheel sensor measures the speed, a two-line Python controller compares it with the set speed and decides the throttle, the engine (the actuator) pushes, and the car (the plant) speeds up. Watch the signal change kind at every part, then see what happens when the sensor is wrong.

You'll learn to

Tick what you feel confident about. These self-checks do not affect your lesson score.

Fig 3 · Interactive
01 / 10

Hold 90 km/h on its own

Cruise control holds a car at the speed the driver sets. The driver dials in 25 m/s (90 km/h); the car is doing 20 m/s (72 km/h). Four parts share the work, and each has one job.

setpoint (goal)   25 m/s  = 90 km/h
car right now     20 m/s  = 72 km/h

m/s = metres per second.
Multiply by 3.6 to get km/h.

The four parts: plant, actuator,
sensor and controller.
Loading figure…
or ← →
Read the lesson step by step
  1. Hold 90 km/h on its own

    Cruise control holds a car at the speed the driver sets. The driver dials in 25 m/s (90 km/h); the car is doing 20 m/s (72 km/h). Four parts share the work, and each has one job.

    setpoint (goal)   25 m/s  = 90 km/h
    car right now     20 m/s  = 72 km/h
    
    m/s = metres per second.
    Multiply by 3.6 to get km/h.
    
    The four parts: plant, actuator,
    sensor and controller.
  2. The plant: the car

    The plant is the thing being controlled: the car. Its output is the quantity we care about, its speed. Its input is the push from the engine. With no push, air and tyres slow it down.

    plant    the car, 1200 kg
    input    push from the engine (newtons, N)
    output   speed (m/s)
    
    Drag here: 30 N for every m/s.
    At 20 m/s that is 600 N slowing it.
    Hold a push long enough and the speed
    settles at push ÷ 30.
  3. The actuator: the engine

    Nobody can set a speed directly. The engine is the actuator: it turns a throttle command, from 0 to 100 %, into a push on the car, from 0 to 3000 N. It is strong, but it has a limit.

    actuator   engine + throttle
    in         throttle command, 0 to 100 %
    out        push on the car, 0 to 3000 N
    
    push = 3000 N × throttle
    
    A newton (N) is a unit of force:
    about the weight of a small apple.
  4. The sensor: the wheel

    A sensor measures the output. Here a toothed ring turns with the wheel, and a sensor counts the teeth going past. More teeth per second means faster. The car's computer turns the count into a speed reading.

    sensor   wheel-speed sensor
    in       the real speed of the car
    out      a reading: 20.0 m/s
    
    reading = teeth per second
              ÷ teeth per turn
              × distance per wheel turn
  5. The controller compares

    The reading travels back to the controller. That trip is feedback, as in Open loop versus closed loop. The controller subtracts the reading from the setpoint: 25 − 20 = +5 m/s. That difference is the error. Positive means too slow.

    error = goal - reading
          = 25.0 - 20.0
          = +5.0 m/s   (too slow)
    
    error > 0   too slow, push harder
    error < 0   too fast, ease off
    error = 0   on target
  6. The controller decides

    Our rule: open the throttle 100 % for every 1 m/s of error, kept between 0 and 100 %. An error of 5 m/s asks for 500 %, so the command is full throttle. The controller only decides; the engine does the pushing.

    throttle = min(max(error, 0), 1)
             = min(max(5.0, 0), 1)
             = 1.0   → 100 %
    
    1 m/s or more too slow → full throttle.
    The closer the speed, the gentler.
    This is proportional control.
  7. Six signals, one loop

    Follow the loop and the signal changes kind at every part: setpoint (m/s), error (m/s), throttle command (%), push (N), speed (m/s), reading (m/s). Each part turns one kind of signal into the next.

    setpoint   25 m/s        driver → controller
    error      +5.0 m/s      inside the controller
    command    100 %         controller → engine
    push       3000 N        engine → car
    speed      20.0 m/s      the car's output
    reading    20.0 m/s      sensor → controller
    
    speed → reading → controller is feedback.
  8. Round and round

    Now the loop runs, 20 times a second. The engine stays at its limit, full throttle, for 2.1 s. Then the error shrinks and the throttle eases to 25 %. The car settles at 24.8 m/s.

    # the loop, 20 times a second, for 12 s
    import math
    m, c, F_MAX = 1200, 30, 3000
    goal, v, dt = 25.0, 20.0, 0.05
    for n in range(240):
        reading = v                       # sensor
        error = goal - reading            # controller
        throttle = min(max(error, 0), 1)
        push = F_MAX * throttle           # actuator
        target = push / c                 # plant
        v = target + (v - target) * math.exp(-dt * c / m)
    print(round(v, 1))                    # 24.8
  9. The loop trusts its sensor

    Now fit bigger tyres without telling the computer, so the sensor reads 10 % low. The loop holds the reading near the goal (24.7 m/s), so the car really does 27.5 m/s, about 99 km/h. Feedback cannot fix a wrong sensor.

    # same loop, but the sensor reads 10 % low
    import math
    m, c, F_MAX = 1200, 30, 3000
    goal, v, dt = 25.0, 20.0, 0.05
    for n in range(240):
        reading = 0.9 * v                 # bad sensor
        throttle = min(max(goal - reading, 0), 1)
        target = F_MAX * throttle / c
        v = target + (v - target) * math.exp(-dt * c / m)
    print(round(v, 1))                    # 27.5
  10. Four parts, four jobs

    The sensor measures. The controller compares and decides. The actuator pushes. The plant responds. A weak actuator makes the loop slow, a wrong sensor makes it wrong. This rule still leaves 0.25 m/s of error.

    part         job                 here
    sensor       measure the output  wheel sensor
    controller   compare and decide  two lines of Python
    actuator     push on the plant   engine, max 3000 N
    plant        respond             the car
    
    left over    error 0.25 m/s (a later
                 lesson shows how to remove it)

Quiz Unlocks after the last step.