MOSFET Audio Amplifier

The questions below are due on Friday March 01, 2024; 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.
Getting Help

We have a help queue active for lab! Go through the lab, answer the questions on this page, and ask for checkoffs on the queue! When you're all done with everything, you're done! If you get stuck on the way, let us know; we're happy to help!

Remember that labs are intended to be a learning experience, not a test, so take your time and understand things, and please ask us questions as you're working through!

Although we do want everyone to work individually and build their own circuits, it is also more than OK to ask friends/neighbors for help, too.

Take Your Time

The lab is not a race! Take your time, read all the words, try to answer questions (and ask for help if you get stuck, and make sure you understand things before moving on, rather than just racing through).

Danger, Will Robinson

There are some places in the lab where you can cause harm to yourself or your laptop if you're not careful. Seriously, let's not rush through it.

1) Remembrance of Things Past

In last week's lab, we built a digital-to-analog converter (DAC), which let us take purely digital (only "high" 3.3V or "low" 0V) signals from the Teensy microcontroller and turn them into analog voltages that spanned a wide range of possible values. Today, we're going to build on that, and to try to resolve the issue we found with trying to use our DAC to play a song last week.

Our circuit from last week looked like this:

Go ahead and grab your circuit from last week (it should be right where you left it), and grab yourself a speaker if you need to as well. Then download this week's Teensy code here: https://circuits.mit.edu/_static/S24/labs/audio_amp/audio_amp.zip

Upload this code to your Teensy. If you use the oscilloscope to measure v_{\rm out}, you should see a signal moving around as the DAC attempts to play the song. Then if you also hook up a speaker to the port labeled v_{\rm out}, you'll see the signal change dramatically! You should also hear a real banger of a song playing, but it will be playing pretty quietly (much more quietly than we would expect given the roughly-0V-to-2.2V range of outputs we were seeing from our DAC before connecting the speaker).

Last time, we used some of the theory we've been learning to try to explain this behavior. In particular, we modeled the DAC using a Thévenin equivalent and modeled the speaker as a resistor:

Calculating by hand, what is the Thevenin equivalent resistance of your DAC circuit?

R_{\rm TH} =~

Given the R_{\rm TH} value from above, and the measured resistance of the speaker, approximately what fraction of the input voltage (e.g., our song signal) do we expect to see on the output terminal?

\displaystyle{v_{\rm out}\over V_{\rm DAC}} =~

Check Yourself 1:
Use the scope to make some measurements and double-check; is this about the ratio you see when plugging/unplugging the speaker?

Now that we've remembered the problem from last week, let's do something about it. In particular, we'll end up fixing this problem today by using a device that we can model as a voltage-controlled current source, which is really going to let us PUMP UP THE JAMS so everyone on the whole block can hear how cool we are and how great our taste in music is.

Once we've hooked things up, our circuit will look something roughly like the following, from a theory perspective:

This parameter g_m has units of 1/\Omega, which is actually called a siemens but is often humorously referred to as a "mho," for "ohm" backwards (who says that EE's don't have a sense of humor?). The symbols for siemens/mhos is actually a capital S, but it's not uncommon to write it as 1/\Omega or \mho.

We'll take a look at the whole circuit in just a bit, but for now, suffice it to say that we're going to set up our circuit so that we can measure v_1 with negligible amounts of current flowing through R_{\rm TH}, then produce a current elsewhere in the circuit that is proportional to that measurement. By running that current through our speaker, we should be able to produce a much louder sound than before.

Before we move on to building this, let's take a look in theory land first.

Solve for the voltage drop across the speaker in terms of V_DAC, R_TH, R_speaker, and/or g_m, given the circuit layout above.

Notice that in this setup, we get no voltage drop across R_{\rm TH}, which helps us to avoid last week's problem.

2) Unplug Your Teensy From Your Computer

Now that we've remembered our problem and thought a bit about how we're going to solve it in a theoretical sense, let's go about doing it for real.

To start, disconnect the Teensy from your computer. We're going to be doing some stuff that could potentially damage your computer if we leave it connected.

