PD control

The questions below are due on Tuesday October 05, 2021; 09:00:00 AM.
 
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.
Lab01 Difference Equation, Model+PD control

Recall the difference equation for the PD-controlled copter arm (assuming a simple second order model for the copter arm "plant"), is given by

\theta_a[n] -2\theta_a[n-1] + \theta_a[n-2]\left(1+\gamma K_p\Delta T^2 + \gamma K_d \frac{\Delta T}{m}\right) -\theta_a[n-2-m]\gamma K_d \frac{\Delta T}{m}
= \Delta T^2 f_{ub}[n-2] + \theta_d[n-2]\left(\gamma K_p\Delta T^2 + \gamma K_d \frac{\Delta T}{m}\right) -\theta_d[n-2-m]\gamma K_d \frac{\Delta T}{m}.
where \theta_d is the desired angle, \theta_a is the measured angle, and we have introduced an extra term, f_{ub}. The term f_{ub} is intended to represent extraneous forces (mostly gravity) that are NOT exactly cancelled by the thrust generated by the direct term, \gamma d[n]. It is impossible to set a constant direct term that always cancels the gravity force, because the effect of gravity changes with arm angle, as we saw in prelab01. So there is usually a nonzero f_{ub}, and one can see that a positioning error for small values of K_p that decreases as K_p increases.

We have a brief matlab script that will help you answer the questions below. The script is also a good collection of matlab "technique" examples, ones that you may find helpful. The file is Matlab script natural frequency plotter.

Steady-State Error, Kp and Kd

Assuming that the desired angle settles to a constant value,

lim_{n \rightarrow \infty} \theta_d[n] \equiv Td
and assuming the PD controller is stable, what is
lim_{n \rightarrow \infty} \theta_a[n] = \theta_a[\infty],
in terms of Td, \Delta T (use dt when answer the questions below), \gamma (use G), f_{ub} (use F), K_p (use Kp ), and K_d (use Kd).

\theta_a[\infty] (in terms of Td, dt, G, F, Kp, and Kd) =

Enter a value python expression using the above parameters (you will not need most of them).

Take particular note which parameters do and do not play a role in the steady-state error, which we define as

lim_{n \rightarrow \infty} e[n] = lim_{n \rightarrow \infty} \left(\theta_d[n] - \theta_a[n]\right),
which in our case simplifies to
e[\infty] = \left(Td - \theta_a[\infty]\right).
Note that the steady-state error goes to zero as K_p goes to infinity.

Settling Time, Kp and Kd

The above difference equation is a model for our copter arm if \Delta T = 0.001 and m = 2, but we are not sure about \gamma , so let us use \gamma = 1.0 for now.

Let us also assume that we selected K_p = 20, because that was high enough to insure a small steady-state error. The next step is to pick a K_d that ensures the system settles to steady-state as quickly as possible. A convenient metric for describing how fast a system settles is its "time-constant". We define the settling time constant as the time interval needed for the initial distance from steady-state to decrease to a third of value (decrease by two thirds). The reason for using one third instead of, for example, one half is largely historic. The fraction \frac{1}{3} is approximately equal to \frac{1}{e}, and exponentials play a large role the time constants for continuous time.

More precisely, we can define the time constant as a number of samples, N, such that

\frac{|\theta_a[n+N] - \theta_a[\infty]|}{|\theta_a[n]-\theta_a[\infty]|} \approx \frac{1}{3}.
We can also convert from samples to continuous time to multiplying by \Delta T.

Using the above difference equation model with \Delta T = 0.001, m = 2, and \gamma = 1.0, and assuming K_p = 20, find to no more than two digits, the value of K_d that minimizes the settling time (think natural frequencies):

For your selected value of K_d, what is the settling time constant, as a number of samples: