Proportional Control and Difference Equations

The questions below are due on Thursday February 16, 2023; 11:59:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

Hitting the Wall Again

A robot that measures obstacle distances ten times a second is placed five meters from a wall. The robot is programmed to move with a velocity negatively proportional to the distance from the wall. We set the velocity negatively proportional to distance to the wall because a robot moving with a positive velocity is moving away from the wall. As the robot gets closer to the wall, it should slow down, but what really happens?

To model how the robot moves towards the wall, we start by representing its distance measurements as a sequence, d, where d[n] is the n^{th} measured distance and d[0] = 5. The difference between d[n] and d[n-1] can be related to the robot's velocity and the time between measurements,

d[n] = d[n-1] + \Delta T \cdot v[n-1] = d[n-1] + 0.1 v[n-1]
where \Delta T = 0.1 is time between distance measurements, and v[n-1] is the robot velocity at the time of sample n-1.

Since the robot's velocity was programmed to be negatively proportional to its distance to the wall,

v[n-1] = -K_p d[n-1],
where K_p is the proportional feedback gain. Combining equations leads to a first-order LDE for d[n],
d[n]=d[n-1] + 0.1 v[n-1]
= d[n-1] - 0.1 K_p d[n-1]
=(1 - 0.1 K_p ) \; d[n-1]
where (1 - 0.1 K_p ) = \lambda is the LDE's natural frequency.

If we do not want the robot to crash into the wall, or equivalently, if we do not want d[n] to become negative, we now know that the first-order LDE's natural frequency must be non-negative. In addition, if we want d[n] to decay to zero (so that we end up next to the wall), the natural frequency must be less than one. Ensuring that 0 \le \lambda \lt 1, or equivalently, that 0 \le \left( 1 - 0.1 K_p \right) \lt 1, yields constraints on K_p as in

0 <0.1 K_p \le 1
0 \lt K_p \le 10

Consider the following questions carefully before moving on to the next section:

  • What happens if K_p is very near but \gt 0?
  • What happens if K_p is exactly 10?
  • What happens if K_p is 11?
Crane Control with Inputs

Let us return to the cargo crane traveling on track above a buried beacon, as shown in Figure 1. The crane measures its signed distance to a beacon every \Delta T seconds, where by signed distance, we mean that the distance is negative if the crane has not yet reached the beacon (left of the beacon in Figure), and postive if the crane has traveled past it (right of beacon in Figure ). The crane is intended to self-drive. That is, it can reposition itself on the track automatically, in response to a desired position request.

Figure 1: Crane traveling on a track and measuring distance to a Beacon.

We are going to assume that the crane has an internal feedback controller that adjusts acceleration to achieve our requested velocity, and that we must design an external position controller.

To model how the crane moves along its track, we will represent the crane's measured distance to the beacon as a sequence, d, and its controlled velocity as a sequence v, where d[n] and v[n] are the n^{th} measured distance and controlled velocity respectively. We can relate the measured distance, d, to its velocity, v, as

d[n] = d[n-1] + \Delta T \cdot v[n-1],
where d[n] and d[n-1] are the measured distances along the crane's track at sample time n and n-1, respectively, and v[n-1] is the crane velocity at the time of sample n-1.

Figure 2: Crane proportional controller.

We denote desired position along the track, also the input to our position controller, as the sequence d_{in}, and a proportional feedback approach to controlling the crane would be to make the crane velocity proportional to the difference between the desired and measured crane positions, as diagrammed in the Figure above. Then the velocity is given by

v[n] = K_p(d_{in}[n] - d[n]).

where K_p is the proportional gain and d_{in} is the input, or desired, position.

In order to determine the performance of this proportional-feedback approach as a function of gain, we substitute the control formula in to the distance-velocity relation for the crane,

d[n] = d[n-1] + \Delta T \cdot K_p \left( d_{in}[n-1] - d[n-1] \right),
and then simplify,
d[n] = (1 - \Delta T \cdot K_p) d[n-1] + \Delta T \cdot K_p d_{in}[n-1],
to arrive at a first-order LDE with an input, d_{in}.

We know how to solve homogenous LDEs, but we now need to learn about including inputs.

First Order LDE's with Inputs

For any system we are trying to control, we will presumably try to influence its outputs by changing its inputs, so we will need to add an input to the homogenous LDE models we already know. In the first-order case, the general form of an LDE with an input is

y[n] = \lambda y[n-1] + b \; x[n-1]\;\;,
where \lambda and b \; are real coefficients, the sequence x is a known input, and the sequence y is the output we need to determine. For the systems we will be considering, most often we are interested in one of two types of inputs, a unit sample or a unit step.

Unit Sample Input

A delayed unit sample with delay n_0 is given by

x[n] = 0 \;\;\; n \ne n_0 \; \;\; \; x[n] = 1, \;\;\;n = n_0,
for which we use the compact notation x[n] = \delta[n-n_0].

As a formal matter, systems described by LDEs are completely characterized by the output due to a unit sample input, referred to as the unit sample response, but that is a digression for us. Formality aside, we can reason about systems by examining their response to a unit sample.

If y[0] = 0, and the input is a delayed unit sample, x[n] = \delta[n-n_0], then y[n] has a familiar power series form that can be derived in a few steps.

For n \le n_0, y[n] = 0, and for n = n_0+1,

y[n_0 + 1] = b \; x[n_0] = b \; \delta[n_0-n_0] = b \;

For n > n_0+1, x[n] =0 and therefore y[n] = \lambda y[n-1], the generating difference equation for the power series. Iterating yields

