Home / CT, System Functions, and Frequency Response / 1st-Order Differential Equations and Proportional Control

1st-Order Differential Equations and Proportional Control

The questions below are due on Thursday March 14, 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) Homogenous First-Order Equations

When we studied difference equations, we started with the first-order homogenous difference equation,

y[n] = \lambda y[n-1],
whose solution is given by
y[n] = \lambda^n y[0],
where we usually assume that y[0] is known. But the relation holds more generally. That is, given y at any value n_0,
y[n+n_0] = \lambda^{n} y[n_0].
The existence of a solution satisfying the difference equation and the initial condition is easily established,
if \;\; w[n] = \lambda^n y[0], \;\;\; then \;\;\; w[n] = \lambda w[n-1],
and
w[0] = y[0].

Solutions to first-order homogenous differential equations are quite similar. If

\frac{d y(t)}{dt} = \lambda y(t),
then
y(t) = e^{\lambda t} y(0),
where the initial condition, y(0), is usually assumed known. But the result holds more generally. That is,
y(t+T) = e^{\lambda t} y(T).
To verify our candidate solution, consider that
if \;\; w(t) = e^{\lambda t}y(0), \;\;\; then \frac{d w(t)}{dt} = \lambda w(t),
and
w(0) = e^{\lambda 0}y(0) = y(0).

1.1) Comparing DT and CT Natural Frequencies

Recall that if
y[n] = \lambda y[n-1],
then \lambda is the natural frequency of the DT system. If \lambda < 0, then y[n] oscillates and if |\lambda| < 1, y[n] decays to zero.

If

\frac{d y(t)}{dt} = \lambda y(t),
then we say \lambda is a natural frequency of the CT system. As always, the use of the term "frequency" seems odd, because for any real \lambda, y(t) = e^{\lambda t} y(0) never oscillates, but is a decaying or growing exponential, depending on the sign of \lambda, as in the figure below.

Figure 1: e^{0.02t} (purple) and e^{-0.02t} (yellow) versus t

For higher order difference equations, the DT natural frequencies were roots of higher-order polynomials, and therefore real equations could have complex natural frequencies. The same will be true for CT natural frequencies, they will be the roots of higher-order polynomials and can be complex. But we will return to the higher-order case later, for now, let us consider an example of proportional feedback leading to homogenous difference or differential equations.

1.2) Continuously Crane

Figure 2: Crane traveling on a track and measuring

Let us return to the cargo crane traveling on track above a buried beacon, as shown in Figure 2. Suppose we must decide between two control systems, a discrete-time controller that measures distance to the beacon every \Delta T seconds, and a continuous-time controller that measures the distance continuously. One way to compare the two systems is to examine the problem of returning the crane as rapidly as possible to "home" position, that is, back to the beacon at d = 0. And for this comparison, we are going to assume that the crane has an internal feedback controller, one allows us to design a controller that senses position and controls crane velocity (as show in Figure 3 below).

Figure 3: Crane DT proportional controller.

1.2.1) Model

For our velocity-controlled crane with discrete-time sensor,

d[n] = d[n-1] + \Delta T \cdot v[n-1],
where d[n] = d(n \Delta T) is the distance from the beacon at time n \Delta T, and v[n-1] is the crane's constant velocity from from (n-1)\Delta T to n \Delta T.

If we use proportional control to return the robot back to the beacon (d=0), then the DT controller velocity at n \Delta T is given by

v[n] = -K_p d[n],
and the combination of controller and plant leads to a homogenous difference equation for d,
d[n] = (1-\Delta T K_p) d[n-1].

For the continuous-time controller, crane distance and velocity are related by a derivative,

\frac{d}{dt} d(t) = v(t),
where d(t) and v(t) are the robot's distance and velocity at time t. If we use proportional control to return the robot to the beacon,
v(t) = -K_p d(t),
leading to a homogenous differential equation for d,
\frac{d}{dt} d(t) = -K_p d(t).
Note that the solution to the CT homogenous equation is
d(t) = d(0)e^{-K_p t}
where d(0) is the initial distance from the beacon. Note that
\lim_{t->\infty} d(t) = 0
for any K_p > 0. That is, for proportional control on a first-order CT system, THE FEEDBACK SYSTEM IS STABLE FOR ANY POSITIVE GAIN .

1.2.2) DT to CT Comparisons

Suppose the cranes are being independently monitored with remote LIDAR, which measures the distance between the crane and the beacon every ten seconds. A test was run using the CT controller with an unknown proportional gain K_p, in which two consecutive measurements from the LIDAR system (which we can denote as d(t) and d(t+10)) gave distances of 200 meters and then 10 meters between the beacon and the crane.