REALLY, ONCE IT'S PROGRAMMED, UNPLUG THE TEENSY FROM YOUR COMPUTER.

Did you disconnect the Teensy from your computer? 

3) Our New Friend, the Benchtop Power Supply

But the teensy needs power to work, and it was getting that power from your laptop before, but we'll grab it from a different place for today, the benchtop power supply, which looks something like this:

We'll need little plugs in both the port labeled CH1 and the port labeled CH2. Yours may not have all the necessary connectors coming out of it; if it doesn't, you can maybe unplug the red and black cables from your multimeter and put them in the other channel (make sure you put red and black in the right holes and DON'T PUT ANYTHING IN THE LITTLE GREEN HOLE AT THE BOTTOM LABELED GND).

When you turn on the supply (the button on the bottom left), 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 channel whose values you're changing can be selected by clicking "CH1" or "CH2".

For now, let's do the following:

  • Make sure all of the little things labeled "On/Off" are off (not lit up)
  • Make sure the "SER" and "PARA" buttons up top are also off (not lit up)
  • Click the "CH1" button if it's not already lit up, and then use the "V" and "A" buttons and the knob to set it to output 5Volts with a current limit of 1 Amp
  • Then click the "CH2" button and repeat the process, but set it to 1.5Volts and 600mA (which should look like 0.6 on the display) instead.

When all is said and done, it should look something like the picture above. If you are having any trouble or just want a staff member to double-check things, let us know!

Then, with your laptop DISCONNECTED (seriously), connect the red wire from CH1 to the pin labeled "5V" on the far corner of the Teensy, and connect the black wire from CH1 to the pin labeled "G" on the other corner of the Teensy.

When you're confident that you've done that correctly, hit the "ON/OFF" button just under "CH1" on the power supply. It should light up and stay lit up, and if you plug your speaker back in, you should hear the song again.

Check Yourself 2:
Do you hear the song? If not, ask a staff member for help.

Check Yourself 3:
Before moving on, turn the power supply back off by clicking the 'ON/OFF' button again. It's a good idea to leave the power supply off when we're building things, and only to turn it back on when we need it.

4) MOSFET? Who's That?

Now that we know how to power our circuit, let's talk about the device we'll be using to complete our circuit today, a metal-oxide-semiconductor field-effect transistor (MOSFET). These devices are everywhere, and they're versatile. They can be used as switches (in digital circuits) or as amplifiers (in analog circuits, which we'll see today).

