# Lecture 23 - Basics of Control

## Questions & Comment

1. Pathologies
• critical races
• performance
2. Layered Abstractions

# Control

## 2. Feedback Control

### How it Works

FOREVER { x += -a * (x - x0) }


x gets updated every time we go round the loop.

Assume that the loop time is very small, say dt,

• which it isn't because evaluating (x - x0) requires talking to hardware.

Then the code amounts to

x(t + dt) = x(t) - a(x(t) - x0)


which can be turned into a differential equation and solved

x(t) - x0 = Constant * exp( -at )


What you see here is, in essence, Newton's method of finding roots, which, when it converges, converges exponentially.

• This is good!

#### A moving target

FOREVER { x += -a * (x - x0(t)) }


We can work hard on this and discover that

x(t) - x0(t) = exp( -at ) \int^t exp( at') u'(t') dt'


In other words, we converge on a moving target as long as it doesn't move too fast

• The meaning of too fast' is important.
• It means doesn't diverge too quickly from constant velocity motion' over the time it takes to update the position.