What was the third consecutive LIDAR measurement, d(t+20), and to within one percent, what was the controller gain, K_p?

d(t+20)=

Kp=

Suppose we want to test the DT controller with \Delta T = 0.1, then \Delta T = 0.5, and finally with \Delta T = 10 seconds. Determine the three values of K_p we should use if we want to match the measured performance to the CT system. That is, if d[n_0] = 200 meters, and n = \frac{10}{\Delta T}, then then d[n+n_0] = 10 meters (so n=100 for \Delta T = 0.1, n=20 for \Delta T = 0.5, and n=1 if \Delta T = 10). Determine the three values for K_p (answers should be within one percent).

If \Delta T = 0.1, then K_p=

If \Delta T = 0.5, then K_p=

If \Delta T = 10, then K_p=

Check Yourself 1:

Suppose we know that the same proportional gain, K_p, is being used for both the CT and a DT controller, and that the LIDAR monitor recorded d(t_0) = 100 for the CT controller and d[n_0] = 100 for the DT controller. If the next recorded value for the CT controller was d(t+10) = 10, and was matched (to within 10 percent) by the next recorded value from the DT controller d[n_0 + \frac{10}{\Delta T}] (Assuming \frac{10}{\Delta T} is an integer). What is the largest possible value for \Delta T. This problem requires a bit of trial and error.

1.2.3) Fast and Slow Sampling limits

If \Delta T is small, so the sample rate for the DT system is fast, how close are the behavoirs of the DT and CT crane control systems? As we noted more generally above,

d(t+\Delta T) = e^{-K_p \Delta T} d(t),
so
d(n \Delta T) = (e^{-K_p \Delta T}) d((n-1)\Delta T).
We can compare the above "samples" of the CT system to the DT system's behavior
d[n] = (1 -K_p \Delta T) d[n-1].
If we define the difference between the sampled CT system and the DT system as an "error", e[n] \equiv d[n] - d(n \Delta T) , then we can write a difference equation for that error as
e[n] = \left[(1 - K_p \Delta T)-(e^{-K_p \Delta T})\right] e[n-1].
When |K_p \Delta T| << 1, we can Taylor expand the exponential and show that the term in brackets is of the order of (K_p \Delta T)^2, so the error will remain small. But for larger \Delta T's, the DT and CT systems have very different behavior.

For example, in the CT crane control problem, we can pick a gain, K_p, that will reduce the distance to the beacon by a factor of ten in one millisecond. What would that gain be?

The CT gain that reduces distance to beacon by factor of ten in one millisecond, K_p= :

For the CT case, fast response corresponds to a very negative natural frequency, and in the DT case, fast response corresponds to a natural frequency whose magnitude is near zero. We can pick a K_p for the DT case that will give us a natural frequency of exactly zero, and ensure a one-step return to the beacon. Such controllers are sometimes referred to as dead-band controllers. What is the value of the natural-frequency-zeroing K_p as a function of \Delta T? (use a python expression, and use 'dt' to for \Delta T.)

Enter a python expression for Kp as a function of dt.

Check Yourself 2:

How do the above K_p's compare if the DT case has a one millisecond sample period? How do the distances from the beacon compare?

1.2.4) Dead-bang and Uncertainty

As \Delta T shrinks, the K_p needed to achieve a DT natural frequency of zero can become impractically large. For \Delta T = 10, like the case above, a zero natural frequency can be achieved using a reasonable gain. But consider the crane velocity just before an update when moving from d[n_0] = 200 to d[n_0+1] = 5 meters. With K_p = 0.1, the velocity jumps from 20 meters per second to 0.5 meters per second, hardly smooth deceleration.

But there is a more serious issue associated with the dead-bang approach. What if someone puts much larger tires on the crane, so that the relation between velocity and position from proportional control gets scaled by an uncertain \gamma, as in

v[n] = \gamma(-K_p d[n]).
The resulting difference equation for distance from the beacon, including the uncertain \gamma is
d[n] = (1-\Delta T \gamma K_p) d[n-1].
If we pick K_p = \frac{1}{\Delta T}, but the uncertain \gamma is somewhere between 0.5 to 1.5, what will happen to d[n]? Will the crane be driven past the beacon and have to turn back? Will its position oscillate?

What would the CT system's response look like in this case?

1.3) First-Order CT Systems with inputs

For any system we are trying to control, we will presumably try to influence its outputs by changing its inputs, so lets add an input to the homogenous first-order CT model above as in

\frac{d}{dt} y(t) = \lambda y(t) + b \; u(t),
where \lambda and b \; are real coefficients, u(t) is a known input.

We are often interested in responses to step changes in input, as in

