Lab 1:
Fast and Spurious

The questions below are due on Friday September 25, 2026; 10: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.
You are viewing the PRELIMINARY 6.3100 Fall 2026 web site. Please note that information on this page may change throughout the semester, please check back frequently.

Quick Reference

Parameter Indices to use in the serial plotter "Send" window

Links

  • Software to install is described here.
  • Build instructions are here.
  • Sketch for this lab is here.

Task Summary

Week A

  1. THERE IS A TABLE DEFINING SEND INDEXES AT THE TOP OF EVERY LAB!!
  2. FIND A PARTNER.
  3. Install Software.
  4. Build and Test the Speed Control Hardware (checkoff 1).
  5. Determine the roles of the ticksperupdate, kff, kp, repeats, freq, and amp, and DisturbA (checkoff 2).

Week B

  1. TBA

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.

Introduction

The goal of this lab is to control the speed of a motor, while learning about

  1. Control system modeling,
  2. Feedback and Stability,
  3. Sample Rate Effects,
  4. Steady-state and Dynamic Tracking,
  5. 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 motor 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, what is the take-away from this lab and postlab about modeling? A good model is usually the simplest model that correctly answers your questions.

Installation and Construction

We use the Arduino IDE 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 motor speed, rotating arm position, and even magnetic levitation.

Put Together Your Lab Kit. Staff will help you find parts.

Install the Software as described here.

Build and Test the Speed Control Hardware as described in the speed assembly guide here.

Checkoff 1:

After you have carefully followed ALL the steps in the step-by-step assembly guide, demonstrate your working speed control hardware.

  • Demonstrate the operation of your motor by plotting results using mode 0. Describe what is plotted on the horizontal and vertical axes. (Hint: In mode 0, the Teensy samples the optical sensor once every 66.6\museconds.) Describe a method for determining motor speed from this plot. What is the speed indicated by the plot?

  • Change the teensy sketch to mode 1, reupload, and reopen the serial plotter. In mode 1, the speed of the motor is controlled by a feedback system, and the measured speed, desired speed, and motor command are being plotted. The plotted speeds are in thousandths of rotations per second (RPS) minus the nominal speed (set to 15 in the Teensy sketch, or 15,000 thousandths of RPS in the plot). The potentiometer you attached to the controller sets a nominal motor command. What maximum offset from the nominal speed can you achieve by rotating the potentiometer?

  • Use the send window in the serial plotter (DO NOT MODIFY THE SKETCH!) by setting the desired speed to toggle between 14 RPS and 16 RPS every five seconds by first typing 6 1 (followed by return) in the send window, to set the input amplitude to one, and then typing 5 0.1 (followed by return) to set the frequency to 0.1 or the period to 10 seconds. When using the send window, the first number is an integer and is the parameter index (a list of integer-parameter pairs is at the top of every lab) and the second number is the parameter value. Explain what is changing in your plots.

  • Try modifying the feedback gain by setting Kp using the send window. A feedback term is added to the nominal command when Kp is non-zero, and is proportional to the difference between the desired and measured motor speeds, scaled by K_p. Use the send window to try different values of Kp, be sure to try 1, 0.1, and 0.0. What value of Kp is too large, and why?

  • Try setting a non-zero disturbance by setting the value of DisturbA to 0.3 using the send window. Then try increasing the feedback gain, starting from 0.1 and doubling (to 0.2, 0.4, ...). What is the effect of gain on the behavior of the measured motor speed?

Structure of the Control System

The following block diagram illustrates the structure of the speed control system that we will develop.

As this 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.

Perturbations from Nominal

As you may have noticed when testing your speed-controlled motor system, there is a nominal speed of 15 rotations/second (15 RPS), 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 precursors to designing good controllers.

Abstracting from Structure

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 encoder 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.

Connecting Structures and Abstractions

In the case of our speed control system, we can extract an abstract model like the one above provided we ignore the structural boundaries. The speed sensor is a combination of the white eight-bladed encoder, 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 encoder.

We summarize the connection between abstract model and structural implementation in the figure below.

The Controller Block

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 motor 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, affects the motor command, but does not show the effect of K_{ff}. We will consider adding K_{ff} later in the lab.

Sensing Speed

The optical sensor generates a pulse every time a white encoder blade passes underneath it. More specifically, the blade 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 encoder 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, as well as when a control loop (which updates the motor command) executes. As the diagram should make clear, interrupts are generated every time an encoder blade passes under the optical sensor (eight times per rotation for our eight-bladed encoder), 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.

Checkoff 2:

Set the disturbance amplitude to back to zero, and reset the input amplitude to 1 and the oscillation frequency to 0.1 using the send window, and then experiment with modifying ticksperupdate from 1 to 8.

  • For what value of ticksperupdate is thenoise'' in the speed measurement largest? Can you explain why the noise level depends on ticksperupdate?

  • Does changing ticksperupdate change the effect of K_p? Show plots to demonstrate your result.

  • Remodify sketch to set the disturbance amplitude back to 0.3, what combination of ticksperupdate and Kp values gives you the best match between desired and measured speed?

STOP HERE FOR THE FIRST WEEK!!!!