Home / 1st-Order Difference Eqns and Fdbk / Diff. Eqns with Inputs and Proportional Control

Diff. Eqns with Inputs and Proportional Control

The questions below are due on Thursday February 15, 2024; 10:30: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.

1) Crane Control with Inputs

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

Let us return to the cargo crane traveling on track above a buried beacon, as shown in the figure above. Let us assume that the crane measures distance to a beacon every \Delta T seconds, with negative distances left of the beacon and positive distances to the right. In addition we will assume that we can set the crane's velocity, though that likely requires the crane to have an internal velocity feedback loop (not unlike a car with cruise control, where one can specify a speed, and the car adjusts its acceleration to maintain that speed).

If we try to control the crane's position by adjusting its velocity, and the crane has an internal velocity controller, then the combination can be summarized in the block diagram below.

Crane proportional controller.

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

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, v[n-1] is the crane velocity at the time of sample n-1, and \Delta T is the time between samples. Note that the above equation is exact only if the velocity is constant between sample n-1 and sample n.

We denote the desired crane position (also the input to our position controller), as the sequence d_{in}, and a proportional feedback approach to control would be to set 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 (LDEs with no external input), but we now need to learn about including inputs.

2) 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] + \gamma \; u[n-1]\;\;,
where \lambda and \gamma \; are real coefficients, the sequence u is a known input, and the sequence y is the output we need to determine.

2.1) General Solution

Performing a process known as "plugging and chugging", we can write

y[1] = \lambda y[0] + \gamma \; u[0],
y[2] = \lambda y[1] + \gamma \; u[1] \;\; = \lambda^2 y[0] + \lambda \gamma \; u[0] + \gamma \; u[1],
y[3] = \lambda y[2] + \gamma \; u[2] \;\; = \lambda^3 y[0] + \gamma \left(\lambda^2 \; u[0] + \lambda \; u[1] + u[2]\right),
and so on. From the three steps above, it is easy to see the general pattern,
y[n] = \lambda^n y[0] + \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} u[m].

2.2) ZIR, ZSR and Linearity

We can easily see the linearity of the difference equation from the above general form. First, suppose we have three "building-block" solutions to our general first-order equation:

an equation with zero input,

y_a[n] = \lambda y_a[n-1]
whose general solution is
y_a[n] = \lambda^n y_a[0];
an equation with a zero initial condition and an non-zero input,
y_b[0] =0 \;\;\; y_b[n] = \lambda y_b[n-1] + \gamma \; u_b[n-1],
whose general solution is
y_b[n] = \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} u_b[m],
and another equation with a zero initial condition and a different non-zero input,
y_c[0] =0 \;\;\; y_c[n] = \lambda y_c[n-1] + \gamma \; u_c[n-1],
whose general solution is
y_c[n] = \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} u_c[m].

Now suppose

y_t[n] = \lambda y_t[n-1] + \gamma \; (B u_b[n-1] + C u_c[n-1]),
with intial condition y_t[0] = A y_a[0], where A, B, and C are three arbitrary scalar weights. Then the general solution for y_t[n] is given by
y_t[n] = \lambda^n A y_t[0] + \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} \left( B u_b[m] + C u_c[m] \right),
or reorganizing,
y_t[n] = A \lambda^n y_t[0] + B \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} u_b[m] \;\; + \;\; C \gamma \sum_{m=0}^{m=n-1} \lambda^{(n-1)-m} u_c[m].
Substituting the "building-block" solutions for y_a, y_b and y_c, we can readily see that y_t[n] is a weighted combination of y_a[n], y_b[n], and y_c[n],
y_t[n] = A y_a[n] + B y_b[n] + C y_c[n],
which verifies the linearity.

Note that y_a has a nonzero initial condition and its difference equation had zero input, so y_a is referred to as a ZIR (for zero-input-response). Also note that the difference equations for y_b and y_c have non-zero inputs but their initial conditions are both zero, so we refer to them as ZSRs (for zero-state-response). In general, one can determine the response to very complicated inputs by decomposing those inputs into sums of much simpler inputs whose ZSR you might already know. So it is helpful to have a library of ZIRs and ZSRs for several "building-block" inputs, and in the sections below, we calculate a few common ones: the ZIR, the ZSR to a unit sample input, and the ZSR to a unit step input.

2.3) Zero Input Case

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?

2.4) Unit Sample Input Case

A delayed unit sample with delay n_0 is given by

u[n] = 0 \;\;\; n \ne n_0 \; \;\; \; u[n] = 1, \;\;\;n = n_0,
for which we use the compact notation u[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, u[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] = \gamma \; u[n_0] = \gamma \; \delta[n_0-n_0] = \gamma \;

For n > n_0+1, u[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{\gamma \;}{\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.

2.5) Unit Step Input Case

A delayed unit step with delay n_0 is given by

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

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

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

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

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

y[n] = 0 \text{, for } n=n_0
y[n] =\gamma \text{, for } n=n_0+1
y[n] =\lambda \gamma + \gamma \text{, for } n=n_0+2
y[n] =\lambda^2\gamma + \lambda \gamma + \gamma \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{\gamma \;}{\lambda} \;\;\; n > n_0.

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

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

which can be seen by summing the series.

3) 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 u[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}] + \gamma,
and solving for y[{\infty}] ,
y[{\infty}] = \frac{\gamma \;}{1 - \lambda}.

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

Questions:

  1. Given \gamma \; > 0 and u[n] = u_s[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 \gamma \; > 0, and u[n] = u_s[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 \gamma \; 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{\gamma \;}{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, u[n] = u_s[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.

4) 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: