Lab 2:Code Of Arms

The questions below are due on Friday October 02, 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

Serial Plotter Send Window Indices

Links

  • Build instructions are here.
  • Sketch for this lab is here.
  • The Matrix Root-Locus and Trajectory Tool is embedded in the Week B section below.

Task Summary

Week A

  1. Build, Calibrate, and Test the Arm Control System (Checkoff 1).
  2. Investigate the behavior of your arm when using only proportional feedback, K_p, and examine the behavior of difference estimates of the derivative as you change the difference interval m (Checkoff 2).
  3. Investigate, experimentally, relationships between proportional and derivative feedback gains and arm performance. Pay particular attention to determining when step responses show the impact of nonlinearity.
  4. Use a combination of proprotional and derivative feedback (by setting non-zero values of K_p and K_d ) to stabilize the arm, and briefly investigate the impact of these gains on disturbance rejection (by dropping a load onto the arm (checkoff 3).

Week B

  1. Relate difference equation natural frequencies to measured arm behavior, and use the relation to estimate \gamma_a (Checkoff 4).
  2. Extract \gamma_a and \beta coefficients by comparing measured and simulated responses of a PD-controlled by comparing to model simulation using a non-instant 1st-order difference equation model of the command-to-arm-torque relation (Checkoff 5).
  3. Add integral feedback to your model, and use the model to design a good PID controller. Compare with experiments, and then investigate how the integral term effects the steady-state error when you introduce disturbances (checkoff 6).

Introduction

In the last lab you modeled and determined control parameters for a motor speed control system, a relatively stationary example, and in this lab you will fly! Well, maybe "fly" is a bit of an exaggeration, though there will be motion. You will build a propeller-thrust-driven rotating arm, and you will control the arm's position by using angle measurements to adjust propeller motor drive. Perhaps a few videos (from a previous term using a somewhat different setup!!)...

Arm Wrestling

In the videos above, we show three propeller arm control systems. In the top video, we show what would happen if we used the same proportional feedback controller we used for speed control. In the bottom left, we show a video of using a PID controller, like the one you will be able to design by the end of this lab. And in the bottom right picture, we show you the kind of controller you will be able to design by the end of the term (after we cover state-space and observers).

The Key Challenge

As the abstract block diagram (left panel above) suggests, controlling the rotation angle requires three interconnected functions, an actuator, a sensor and a controller. The angle sensor generates an analog voltage proportional to rotation angle, which is much more direct than the optical encoder sensor used for speed control. But the actuator is more complicated (right panel above). When a motor command is updated by the microcontroller sketch, the voltage across that motor changes, leading to a change in motor speed, which results in a change in propeller thrust, which alters the arm torque, leading to changes in arm angular velocity. The layers of indirection make the control problem challenging, but not uncommonly so, most systems using force-based actuators are similar.

Control Design Approach

Like before, you will model your system and then use the model to help determine a good controller, though for the arm angle control, the modeling and controlling is more complicated. So, you will start with a simple proportional feedback controller, measure the arm behavior, and use those measurements to calibrate a second-order difference equation model of the arm. Then you will use your arm model to determine how the controlled-system's natural frequencies change as a function of proportional(P) and delta(D) (or derivative) feedback gains, and use that insight to design a good PD controller. Success! -ish.

It is possible to find an "okay" PD controller using the second-order arm model, a model accurate enough to predict failure for proportional-only control, but not much more. To achieve better performance, you'll need a more sophisticated controller, and to tune it, you will need a more comprehensive arm model. In particular, you will add an integral (or summation) term to your controller (the "I" in PID), and then tune the three gains (proportional, K_p, derivative, K_d, and integral, K_i) using a model that includes a non-instant relation between changes in motor command and the resulting changes in propeller thrust. And to analyze this complicated controller and model system? For that, you will need to make use of the more sophisticated analysis techniques and computational approaches you've just learned.

Assemble and Test

Please build the propeller-arm control system as described here. Be sure to complete the testing at the end of the assembly guide so that:

  1. the angle sensor axle is oriented correctly,
  2. the measured angle displayed by the serial plotter is zero when the arm is horizontal,
  3. and you've adjusted the nominal motor command so that the associated propeller thrust holds the arm level (that is, horizontal).

Checkoff 1:

Demonstrate your calibrated arm.

  • Use the low proportional gain described in the assembly guide to demonstrate the arm holding itself level. Try blowing on the arm. How well does the arm hold its horizontal position?

  • Set K_p = 0 and adjust the arm position by turning the potentiometer (the same one you adjusted in lab1) to adjust the nominal motor command (and therefore the propeller thrust). Try to adjust the potentiometer so that the arm is rotated to approximately -0.75 radians (-45 degrees, so BELOW level). How well does the arm hold this position?

  • Now adjust the potentiometer so that the arm is approximately +0.75 radians (+45 degrees, so ABOVE level). How well does the arm hold this position?

  • What fraction of the gravity force on the arm acts to rotate the arm in each case?

  • What is different about the two arm position? Hint: think about how the gravity force changes when you perturbn the arm angle away from +0.75 radians versus how that force changes when you perturb away from -0.75 radians.

Experiment with Proportional Gain

For the second checkoff, we would like you to try some preliminary experiments with proportional feedback, to help you develop an appreciation for the differences between the arm angle and speed control problems.

Determine how the response of the system changes with K_p by using the following procedure:

  1. Use the send window to set K_p (type "3 0.6" for example).
  2. Hold the arm (with your hand) so that the serial plotter shows the arm is about 60 milliradians above horizontal.
  3. Be prepared to stop the plotter -- then let go of the arm!
  4. Stop the plotter, then stop the arm by grabbing the end of the chop stick or by pulling the large power connector.
  5. Repeat with a new K_p

You should be able to find K_p's in the range \frac{1}{4} < K_p < 2 that produce both stable and unstable oscillating behaviors (like the two figures below). Try to find one that is stable (decays to zero like the first figure below), and one that is unstable (like the second figure below). Take screen shots for these two behaviors. You will need them for the checkoff.

Examining Cmd and DEdt/10

Once you have found a pair of K_p's (one producing decaying, and the other growing, oscillations), turn on the serial plotter plots for the motor command and the derivative of the error, and redo your growing oscillation experiment. You should be able to produce a figure like the one below.

The DEdt plot shows a difference approximation to the time derivative of the arm angle error. The error is defined as the desired minus the measured angle,

e[n] \equiv \theta_d[n] - \theta_a[n],
and the difference approximation to its derivative is given by
DEdt[n] = \frac{e[n]- e[n-m]}{m\Delta T}
or in block diagram form

where

m = 1 + extraBack
indicates how far backward to look for a difference sample . If m is large, the "derivative" is less noisy, but is less "up to date". If m is small, the "derivative" is noisy, but is also more immediate. A typical case is shown in the figure below.

Try increasing m (integers between 1 and 10) using index 0 (EXTRABACK) in the send window. You should be able to set m to produce a figure like the one below.

Checkoff 2:
  • Show the staff member your screen shots for the largest value of K_p for which your system was stable, that is, the oscillations decayed with a 60 milliradians initial displacement.

  • Show the staff member your screen shots for the smallest value of K_p for which your system was unstable with a 60 milliradians initial displacement.

  • What is the relation between the angle, command, and DEdt signals? Do the peaks in these waveforms line up?

  • How do the waveforms change as m gets bigger? Note that on line 19 in the sketch, #define offsetExtraBack 2 sets an offset of two for EXTRABACK. When you type "0 2" in the send window, you are setting EXTRABACK to four, and therefore setting m=5 . If you want to set m = 1 , type "0 -2" in the send window.

Disturbing Observations

At the beginning of this lab you observed evidence of nonlinearity: differences in arm behavior when positioned above horizontal versus below horizontal. And as we saw in lecture this past week, adding derivative feedback, K_d, helped stabilize the path following robot, and increasing proportional feedback, K_p, improved disturbance rejection. So for this last checkoff of part A, we would like you to investigate (experimentally) stability, nonlinearity and disturbance rejection.

Stability and Derivative Feedback

To get a feel for using derivative feedback to stabilize the arm, try the following:

  1. Use the send window to set extraback = 5 (type "0 3" in the send window, to add 3 to offsetExtraBack, which is 2), K_d = 0.2 (type "1 0.2" in the send window) and K_p = 0.5 (type "3 0.5" in the send window). The arm should be level, if not, adjust the potentiometer to level it.
  2. Set the step frequency to 0.1 (type "5 0.1" in send window), and then set the step amplitude to 0.2 (type "6 0.2").
  3. Note the step response, and then try setting K_p = 0.75, then K_p = 1.0, 1.25, 1.5, ... Note how the step response changes with increasing K_p. What is the largest K_p you can use before the system becomes unstable?

Evidence of Nonlinearity

How nonlinearity impacts performance can often be predicted using linear system ideas. Try the following large-step experiment:

  1. Set the step amplitude to 0.35 , K_d=0.1 and K_p=0.6.
  2. Readjust the command offset potentiometer to best match the steady-state-ish values of the desired and measured arm angles.
  3. Decrease K_d until your falling step response oscillates a couple of times before settling down.
Your plot should look something like the plot below (and your K_d should be somewhere between 0.02 and 0.08). What do you observe about the difference between the rising and falling step responses, and can you explain the difference (You will probably need some staff help to answer this one!)?

DIY: Drop It Yourself

Now lets try disturbing the arm, by dropping a Lego "U" on the arm as shown in the picture below.

  1. TURN OFF THE STEP INPUT, set the input amplitude to zero (type "6 0.0" in the send window)
  2. Set K_d = 0.2, K_p = 0.5, .
  3. Readjust the command offset potentiometer to zero the arm angle.
  4. Try dropping the Lego "U" on your arm and note how the arm angle changes (drop the "U" close to the angle sensor, so it does not have too much leverage, and try to drop it in the same place when you repeat the experiment below).
  5. Try setting K_p = 0.75, redrop the "U", and note how much the arm angle changes. Repeat with K_p = 1.0, 1.25, 1.5.

Checkoff 3:
  • Please prepared to show and explain your experiments to a staff member.

  • Stability: What do you observe about the arm step response as you increase K_p?

  • Nonlinearity: For the large step experiment, what did you observe about the difference between the rising and falling step responses? Can you explain it? (You will probably need some staff help to answer this one!)

  • Disturbance Rejection: What do you observe about the response to the U-drop disturbance as you increase K_p?

STOP HERE FOR WEEK A!!!!