Motor Control

The questions below are due on Friday March 10, 2023; 05:00:00 PM.
 
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.

Last week, we built a 4-bit digital-to-analog converter (DAC), which demonstrated a powerful capability of electronic circuits as interfaces between computation and the physical world. In this lab, we'll explore that idea further, building a smaller DAC and using it to control a motor.

We're also going to use this lab as a first exposure to a new kind of device: an operational amplifier ("op-amp" for short), which we can model as a kind of dependent source like those we've seen in lecture. We're not expecting you to have seen op-amps before; rather, we'll use this lab to get a little bit of exposure to op-amps and some ways in which they can be used; and then we'll dive deeper into the theory in next week's lectures and recitation.

Drivin' Through the Night

Before we get to using our DAC to control the motor, let's experiment with the motor itself a little bit. For this part of the lab, we'll use a new piece of equipment: the benchtop power supply. It looks like this:

Yours may not have connectors coming out of it; if it doesn't, you can unplug the red and black cables from your multimeter and put them in the left-most two plugs (labeled "CH1," make sure you put the red and black in the right places).

When you turn on the supply, you'll see something like the above on the display. While the green "V" on the right is lit up, turning the big knob will adjust the voltage; clicking the little "A" will change things to that the big knob will adjust the maximum current instead. The "On/Off" button under "CH1" turns that channel on and off (it will be lit up in green when the channel is on).

Here's the experiment we'd like to try:

  • Grab a motor and a breadboard from the cart. If your motor doesn't already have one, use some tape to make a little "flag" on the end of the motor so that we'll be able to see how it's moving more easily, something like this:

  • Push the big power button on the bottom left of the power supply to turn it on.

  • Make sure channel 1 is off (the little "on/off" button under CH1 should not be lit up).

  • Click the little "V" button on the right and use the knob to adjust the voltage to 0V.

  • Click the little "A" button on the right and use the knob to adjust the current to 1A (this is a safety measure; it limits the amount of current we can draw from the supply).

  • Connect the two clips from the supply to the two leads from the motor (you could connect them directly, but it might be better to use the breadboard).

  • Click the "On/Off" button to turn on the supply.

  • While it is on, adjust the voltage between 0V and 10V.

Check Yourself 1:

How does the motor's speed relate to voltage? What happens if you flip the leads on the motor?

Turn off the power supply when you're done.

DAC to the Future

Now that we've understood something about how the motor works, we're going to combine it with what we saw in last week's lab. We would like to use something like our DAC from last time to provide a variable voltage drop across the motor (to get it to turn at different speeds).

To start, let's build a little 2-bit DAC using the same basic design from last time, using pin 15 on the Teensy to provide V_1 and pin 14 to provide V_2. As with last week, choose values of R that are around 100\Omega or 150\Omega or so.

Note, like we saw last time, that the bottoms of the voltage sources inside the Teensy are all connected together, and they are connected to pin G (ground). Here is a partial view of the internals of the Teensy as it relates to today's lab:

Also connect pin 11 to ground (pin G) through a button, which we'll use to control things.

This connection will allow the Teensy to measure the voltage at pin 11 to detect when the button is pressed. Download lab5_motor_steps.ino and flash it to your Teensy.

Hook the output port v_{\rm DAC} up to your oscilloscope and look at the voltage on the output. You should see it change as you push the button connected to pin 11 (if you're interested, feel free to look at the code to see how that's being done).

Check Yourself 2:

How many distinct voltages can you create by pushing the button? What is the maximum voltage you're able to get? How much are the levels separated by?

Measure these things with the scope, but also verify that they match the values we get by analyzing the circuit (remember that the Teensy can set V_1 and V_2 independently to be either 3.3Volts or 0Volts relative to pin G).

Current Events

Next, we'd like to hook up our motor so that we can control it using the output from our DAC (hopefully getting four distinct speeds). Try pushing the button to move between the four voltage levels and look for motion. Notice the motor isn't turning, even though we saw a voltage earlier that, based on our earlier experimentation, should have been sufficient to turn.

With your scope still set to measure v_{\rm DAC}, try connecting and disconnecting the motor. What happens?

Check Yourself 3:

Why doesn't the motor turn? How does this relate to what we've seen in labs in the last few weeks?

Buffer: The Ampere Slayer

Now let's see what we can do about the problem we noticed in the last section. We've got a nice voltage that we made using our DAC, but as soon as we hook something up to it (the speaker last week, the motor this week), the voltage changes dramatically! In this way, circuits are not modular; adding or removing a single component can affect the voltages and currents throughout the circuit. This can make design quite hard; our design depends on knowing exactly what we're connecting to, and if they change (from the speaker to the motor, for example), we might need to change our circuit. It seems like progress would be impossible...

But luckily, we do have ways to modularize our circuits. One key way we can do this is using devices that act as dependent sources: they measure a value somewhere in the circuit (without changing it much) and set a value elsewhere in the circuit based on that value. In this way, we can isolate various parts of the circuit from one another.

One such device is an operational amplifier, which we'll explore a bit today and learn more about during class next week. One way to model this device is as a voltage-controlled voltage source that measures a voltage somewhere in the circuit and sets a voltage elsewhere. Here is a graphical depiction of one way we can model this device (which we'll see more of in lecture next week):

This kind of separation is really nice; it allows us to measure and use values from a circuit we've built without affecting that value too much, which allows us to think more easily about circuits as being comprised of modules (for example, we might like to think about our DAC as a module that always creates a predictable set of voltages, and then separately use those voltages to drive a speaker or a motor or something).

Schematically, we will usually not draw out of the whole dependent-source model of an op-amp; we have a short-hand version instead, which we'll use throughout the rest of this lab:

As our first foray here, we're going to use an op-amp to act as a buffer that isolates our DAC from the motor. For today, we'll use an L272AM op-amp, which is packaged so that two op-amps fit in one package, as shown below:

The spacing of the pins is such that the package can be conveniently inserted into the breadboard across the gap in the middle, as shown above. Notice that the pins all have distinct meanings, and a dot on the package marks pin 1.

A small "buffer" circuit is shown below. We will learn how to systematically analyze op-amp circuits next week. For now, though, it is sufficient to understand a couple of basic properties of op-amps:

  • the currents into the + and - inputs (called the "non-inverting" and "inverting" inputs, respectively) are small enough that they are essentially zero, and

  • when connected as shown below (with its output pin connected to its inverting (-) input), the relationship between the output and input will cause the potentials at the two input terminals to be equal to each other.

Here is a slightly larger drawing showing how we'll use this idea in today's lab (note that the port labeled v_{\rm DAC} represents the output of your DAC):

Let's go ahead and build it, but let's be careful. Follow these steps:

  • Grab a 9V battery and a connector from the cart.

  • Connect the 9V battery across one set of red/blue rails (the red lead from the battery should go to the red rail, and the black lead should go to the blue rail).

  • Connect the red and blue rails up to pins 2 and 4 of the op-amp, respectively, to provide power to the op-amp. You should be able to orient the op-amp so that short wires can be used to make these connections, like so (and we have these little wires in the cabinet with the resistors):

    Pay close attention to the little "dot" on the op-amp package. It marks pin 1, so in order to make sure that your connections are going to 2 and 4, it needs to be oriented correctly (it's in the lower-left corner in the photo above).

  • Connect the Teensy's ground (pin G) to the 9V battery's gound (the black cable/pin), but do not connect the +9V (red) side of the battery to the Teensy.

  • Wire up the op-amp as shown below, using one of the op-amps in the L272AM package (the pinout for the L272AM has been reproduced here so you don't need to scroll back up). Note that v_{\rm DAC} represents the output of your DAC, and we'll leave v_o disconnected for now (just measure it).

Check Yourself 4:

Use your oscilloscope to measure v_o. How does it compare to v_{\rm DAC}?

Does this behave like you would expect, given the way we've hooked up the op-amp here?

Now try hooking up the motor not to v_{\rm DAC}, but between the op-amp's output pin and ground (as shown here):

Check Yourself 5:

Your motor should be turning now (and its speed should change as you click the button on pin 11).

Check Yourself 6:

With your oscilloscope measuring v_o, connect and disconnect the motor. How does this voltage change as you do so? Why is this result different from when we did the same experiment earlier with the motor on v_{\rm DAC}?

Checkoff 1:

Discuss the results of your experiment so far with a staff member, including:

  • How does the motor's speed relate to the voltage drop across it?
  • Why did the motor not turn when connected directly to v_{\rm DAC}?
  • How does the version with the op-amp "buffer" fix this problem?

Mad Gainz

The buffer above lets us use the signal from our DAC to control the speed of the motor; how exciting! But, unfortunately, the motor doesn't turn very fast here, at least not compared to how fast it was going in our experiments near the start of the lab. Let's see what we can do about that.

Consider the following op-amp topology:

Note that in this topology, we have the same constraints as above:
  • approximately no current flows into or out of the input terminals, and
  • the op-amp will work to set the potentials at the two input pins (labeled $+$ and $-$) equal to each other.
What is the voltage v_\text{out}, in terms of v_in (v_\text{in})?
v_\text{out} =~

Go ahead and replace the buffer on your breadboard with this topology, using the output from your DAC as v_\text{in} (you may need to construct or approximate those two resistor values, but we want something close to the amplification factor from the question above). Then connect up the motor.

After doing so, you should still be able to adjust the speed of the motor, but the maximum speed should be much higher than before.

Checkoff 2:

Discuss the results of your experiments with a staff member.

When you are done, clean up by:

  • taking the little "flag" off of your motor and returning your motor to the front of the room
  • returning the 9V battery and the battery connector
  • SAVING THE REST OF YOUR CIRCUIT. Use some tape and a marker to put your name on the back, and leave your circuit on the very top of the lab bench.
  • throwing away any spare resistors / clipped wires
  • turning off your scope, multimeter, and bench power supply