u(t) = 0\;\;\;t < t_0\\ u(t) = 1\;\;\;t \ge t_0.
If we assume that y(0) = 0 and the u(t) described above, then y(t) = 0 \;\;\; t \lt t_0, but what happens after t_0?

Let us start with an easier problem. Suppose

u(t) = Ue^{st},
for all time t. Let us assume y(t) has the same time-dependence as u(t), though allow it to be scaled differently, as in
y(t) = Ye^{st}.
Note that
\frac{d}{dt} y(t) = \frac{d}{dt} Ye^{st} = sYe^{st},
so
\frac{d}{dt} y(t) = sYe^{st} = \lambda y(t) + b \; u(t)\;\; = \lambda Ye^{st} + b Ue^{st}.
Cancelling e^{st} and moving the terms involving y to the left side,
sY - \lambda Y = b U \;\;\; or\;\;\; Y = \frac{b}{s-\lambda} U,
where later we will later observe that \frac{b}{s-\lambda} is a transfer (or system) function, and we will denote it by H(s).

So, we have a family of solutions to the homogenous (zero input) equation,

\frac{d}{dt} y(t) - \lambda y(t) = 0,
y(t) = Ae^{\lambda t} for any scalar A. We also have one solution to the equation with a particular input,
\frac{d}{dt} y(t) - \lambda y(t) = Ue^{st},
y(t) = \frac{b}{s-\lambda}Ue^{st} .

Since our differential equation is linear, we can add the homogenous solution to the particular solutions, and use our one degree of freedom, A to make sure we match y(0). That is,

y(t) = Ae^{\lambda t} + \frac{b}{s-\lambda}Ue^{st}
where A is chosen so that y(t)|_{t=0} matches y(0), the given initial condition.

If y(0) = 0 and u(t) = 1 for t \ge 0, then u(t) = 1 e^{st} for s = 0 and

y(t) = Ae^{\lambda t} + \frac{b}{0-\lambda} 1 e^{0t} = \frac{b}{- \lambda} \left(1 - e^{\lambda t} \right),
where the rightmost equality is derived by selecting A to match y(0) = 0.

A plot of the step response for b = 10 and \lambda = -100 is given below. Note that the step response settles to \frac{b}{-\lambda} as t \rightarrow \infty, and has risen to about two-thirds of the steady-state at t \approx \frac{1}{-\lambda}.

Figure 4: Step Response for b = 10 and \lambda = -100

It is easy to verify that the above y(t) satisfies the differential equation by redoing the analysis with a redefined time, \tilde{t} = t - t_0.

1.3.1) Linearity and Sums of Inputs

0.0.1)

It is often useful to represent u(t) as a sum,

u(t) = \sum_{k=1}^{k=K} U_ke^{s_k t}.
By linearity, the particular solution for the sum input would be
y(t) = \sum_{k=1}^{k=K} \frac{b}{s_k-\lambda}U_ke^{s_k t},
a simple, but surprisingly useful, observation.

1.4) Crane Control with Inputs

If we want to move the crane to positions other than the beacon position at d=0, we will need to specify a desired position along the track. The desired position, which we will denote as d_{in}(t), will become an input to our position controller, which will try to keep the drane position, d(t), close to the desired position d_{in}(t).

A proportional feedback approach to controlling the crane's position would be to make the crane velocity proportional to the difference between the desired and measured crane positions, as diagrammed for the DT case in the figure above. Then the velocity is given by

v(t) = K_p(d_{in}(t) - d(t)).
where K_p is the proportional gain and d_{in}(t) is the input, or desired, position at time t.

In order to determine how the performance of this proportional-feedback controller changes as we increase or decrease gain, we substitute the control formula in to the distance-velocity relation for the crane,

\frac{d}{dt} d(t) = K_p \left( d_{in}(t) - d(t) \right),
and then reorganize as
\frac{d}{dt} d(t) = - K_p d(t) + K_p d_{in}(t).

Figure 5: d(t) versus t for four different values of K_p

Above are four plots of d(t) versus time for the case d(0) = 5 and d_{in}(t) = 1. There are four plots, blue, orange,yellow and purple, and each plot is associated with a different value of K_p. Assuming that the four K_p values are integers in the range \{1,...20\}, what are the four gains in blue, orange, yellow, and purple (hint, e^{-1} \approx \frac{1}{3}). Enter your solution as a python list, e.g. [5,10,15,20].

K_p for [blue,orange,yellow,purple] =

If d(0) = 5, and d_{in}(t) = 1, what is the analytic solution for d(t) as a function of K_p and t? Use a python expression, use 'Kp' to for K_p and use, for example, 'e**(-a*t)' to represent e^{-at}.

Enter a python expression for d(t) as a function of Kp and t