y[n] = \left(\lambda\right)^{n-n_0}\frac{b \;}{\lambda} \;\;\; n > n_0.
a form very similar to the solution of the homogenous case with non-zero initial conditions.

In the stable case, that is if |\lambda| \lt 1 ,

\lim_{n \rightarrow \infty} y[n] = y[{\infty}]= 0.

Unit Step Input

A delayed unit step with delay n_0 is given by

x[n] = 0 \;\;\; 0 \le n \lt n_0 \; \; \; \; x[n] = 1, \;\;\;n \ge n_0,

for which we use the compact notation x[n] = u[n-n_0]

Given a unit step input, x[n] = u[n-n_0], and y[0] is still zero, then y[n] = 0 \;\; n \le n_0 and y[n_0 + 1] must equal b \; x[n_0] = b \; u[n_0-n_0] = b \;. For n > n_0+1, x[n] =1 and therefore

y[n] = \lambda y[n-1] + b \;.

If we write out the terms, we can see the pattern,

y[n] = 0 \text{, for } n=n_0
y[n] =b \text{, for } n=n_0+1
y[n] =\lambda b + b \text{, for } n=n_0+2
y[n] =\lambda^2b + \lambda b + b \text{, for } n=n_0+3.

Iterating yields a representation of y as a power series sum,

y[n] = \sum_{m = n_0+1}^n\left(\lambda\right)^{m-n_0}\frac{b \;}{\lambda} \;\;\; n > n_0.

In the stable case, that is |\lambda| < 1 ,

\lim_{n \rightarrow \infty} y[n] \equiv y[{\infty}] = \frac{b \;}{1 - \lambda}

which can be seen by summing the series.

Determining the large N limit

For the stable case, |\lambda| \lt 1, if the input eventually becomes constant, such as in the delayed unit step, we are often only interested in behavior for large n. If so, there is an easier approach to determining y[{\infty}] , a surprisingly useful trick more generally.

Suppose x[n] =1 for n > n_0 and |\lambda| \lt 1. In this stable, constant input, case, y[n] and y[n-1] both approach y[{\infty}] for large n, so

y[{\infty}] = \lambda y[{\infty}] + b
and solving for y[{\infty}] ,
y[{\infty}] = \frac{b \;}{1 - \lambda}.

There are many ideas hidden in the above simple formula, and they are best exposed by answering questions. Questions:

  1. Given b \; > 0 and x[n] = u[n], if \lambda = -1 does y[n] remain bounded?
  2. For the \lambda = -1 case, does y[{\infty}] exist?
  3. Does y[n] remain bounded if \lambda = 1?
  4. Given b \; > 0, and x[n] = u[n], what value of \lambda minimizes y[\infty] when it exists, and what is that minimum value.

Answers:

  1. Yes, y[n] is bounded.
  2. No, y[{\infty}] does not exist as y[n] alternates between 0 and b \; forever.
  3. If \lambda = 1, y[n] is unbounded, and y[{\infty}] does not exist.
  4. Setting \lambda very close to -1 minimizes y[\infty], which is bounded from below by \frac{b \;}{2}. But then y[n] oscillates and decays very slowly.

And one last use of y[{\infty}], we use it to construct the entire step response. If y[0] = 0, x[n] = u[n-n_0], and |\lambda| \lt 1, then y[n] = 0 for n \le n_0 and

y[n] = \left( 1 - \lambda^{n-n_0} \right) y[\infty] \;\;\; n > n_0.

In the Figures below we show the behavior of the step response for several different values for \lambda. Notice the large n values in the plots. For example, even if \lambda \lt 0, the large n value is still positive.

Delayed step response for \lambda = 0.9 and n_0 = 3.
Delayed step response for \lambda = 0.3 and n_0 = 3.
Delayed step response for \lambda = -0.3 and n_0 = 3.
Unit step (no delay) response for \lambda = -0.9 and n_0 = 0.
Exercises

For the following problems,

v[n] = \lambda v[n-1] + u[n],
where u[n] denotes the unit step, and
u[n] = 0 \;\; \text{for} \;\; n \lt 0
and
u[n]= 1 \;\;\text{for} \;n \ge 0.

A:

B:

C:

D:

E:

F:

For which plots above is \left| \lambda \right|=1? (Enter the letters below, separated by commas.)

For which plots above is \lambda \lt 0? (Enter the letters of the plots separated by commas below:)

For which plots above is \left|\lambda \right| \lt 0.5? (Enter the letters of the plots separated by commas below):

For what value of \lambda is the limit as n \to \infty of v[n] equal to:

5:

100:

\frac{5}{6}:

\frac{5}{9}:
Consider a feedback system in which v is being controlled so that it tracks w, where
w[n] = \begin{cases} 0 & \text{if } n \leq 5, \\ 1 & \text{if } n > 5 \end{cases}

A model for a proportional feedback system is given by the difference equation

v[n] = v[n-1] + \Delta T \cdot K_p \cdot (w[n-1] - v[n-1])
where \Delta T = 0.01 is the time between samples. A difference equation of this form could be a model for velocity control, where v is the velocity and K_p \cdot (w[n-1] - v[n-1]) is the acceleration due to proportional feedback. Below are plots of the response of the system for different values of the proportional gain K_p :

A:

B:

C:

D:

E:

F:

G:

H:

Enter the letter of the plot above that corresponds to v[n] when K_p=10

Enter the letter of the plot above that corresponds to v[n] when K_p=50:

Enter the letter of the plot above that corresponds to v[n] for K_p=150:

Enter the letter of the plot above that corresponds to v[n] when K_p=200: