---
title: Open-loop and closed-loop control
heading: Controlling a system by a preset command against controlling it by measuring the result and correcting, a car's cruise control on a hill as the example, how proportional feedback shrinks the error from a disturbance and speeds up the response, and the steady error it leaves
eyebrow: D3 · Lesson 1 · Open-loop and closed-loop control
xp: 40
---

::: hook
A toaster is open loop: it runs for a set time whether the bread is pale or burnt. A thermostat is closed loop: it measures the room and switches the furnace on and off to hold the temperature it was asked for. The difference matters most when something unexpected happens. A car's cruise control that simply held the throttle where it was set would slow down on every hill; one that measures the speed and opens the throttle as the car slows holds the speed it was asked for. Measuring the result and correcting for the difference is called **feedback**, and it's the idea behind every control system.
:::

::: play
- A 1500 kg car cruising at 25 m/s meets a hill at t = 10 s whose slope adds a backward force $F_h$. Its drag is modeled as a linear 50 N·s/m.
- Open loop (dashed), the throttle force stays fixed and the car slows until drag drops enough to balance the hill.
- Closed loop, the controller adds force in proportion to the speed error, $K(v_\text{ref} - v)$. A larger gain K leaves less error and recovers faster.
:::

```sim plot
view: graph
x: t = 0..60
y: v = 15..27
slider: s = 0..6 step 0.5 = 2
slider: K = 0..2000 step 50 = 500
plot: 25 - 1500*9.81*s/100/50*(1 - exp(-50*(t - 10)/1500))*step(t - 10) | samples: 400 | dashed | color: ch3 | label: open loop, m/s (s = slope, %)
plot: 25 - 1500*9.81*s/100/(50 + K)*(1 - exp(-(50 + K)*(t - 10)/1500))*step(t - 10) | samples: 400 | label: closed loop, m/s
readout: open-loop speed loss, m/s = 1500*9.81*s/100/50 | digits: 3
readout: closed-loop speed loss, m/s = 1500*9.81*s/100/(50 + K) | digits: 3
readout: closed-loop time constant, s = 1500/(50 + K) | digits: 3
```

::: predict
## The car meets a 2% grade, a backward force of 294 N. Open loop, it settles 5.9 m/s slower. With proportional feedback of K = 500 N per m/s, how much speed does it lose?

- [ ] None
- [x] About 0.54 m/s
- [ ] About 2.9 m/s
- [ ] 5.9 m/s, the same

::: reveal
In steady state the extra throttle, $K\Delta v$, plus the drop in drag, $b\Delta v$, must balance the hill: $\Delta v = F_h/(b + K)$ = 294/550 = 0.54 m/s, eleven times less than open loop. It also recovers eleven times faster, with a time constant of 1500/550 = 2.7 s against 30 s. Proportional control always leaves some error, since it needs an error to make the extra force; lesson 3 removes it.
:::
:::

::: nameit
## Open loop and closed loop

- **Open loop**: the controller sends a command computed in advance from a model. It's simple and can't go unstable, but it can't correct for disturbances or model errors.
- **Closed loop**: a sensor measures the output, the controller compares it with the **reference** (the setpoint) and acts on the **error** $e = r - y$.

## The cruise control

A car of mass m with linearized drag b obeys $m\dot v = F - bv - F_h$. With proportional feedback, $F = F_0 + K(v_\text{ref} - v)$, so a disturbance $F_h$ leaves a steady error and a time constant

$$\Delta v = \frac{F_h}{b + K}, \qquad \tau = \frac{m}{b + K}$$

against $F_h/b$ and $m/b$ open loop. Feedback divides both by $1 + K/b$, the **loop gain** plus one.

## The price

Feedback needs a sensor, can amplify sensor noise, and can make a system oscillate or go unstable if the gain is too high and the response delayed (lessons 5 to 7).
:::

::: example
## How fast has the open-loop car slowed 10 s after meeting the 2% hill?

::: solution
1. **Time constant.**
   $$\begin{aligned} \tau &= 1500/50 \\ &= 30\ \text{s} \end{aligned}$$
2. **Speed lost after 10 s.**
   $$\begin{aligned} \Delta v &= (F_h/b)(1 - e^{-t/\tau}) \\ &= 5.886 \times (1 - e^{-10/30}) \\ &= 1.67\ \text{m/s} \end{aligned}$$
3. **Compare with feedback.** The closed-loop car with K = 500 has already settled to its 0.54 m/s loss by then.

**Answer:** after 10 s the open-loop car is 1.67 m/s slower.
:::
:::

::: example
## What gain would hold the speed loss on the 2% hill to 0.2 m/s?

::: solution
1. **Total damping needed.**
   $$\begin{aligned} b + K &= F_h/\Delta v \\ &= 294.3/0.2 \\ &= 1472 \end{aligned}$$
2. **Gain.** Take away the car's own b = 50:
   $$\begin{aligned} K &= 1472 - 50 \\ &= 1422\ \text{N·s/m} \end{aligned}$$

**Answer:** a gain of 1422 N·s/m holds the loss to 0.2 m/s.
:::
:::

::: example
## The 1500 kg car's engine can add at most 2000 N beyond what level cruising needs. What happens on a 10% grade and on a 15% grade, whatever the gain?

::: solution
1. **Force at 10%.** The grade's force is about $mg \times \text{grade}$, 1471 N at 10%. That's within reach, so feedback holds the speed as before.
2. **Force at 15%.** It's 2207 N, more than the engine can add, so the throttle saturates.
3. **Speed lost.** The car slows until drag falls by the missing 207 N:
   $$207/50 = 4.1\ \text{m/s}$$
   slower.
4. **The limit.** No gain helps once the actuator is at its limit.

**Answer:** on a 10% grade feedback holds the speed; on a 15% grade the throttle saturates and the car ends up 4.1 m/s slower, whatever the gain.
:::
:::

::: check
given: m = 1000 | 1500 | 2000; s = 1 | 3 | 5; b = 40 | 60
answer: m*9.81*s/100/b
unit: m/s
tolerance: 0.5%

## A {m} kg car with linear drag {b} N·s/m meets a {s}% grade with its throttle fixed. How much speed does it lose in steady state? (Take the hill force as mg times the grade.)

::: right
Right. $F_h/b$ = {answer} m/s.
:::

::: misses
- [any] Not yet. Drag must fall by the hill force.
:::
:::

::: check
given: m = 1000 | 1500 | 2000; s = 1 | 3 | 5; b = 40 | 60; K = 300 | 800 | 2000
answer: m*9.81*s/100/(b + K)
unit: m/s
tolerance: 0.5%

## The same {m} kg car ({b} N·s/m of drag, {s}% grade) has proportional cruise control with K = {K} N·s/m. How much speed does it lose?

::: right
Right. $F_h/(b + K)$ = {answer} m/s.
:::

::: misses
- [m*9.81*s/100/K] Drag helps too: divide by b + K.
- [m*9.81*s/100/b] That's open loop.
- [any] Not yet. Extra throttle plus less drag balance the hill.
:::
:::

::: check
given: m = 1000 | 1500 | 2000; b = 40 | 60; K = 300 | 800 | 2000
answer: m/(b + K)
unit: s
tolerance: 0.5%

## What's the closed-loop time constant of a {m} kg car with {b} N·s/m of drag and a proportional gain of {K} N·s/m?

::: right
Right. $m/(b + K)$ = {answer} s.
:::

::: misses
- [m/b] That's open loop.
- [any] Not yet. The closed loop's first-order time constant.
:::
:::

::: check
given: b = 20 | 50 | 80; K = 200 | 500 | 1500
answer: 1 + K/b
tolerance: 0.5%

## By what factor does proportional feedback of {K} N·s/m shrink a car's disturbance error, if its drag is {b} N·s/m?

::: right
Right. $(b + K)/b = 1 + K/b$ = {answer}.
:::

::: misses
- [K/b] Add one: drag alone already resists.
- [any] Not yet. Compare $F_h/b$ with $F_h/(b + K)$.
:::
:::

::: check
kind: parts
given: m = 1200 | 1500 | 2000; b = 40 | 50; K = 300 | 800; g = 2 | 4 | 6

## A {m} kg car with {b} N·s/m of drag and proportional cruise gain {K} N·s/m meets a {g}% grade.

::: part
answer: m*9.81*g/100/(b + K)
unit: m/s
tolerance: 0.5%

### How much speed does it lose in steady state?

::: misses
- [m*9.81*g/100/K] Drag falls as the car slows and helps too: divide by b + K.
- [any] $F_h/(b + K)$.
:::
:::

::: part
answer: m/(b + K)
unit: s
tolerance: 0.5%

### What is the closed-loop time constant?

::: misses
- [any] $m/(b + K)$.
:::
:::
:::

::: check
kind: parts
given: m = 1200 | 1800; F = 1500 | 2500; g = 10 | 15 | 20

## A {m} kg car's engine can add at most {F} N. It meets a {g}% grade.

::: part
answer: m*9.81*g/100
unit: N
tolerance: 0.5%

### What force does the grade demand?

::: misses
- [any] About $mg \times$ grade.
:::
:::

::: part
answer: step(F - m*9.81*g/100)
tolerance: 0

### Can the cruise control hold speed (1 for yes)?

::: misses
- [any] Only if the engine can supply it.
:::
:::
:::

::: explain
## Why does closed-loop control handle disturbances that open-loop control can't?

::: model
An open-loop controller decides its command in advance from a model of the system, so anything the model leaves out, such as a hill, a gust of wind or a heavier load, changes the output with nothing to notice or correct it. A closed-loop controller measures the output and acts on the difference between what was asked for and what happened, so any disturbance that moves the output also produces an error that drives a correcting action. The higher the gain, the smaller the error needed to produce a given correction, so the system tracks its setpoint more closely and recovers faster, at the cost of needing a sensor and risking instability if the gain is too high.
:::
:::

::: practice

::: check
given: m = 500 | 40000; s = 0.5 | 8; b = 10 | 500; K = 10 | 5000
answer: m*9.81*s/100/(b + K)
unit: m/s
tolerance: 0.5%

## Speed loss: {m} kg, {s}% grade, b = {b}, K = {K}?

::: misses
- [any] $F_h/(b + K)$.
:::
:::

::: check
given: m = 500 | 40000; b = 10 | 500; K = 10 | 5000
answer: m/(b + K)
unit: s
tolerance: 0.5%

## Time constant: {m} kg, b = {b}, K = {K}?

::: misses
- [any] $m/(b + K)$.
:::
:::

::: check
given: b = 5 | 500; K = 10 | 10000
answer: 1 + K/b
tolerance: 0.5%

## Error reduction: b = {b}, K = {K}?

::: misses
- [any] $1 + K/b$.
:::
:::
:::
