Summary and Speed Control Inconsistency
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.
This problem is intended to give you some experience with tools used to analyze higher-order systems. In particular, we hope it will help you understand how to connect natural frequencies to time responses, and how to use root loci to determine controller gains. We will use the now-familiar motor speed control example from the first lab because, as we will clarify below, it really was a second order system. We give a very brief summary below (that you can skip until you need it).
A Naturally Brief Summary
The generic form for a zero-input N-state vector first-order difference equation is
The solution, x[n], is a function of an initial condition vector, x[0], and the input sequence, u, and is given by
If the input is zero (ZIR), the above formula simplifies to
It is perhaps worth noting that the eigenvalues of \textbf{A} are not always referred to as natural frequencies, with some referring to them as complex frequencies or eigenfrequencies. Using the word frequency might even seem like a misnomer, because these eigenvalues are not necessarily related to the inverse of an oscillation period. This author's perspective? These eigenvalues inhabit the entire complex plane, why worry about reserving certain words for the imaginary axis, a set of measure zero in that plane.
First Order Model for Motor Speed Control
In the motor speed control lab, Fast and Spurious, you modeled, analyzed, and measured a proportional-feedback-based motor speed control system. You extracted a first-order model of the system, and used that model to predict (fairly accurately) the stability limits on proportional feedback gains. But you also should have observed an inconsistency between the step responses associated with a first-order model and higher-order nature of the step response measurements. In this problem we will develop a second-order model of the speed control system, and show that this higher-order model not only predicts system behavior when ticksPerEstimate=8 but also explains the behavioral changes when ticksPerEstimate=1.
We modelled the speed control system with a first-order difference equation:
where \omega[n] is the motor speed (in revolutions per second, or RPS) at the n^{th} speed sample, \Delta T is the time between speed samples, \beta is a friction coefficient and \gamma is the scale factor relating microcontroller command to motor acceleration.
When the microcontroller parameter ticksPerUpdate is set to 8, the motor speed is updated once per revolution, and since the nominal motor speed is 15 rotations per second,
The First Order Model
Assume c[n] = K_p(\omega_d[n] - \omega[n]), and write the first-order difference equation for \omega[n] in the form \omega[n] = \alpha_1\,\omega[n-1] + \alpha_2\,\omega_d[n-1]. Enter symbolic expressions (in python format) using DeltaT for \Delta T, Kp for K_p, beta for \beta, and gamma for \gamma.
The natural frequency, \lambda, of this first-order system is
Given the values of \beta and \gamma above, and assuming \omega_d[n] = 0 for all n and \omega[0] = 1, find a value for K_p so that \omega[n], n = 0,1,2,3,4,5,6 oscillates at least twice, and that \omega[6] = 0.5. Please first determine the value of \lambda, (careful about signs!) and then determine the seven values of \omega[n], for n = \{0,1,2,3,4,5,6,7\}.
Enter your seven values, \omega[0], ...\omega[6] as a python list in answering the question below. A lollipop plot of your sequence will appear right after you click the submit button.
The Second Order Model
The speed control hardware does not measure \omega directly. Instead, the speed is estimated from timing pulses generated by reflections from the eight-bladed propeller spinning beneath an led-sensor pair. Using the notation in the figure below, which shows the timing when ticksperupdate=8 and ticksperestimate=8.
For the case shown below, the sampling interval is \Delta T = t_0 - t_8, and the associated motor speed estimate \widetilde{\omega}[n] is given by \widetilde{\omega}[n] = \frac{1}{t_0-t_8}.
In the first order model, we assumed
Given the above insight, a more accurate description of speed controller is:
Matrix Form
We can rewrite equation (2) in matrix form by creating a vector from the n^{th} and (n+1)^{th} samples of motor speed as in
Please give formulas for each entry in the A matrix and B vector as a symbolic Python expression, using DeltaT for \Delta T, Kp for K_p, beta for \beta, and gamma for \gamma.
Natural Frequencies (eigenfrequencies)
What are the natural (eigen)-frequencies (eigenvalues of A) of our second order model of the speed controller? We could try to compute them as analytic functions of the gain, K_p, and for a second-order (and even third-order) models, it is possible to determine closed form analytic expressions, but not for higher order models (there is no closed-form general formula for the roots of polynomials above order three, or for eigenvalues of square matrices of dimension higher than three). Instead, we can plot a root-locus of natural frequencies for a range of parameters, and use those plots to determine properties of interest.
The question below is not really a question, but rather a tool (so it always grades as correct) for plotting root-loci and associated time responses. Specifically, the tool plots the eigenvalues of A({K_p}), as K_p varies over a given range. The tool also plots a pair of ZIR's, ones associated with the largest and smallest values of the specified range of K_p's.
Please enter the 2 \times 2 matrix A(K_p) as a Python nested list with entries as analytic functions of ONLY K_p (so please substitute the numerical values given above for \beta, \gamma and \Delta T), and please represent K_p using the python variable Kp. Finally, please follow the matrix specification with the gain range and number of plotting points using the format
Kp=[lowKp,highKp], n=[nstart,nStop].
As an example (NOT THE CORRECT MATRIX!! NOT THE CORRECT MATRIX! NOT THE CORRECT MATRIX!), if the matrix for our system was
[[1, 1],[-2*Kp, 0]], Kp = [0,0.5], n=[0,20]
Plotting Tool.
Use the plotting tool above to find the LARGEST K_p for which the magnitude of the maximum-magnitude eigenvalue is less than 0.9. ADVICE: the above root locus plot will be easier to interpret if you set the high end of the gain so that
Please use observations from our root-locas plotter to answer the questions below.
Reducing the Measurement Delay
The ticksperestimate=8 estimate uses the full motor rotation t_0-t_8 to estimate the motor speed, introducing a kind of delay. Instead, we could set ticksperestimate=1, in which case
As before, we relate this to \omega[n] and \omega[n-1] by linear interpolation:
What are the numerical values of a and b?
Using a and b above, update the formulas for the entries of A and B using a, b, DeltaT, Kp, beta, gamma.
Use the plotting above to find a value for K_p so that the magnitude of the maximum magnitude natural frequency is approximately 0.9.
The behavior of the controller using the reduced delay motor speed estimate was much closer to the behavior predicted by the first-order model, do you see why?