Compared to other components we've seen so far in the labs, the MOSFET is somewhat complicated. But, lucky for us, engineering is all about selectively ignoring complexity, so we're mostly just going to focus in on the parts that we need for the lab today (though if you're interested to learn more, you should definitely take 6.208 at some point in the future!).

Here is the MOSFET we'll be using today:

And schematically, we'll represent these things like so:

One thing you might notice about this device is that it has three terminals, referred to as the SOURCE (S), the GATE (G), and the DRAIN (D). Let's take a moment to look at the datasheet for this MOSFET to learn a little more about it. There is a lot of information there that you might need if you're working with this device in the future, but for today we'll help you focus in on the relevant parts. Let's start by looking just at the first page of the datasheet. Right at the top, there is a picture showing the device and labeling each of the pins.

What order are the terminals in, looking from the front of the MOSFET like above? ENter your answer as a sequence of letters in the box below, for example dgs would indicate that the Drain is on the left, the Gate is in the middle, and the Source is on the right.

On page 3 of the datasheet there are also some interesting curves shown, which help us characterize the behavior of this device. But oh, no! The curves are all horribly nonlinear and gross, for example, here's the one we're really going to be caring about today, which shows how the voltage drop between the Gate terminal and the Source terminal (v_{\rm gs}) and the voltage drop between the Drain and the Source (v_{\rm ds}) relate to the current flowing from the Drain terminal to the Source terminal (i_{\rm d}):

Oof. Life would be hard if we needed to work with things on that level. But let's not worry too much; engineering is all about selectively ignoring gross details of things. So we don't need to be too worried. We're going to invent a better world for ourselves, where everything is approximately linear. Each of the curves in that picture represents the relationship between v_{\rm ds} and i_{\rm d} for one particular value of v_{\rm gs}. Let's look closely at the second curve from the bottom, just as an example. Note that there is a little region of that curve where it looks almost like a horizontal line:

Let's imagine that that horizontal line continued forever in both directions rather than curving off as it does. What that means is that in that region, the current flowing through this device is constant, regardless of the voltage drop across it. What kind of component does that sound like?

OK, cool! Now let's notice that each one of the curves in the graph has a little region over which this relationship seems to be linear:

So what this is saying is that (under a certain range of values), this device behaves almost like a current source. For a fixed value of v_{\rm gs}, the value of this current source is roughly fixed; but as we change v_{\rm gs} (which moves us from one curve to another in the graph), that value changes as well.

This is not exactly what's going on, but it's a reasonable approximation under certain conditions. So what we're going to do for today is to try to keep ourselves operating in those regions of the graph, so that we can squint our eyes and ignore all the horrible nonlinearities:


 

OK, so let's focus our attention on that little region of the graph. It looks like, if we're ignoring the blurred out regions, then for each of the curves, i_{\rm d} is roughly constant no matter how we change v_{\rm ds}. That sounds like a current source! And, what's more, the specific value of i_{\rm d} depends on the value of v_{\rm gs}!!! So when we're making sure to stay within the region of this graph where things look mostly linear, we're going to assume that we can model our transistor like so:

It's important to note that this isn't actually what is going on inside the transistor. We live in a horrible nonlinear world, and we've already seen that the actual curves the transistor lives on are horribly nonlinear even beyond the ways we've mentioned above (not to mention that they vary with other external parameters like temperature, etc). But that doesn't mean we can't make productive use of it!

This idea is not at all specific to this lab; our love of linearity is one of the things that make us EE's as opposed to other kinds of engineers. When confronted with nonlinearities in the world, we will often make small assumptions or limit our attention to cases where things look linear, which enables us to think about them productively. So for today, we'll assume that the MOSFET is actually working like that voltage-controlled current source, as seen above, and see how far that gets us (if we need to, we can always back up and build a more complex model).

5) Adjusting the Power Supply

But, actually, in order to make this approximation closer to correct, we're going to need to make a little adjustment to the way we're supplying power to our circuit. Our DAC is currently outputting voltages in the neighborhood of 0-2.2Volts, roughly. But for the MOSFET to behave anything like what we're hoping for, we're going to need to make those voltages higher. We'll do this by connecting a 1.5-Volt supply in series with the Teensy, something like this:

We can do this by using both channels of the power supply. If we connect the red side of CH2 (1.5Volts) to the black side of CH1, and then connect the black side of CH2 elswhere on the board. This way, from the perspective of the Teensy, it is still outputting voltages in the range from 0 to 2.2 Volts; but for anyone measuring those values relative to the bottom of CH2, we'll see values around 1.5V higher than that. This change will help us keep the MOSFET in the region of that earlier graph where things mostly look linear, which enables modeling it like a voltage-controlled current source.

Let's go ahead and fill out the circuit a little bit more. Ultimately, this is what we want to build, where the V_{\rm TH} and R_{\rm TH} represent our DAC from last week:

The idea is that we're going to get a current flowing through the speaker that is roughly proportional to the voltage output of the DAC. So we're going to do some measurements to try to verify this, and to estimate the parameter g_m in the VCCS model of the MOSFET:

Try not to bend the pins of the MOSFET as you put it in the breadboard! The usual trick is to push down gently while wiggling it side-to-side, like so:

Go ahead and build that but don't turn on the power yet, and then in the next section we'll add in the scope probes that we'll use to make some measurements in a little bit.

5.1) Measurements

Let's add some measurement probes, using channels 1, 2, and 3. The goal is to measure the voltage v_{\rm gs}, and also to measure the voltage drop across R, which we can use to estimate i_{\rm d} (and, thus, g_m). Let's hook them up like so but DON'T TURN ON THE POWER YET!:

Checkoff 1:
Once you've got the circuit set up, let's have a conversation with a staff member to talk about what we've done so far and about the experiment we're going to do in a second.

6) Party Time

If you turn the power supply on (hit "ALL ON/OFF"), you should see the output of your DAC on channel 1, and you should hear the song...erm, kind of. Actually, if you hear anything at all, it probably sounds pretty terrible.

So what is happening? Well, we're being cruel to the poor little speaker, trying to run more current through it than it would like; and we're also actually being cruel to our MOSFET, too, forcing it outside of the roughly-linear region we're interested in. So let's be slightly less cruel by opening another path for current to flow so that it doesn't all have to go through the speaker.

Let's put a resistor in parallel with the speaker, opening another path for current to flow so as to reduce the current through flowing through the speaker. But don't grab 10\Omega resistors from the usual cabinet! Use the special green 10\Omega resistors we have up front on the cart (they're designed to handle more power without catching on fire).

Go ahead and plug that in; it should make a huge difference!

Check Yourself 4:
Why does adding the resistor in parallel help things here?

Be careful; the resistor and our MOSFET will get hot if we leave this running for too long (hot enough to be painful to touch). So be careful when touching the components. You may also wish to wait awhile between turning the power off and removing the components so as not to burn yourself.

6.1) Characterizing the VCCS

Finally, let's try to characterize the MOSFET by estimating the parameter g_m. We'll do this by comparing v_{\rm gs} and the voltage drop across the speaker, from which we should be able to back out g_m.

We're already measuring v_{\rm gs} on channel 1.

Measuring the drop across R_{\rm speaker} is a little bit trickier, though. Unfortunately, we can't just hook one of the channels across R_{\rm speaker}, since all of the little alligator sides of the scope probes are all connected together internally.

But, fortunately, these scopes give us a way to make that measurement regardless. Note that, as we currently have the probes connected, the drop across the speaker is the difference between the voltages we're measuring on channels 2 and 3. If you click the "Math" button in the bottom left of the scope, you can choose to have it subtract two signals and show that output. That's what we want to do here. So let's subtract channel 3 (on the bottom of the resistor R) from channel 2 (on the top of the resistor R), we should get the drop across the resistor R.

Now, to compare the signals, hit "Run/Stop". Then turn off your power supply (so things don't get too hot) and find a good spot in the signal to measure the voltages on both channel 1 and our math result (channel 2 - channel 3) at that same point in time using your cursors.

Assuming we have a single 10\Omega resistance in parallel with our speaker, solve for g_m. Enter your answer as a symbolic Python expression involving v_1, v_2, and v_3 (the voltages measured on channels 1, 2, and 3, respectively), 10 (for the 10\Omega resistor), and R_speaker (the resistance of the speaker). If you wish, you can use par(x, y) to represent the parallel equivalent resistance of x and y rather than solving for it directly.

g_m =~

Check Yourself 5:
Using the values you measured with the cursors, estimate g_m. Be prepared to discuss your process and your results in your checkoff.

Checkoff 2:

Discuss your results with a staff member. How did you estimate g_m? How is this circuit, as a whole, working?

When you're all done, clean up! For today:

  • Keep your DAC (we're still not done with it yet)
  • return the MOSFET, power resistors, and speaker to the cart at the front of the room
  • if you borrowed a USB cable, we want that back, too

7) (Optional) Choose Your Own Tunes

IF YOU'RE GOING TO DO THIS, COMPLETELY DISCONNECT THE OSCILLOSCOPE FROM YOUR CIRCUIT BOARD BEFORE PROCEEDING. YOU MAY ALSO WISH TO UNPLUG YOUR LAPTOP IF YOU HAVE THE BATTERY TO DO SO.

If you want to, we also have a way for you to load your own tunes onto the Teensy. You can use this site to convert a portion of a youtube video to the right format for this lab, which you can download and then reflash to the Teensy!