Fast and Spurious
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.
Quick Reference
GET UPDATED SKETCH: 9/14/23
Serial Plotter Send Window Indices - DO NOT CHANGE!!
Links
- Software to install is described here.
- Build instructions are here.
- Sketch for this lab is here GET UPDATES: 9/14/23 .
Task Summary
- FIND A PARTNER.
- Install Software.
- Build, Test, and Calibrate the Speed Control System (checkoff 1).
- Determine the roles of the TICKSPERUPDATE, KFF, KP, REPEATS, FREQ, and AMP, and
DisturbA
(checkoff 2).
- Extract coefficients from data for a 1st-order difference equation model.
- Use model to inter-relate gains, update period, and stability. Compare with experiments (checkoff 3).
- Investigate how gains effect tracking error and disturbance rejection, design controller (checkoff 4).
- Collect experimental data for the postlab using various values of TICKSPERESTIMATE (as screenshots) (Checkoff 5).
Safety First
Please read the EECS Lab Safety instructions.
- We will be building and debugging electrical systems. While everything we do in this subject is low-voltage, you should never modify or even touch a circuit without turning off its power.
- We will be using small but very high speed motors. If our systems go unstable, parts can fly off in any direction. Please wear safety goggles when using the high-speed motors with spinning propellers.
Fast and Spurious
The goal of this lab is to control the speed of a motor-driven rotor, while learning about
- Control system modeling,
- Feedback and Stability,
- Sample Rate Effects,
- Steady-state and Dynamic Tracking,
- Insensitivity to Disturbances and uncertainty,
As you will see, the issues associated with control will be obvious and direct, but the issues associated with modeling will be both pervasive and, unfortunately, subtle.
After constructing and testing the speed control system, you will collect data from which to calibrate a first-order difference equation model for the relationship between the Teensy-sketch-generated motor command and the measured rotor speed. You will then use this model to make reasonably good predictions about the interactions between sample rates, controller gains, stability, tracking errors, and disturbance insensitivity.
Then, in preparation for the post-lab, you will collect another data set, one specifically designed to expose inaccuracies in the first-order model. As part of the post-lab, you will derive, calibrate, and analyze an improved second-order model, and see if its predictions are better (spoiler alert, sometimes they are).
The take-away about modeling from this lab and post-lab is NOT (we repeat, NOT) that one model is good and the other is bad. As you will see in lab, a first-order model is accurate enough (and simple enough) to answer questions about the interaction between sample rate and stability, or feedback gain and disturbance rejection. But as you will see in the postlab, you'll need a second order model to accurately predict the stability limits on gain, or to predict waveforms near the stability limit.
So, The take-away from this lab and postlab about modeling? A good model is usually the simplest model that correctly answers your questions.
We use the Arduino IDE 2.2 software (with modifications and a 6.310 specific library) to communicate with, program, and plot results from our 6.310 controller board (based on the Teensy 4.1 microcontroller). Throughout the term, you will be using this software-board combination, along with lab-specific hardware, to design and experiment with algorithms that control rotor speed, rotating arm position, and even magnetic levitation.
For the first checkoff please:
Demonstrate your working and calibrated speed control system
As the above abstract block diagram suggests, controlling the rotation speed of a spinning object requires three interconnected functions. Foremost of the three is an actuator that can be commanded to either accelerate or decelerate the object. Second, one needs a sensor to verify the object's speed. And thirdly, the focus of much of this class, one must design a controller that can determine effective actuator commands given the desired and measured speeds of the object.
As you may have noticed when testing your speed-controlled rotor system, there is a nominal speed of 15 rotations/second (or 15RPS), and an associated nominal actuator command. All the other speeds and commands are offsets to these nominal values, so our system is more precisely described by the abstract diagram below. We formulated our speed control problem in terms of perturbations from nominal values partly because it is a natural fit to the common control problem, maintaining constant speed (think automobile cruise control). But more importantly for our purposes, relationships between perturbations are likely to be more linear, and therefore more easily modeled. And good models, as we shall see thoughout the term, are essential precursers to designing good controllers.
Below is a functional block diagram of our speed control system, based on its physical structures. What should be immediately clear is that the functional block diagram looks nothing like the abstract block diagrams above. For example, is the motor the actuator? Or is it the motor plus the H-Bridge drivers? Also, the combination of the white eight-bladed rotor and the optical sensor does not produce rotation speed, it produces a signal from which the speed can be deduced. So does the combination really form the sensor in our abstract model?
Whether the problem is software or hardware or some combination of the two, finding a good abstract model is often the central challenge in any engineering design. As we noted in the introduction, a good model has enough detail to accurately assess design tradeoffs, yet is simple enough to reveal alternative strategies. But, how does one find a model good enough to answer one's questions, if one needs the model to determine what questions to ask? And how does one find a model that reveals strategies one does not yet know?
Modeling, it is impossible to teach, but fortunately, not impossible to learn.
In the case of our speed control system, we can extract an abstract model like the one in section 3.1, provided we ignore the structural boundaries. The speed sensor is a combination of the rotor, the optical sensor, and the function getSpeed
in the Teensy sketch (which converts the time between falling edges in the optical sensor output into speed estimates, see the next section). The actuator in the abstract diagram is a combination of the function hbridgeBipolar
in the Teensy sketch (which converts a motor command into a pulse-width-modulated signal), the h-bridge driver, and the motor connected to the white rotor.
We summarize the connection between abstract model and structural implementation in the figure below.
As we can see from the figure in the previous subsection, there is a small part of the Teensy sketch that corresponds to the speed-controller block in the abstract block diagram. The actuator command, motorCmd
in the sketch, is computed from the nominal command, nomCmd
in the sketch, the desired perturbation in rotor speed, omega_d
in the sketch, and the measured perturbation in motor speed, omega
in the sketch. To make the meaning of omega
and omega_d
clearer, consider the example plot below. The plot was generated by running the speed control system in control mode (MODE 1), with omega_d
set to be a unit amplitude square wave, the controller gain Kff
set to 0.025, and the square wave frequency set to \frac{1}{25}.
Below we show an incomplete block diagram for the controller, showing how the motor command is computed from the desired and measured motor speeds, as well as the nominal command (which is just added in). The block diagram shows how K_p, the proportional feedback gain, effects the motor command, but does not show the effect of K_{ff}. Be prepared to show how to add K_{ff} to the block diagram at checkoff.
The optical sensor generates a pulse every time a white encoder blade passes underneath it. More specifically, the propeller reflects the infrared light from the led on one side of the sensor to the optotransistor on the other side of the sensor, and when bombarded with infrared light, the optotransistor turns "on". The "on" transistor effectively "pulls-up" the IN5 input on the 6.310 controller board, increasing the voltage from close to zero to nearly three volts. Once the propeller blade passes out from under the sensor, the optotransistor turns "off", the IN5 voltage is pulled back down to zero by a resistor ground (see the schematic in the assembly guide).
The negative change in the voltage on IN5 "interrupts" the microcontroller, which determines the time since the last negative change, and computes the motor speed.
The signal generated by the optical sensor circuit is plotted below (notice the y-axis is normalized, so that 1000 corresponds to three volts), along with a diagram showing when interrupts are triggered on the Teensy 4.1, as well as when a control loop (which updates the motor command) executes. As the diagram should make clear, interrupts are generated every time a propeller blade passes under the optical sensor (eight times per rotation for our eight-bladed rotor), but the control loop only runs every m^{th} interrupt, where m is the setting of ticksperupdate (which you change from the serial plotter send window, by typing, e.g. "0 4" to set ticks per update to 4). Note that when ticksperupdate is zero, m is set to the maximum value of 8.
Demonstrate a working controller
STOP HERE FOR THE FIRST WEEK!!!!
GET UPDATED SKETCH: 9/14/23
As we saw in Monday and Wednesday's lectures, if we can construct a first-order difference equation model for our feedback control system, we can use the model to design a good controller. In general, we approach modeling in two steps:
- Apply a few physical prinicples to determine a parameterized form of the model and,
- Extract the parameter values from the results of carefully-chosen experiments.
Recall that when first experimenting with the speed control system, we turned a small potentiometer to adjust a nominal motor command, C_0 (nomCmd
in the Teensy sketch), to set a nominal motor speed, \Omega_0 (nomOmega
in the sketch). We then perturbed the motor command (e.g. by setting non-zero feedback or feed-forward gains) and measured the perturbation in motor speed. In order to model our system more precisely, we will use lower case letters to denote perturbations from nominal,
cmd
in the sketch) is the measured perturbation in motor command, \omega[n] (corresponding to omega
in the sketch) is the perturbation in measured motor speed, and \omega_d[n] (corresponding to omega_d
in the sketch) is the desired perturbation in motor speed.
To start, changes in motor speed can be related to motor acceleration, \alpha, by
Note: since the sample period is dependent on the motor speed, and the motor speed is being perturbed, we are explicitly ignoring the perturbations in \Delta T. We will assume \Delta T \approx \frac{1}{\Omega_0} (assuming the motor speed is in units of RPS).
One way to generate responses from which to calibrate the linearized model is to use the AMP index in the send window to set the maximum value of omega_d
to a ten percent of the nominal speed (so 1.5 RPS), then use the KFF index to set K_{ff} so that omega
reaches a steady-state that matches omega_d
. You will need to set the input frequency low enough so that the motor speed settles between transitions (perhaps 0.05 hertz or ten seconds between transitions, using the send window and the FREQ index).
For the above senario, and in steady-state, \omega[n] = \omega[n-1]= \omega_d[n]. Since
You can derive a second relation involving \beta and \gamma by examining the immediate (rather than steady-state) behavior of the perturbed motor speed, \omega[n], in response to the step changes in \omega_d[n]. And the analysis of \omega[n] dynamic behavior will simplify if you exploit the fact that the system is linear, and that both \omega and \omega_d are in steady-state before the step change and eventually in a different steady-state afterwards.
NOTE: You can stop the plot by clicking on the run-stop icon in the plotter, and when stopped, you can move the cursor to any plot to find its x-y values.
For the feedback case, the c[n] for your system becomes,
Test your analysis against experiment by using the same values for the AMP and FREQ indices as you used for model calibration, setting K_{ff} to zero, and then slowly increasing K_p (starting with K_p=0) and watching the step responses. Determine when your system goes unstable and see if your experiments match your analytic predictions from your calibrated model.
There are two coefficients to estimate (\beta and \gamma), and two types of information in your measured step responses, how fast the measured speed changes and the change in steady-state value.
For this checkoff, determine \beta and \gamma for your system, and test how well your model predicts the onset of instability (for TICKSPERUPDATE set to 8). In the next checkoff, you can test your model for different values of TICKSPERUPDATE, and use that relation to optimize performance when there are disturbances.
Determine \gamma and \beta for your system.
Use the TICKSPERUPDATE index in the send window to set the ticksperupdate to 4, then 2 and then 1. How will you change \Delta T in your difference equation model to reflect these changes? For each value of ticksperupdate, find the value of K_p for which the system is stable, and see if your experiments match your updated models.
Then set the DisturbA value to 0.5 (on line 14 of the Teensy sketch), and repeat the above experiments. How does the disturbance response change with increasing K_p? Can you use your model to predict how the disturbance response should change with K_p (hint, if you use a very low input frequency, the disturbance response will achieve steady-state, simplifying the analysis).
Be ready to show us both steady-state errors and disturbance rejection, and you should be able to use the difference equation model, and its natural frequencies as a function of K_p , to explain the disturbance rejection and stability.
Set ticksperupdate back to 8 (or 0), set DisturbA back to zero, pick the same frequency and amplitude for the input as you used in the model calibration, and examine the step response for values of K_p that are close to the stability limit. Then use the send window and the REPEATS index to set the repeat value to 3, which forces the plotter to plots each point four times. These repeated plots will create a flat section for each sample, and make it easier to see the number of samples per period when there are oscillations. Look closely at step responses that oscillate before settling, could they have been produced by a first order system? You should take screen shots of your results, you will need them for the postlab.
Ensure that you are updating the speed once per revolution (use the TICKSPERUPDATE index to set ticksperupdate to 8). Then, change ticksperestimate (NOT ticksperupdate!!!) to 1 using the send window with the TICKSPERESTIMATE index (!!NOT TICKSPERUPDATE!!) and increase K_p until the step response is almost unstable. Then try setting ticksperestimate to 2, then 3, and then 4, and finally 8. You should take screen shots of your results, you will need them for the postlab.
Something is not right, but the effect is subtle. Get the checkoff to get some some hints.