Gas station without pumps

2015 May 5

First op-amp lab was quick

Filed under: Circuits course — gasstationwithoutpumps @ 21:12
Tags: , , , ,

On Monday I provided a little feedback on the design reports for the electrode lab.  The big issues were

  • Students not reporting the models they were fitting to the data.
  • Students not reporting the parameters of the fits after doing the fitting.
  • Students choosing overly complicated models (like R+(R||C) for data showing constant impedance)
  • Students not modeling important phenomena (like the (R||C) input impedance of the voltmeters)

Little issues included

  • Using “due to the fact that” rather than “because”
  • Omitting leading zeros before a decimal point.  Numbers should never start with punctuation.

After that brief intro, I worked with the students to develop a block diagram for an audio amplifier using the electret microphone and loudspeaker that they had already characterized.  This had been part of their homework, but I expected them not to have really grasped the point of a block diagram.

Another thing I went over in class, because I’d seen problems with it in previous reports and prelabs ,was reminding students that V=IR is not a ritual magic incantation. Reciting it doesn’t make solutions to problems right, if it is just randomly applied.  I reminded them that the voltage has to be across the resistor that the current is through—picking random voltages or currents in the circuit is meaningless.  I showed them an example taken from the prelab they were turning in at the end of class.

When I did the grading for the prelab homework Monday night, I saw that many of the students managed to copy the block diagram we had done in class, but none had appropriately labeled the signals between the blocks.  I think I need to provide some more and better examples in the book.  (Ah, I see I already have marginal notes to myself to add a couple in Chapter 2.)

The V=IR error was very common, mostly with V was taken to be the power supply voltage, rather than the voltage across the resistor that biases the microphone.

Students also had a lot of trouble with computing the AC voltage of the signal out of the microphone, based on the loudness of the sound input and the sensitivity of the microphone. I knew this was a difficult assignment, but I thought that it would be relatively easy, because they had supposedly already created a worksheet for themselves as part of Lab 4 (the microphone lab).  Either they forgot everything they learned there, or they never really got the idea of the worksheet they created.  One student asked in class on Monday, quite reasonably, for a worked example.  I’m going to have to come up with one that doesn’t just do all the work for them—I know these students can fill out worksheets, but what I need to get them to do is to solve problems when the steps aren’t all set out for them.

The afternoon lab section (many of them working together) did much better on the prelab than the morning section—the difference between the sections has been noticeable from the beginning, but it seems to be getting bigger, not smaller.  For some reason the descaffolding is working better with the smaller section.  Individuals in the morning lab are doing quite well, but there are more floundering students in that section, and I don’t know how to get them back on track.

Even though the morning lab is struggling more than the afternoon lab, I think that both are doing better than previous year’s classes at this point of the quarter.  With only one or two exceptions, everyone in both lab sections got their op amp circuit designed, wired, and demonstrated within the 3-hour class period.  That means that Thursday’s lab can be a tinkering lab for most of the students, where they can try various ways of improving the design:

  • Switching from a symmetric dual power supply to a single power supply.
  • Paralleling two op-amp chips to get twice the current capability.
  • Adding a potentiometer for variable gain.
  • Adding a unity-gain buffer to separate the loudspeaker driver from the gain amplifier.
  • Adding a tone-control circuit, like the Baxandall tone control on  They can’t use exactly that circuit, as they have only 10kΩ potentiometers, not 100kΩ ones.  The idea can be adapted, or the students could do simple treble-cut or bass-cut circuits.
  • Using a loudspeaker as a microphone. I think that should work, as I get about a 500µV signal from my loudspeaker when I talk into it.  The don’t need any DC bias for the loudspeaker mic, and they may even be able to eliminate their high-pass filter, as the loudspeaker mic can be set up to have its output already centered at 0V.

I’ll talk about some of these possibilities in class tomorrow (plus stroking the students a bit about getting the lab done quickly). I attribute he good performance on the lab to them having put in more time on the prelabs, even if they didn’t get the answers to the questions exactly right.  Thinking about the design ahead of time (and getting a little feedback) goes a long way toward clearing up confusion they have had.

There are 4 more amplifier labs coming:

  • Instrumentation amps with a strain-gauge pressure sensor (measuring breath pressure and blood pressure using an arm cuff).  Will need to be 2-stage, since the INA126PA chips we are using aren’t rail-to-rail amplifiers.
  • Transimpedance amplifier fora photodiode to measure pulse.  This will also need to be multistage, since the first stage will have to have limited gain to avoid saturation.  After high-pass filtering much more gain will be needed.
  • Class-D power amplifier.  This is always the toughest lab of the year.  Even small mistakes can result in shoot-through current that gets the FETs hot enough to melt the breadboards (I have two breadboards that I’ve melted holes in).
  • EKG using only op amps (making their own 2-op-amp instrumentation amp, plus high-pass filtering and a second gain stage.  They’ll be using all 4 of the op amps in the quad op amp package for this amplifier.

I’m about a week behind on grading redone assignments—weekends are spent grading design reports, Monday nights grading prelabs, weekends plus Tuesdays adding to the book a chapter ahead of the students, and I squeeze in the redone assignments Wednesday or Thursday night, if I don’t crash too early.

2015 May 3

Ag/AgCl electrode lab went ok

Filed under: Circuits course — gasstationwithoutpumps @ 23:15
Tags: , , , , ,

Like on Tuesday, on Thursday I spent a long time in the lab, from about 9 a.m. to after 6 p.m., because it takes a fair amount of time to set up and clean up when we are dealing with liquids (in this case, salt water) in the electronics lab.  The lab itself went fairly smoothly and the students all seemed to be collecting good data.

As I feared, we ran out of one of the 4 stock solutions: 3l per concentration for 28 students was not enough, unless students shared by transferring solutions from one group to another.  Next year I’ll have to get 200ml/student made up, or change the way the lab is run so that students have 6 sets of cups already pre-poured, and just grab a cup that they haven’t already used.  I worry a bit about careless students not cleaning and drying their electrodes between uses, though and contaminating a low-salt solution with salty electrodes.

I had one surprise this year.  We changed which brand of EKG electrodes we ordered (from Vermed to some foam-backed electrode with no brand name—not a substitution I remember approving, but I probably would have if asked).  It turns out that the new electrodes do not seem to be silver/silver-chloride.  Instead of resistance around 10Ω as the Vermed electrodes have, the new ones are in the 10MΩ range.  They must be using some polarizable electrodes instead of non-polarizable Ag/AgCl.  I hope that they work ok for the EKG lab at the end of the quarter (10MΩ should be ok, as the instrumentation amps and op amps have input impedances of 1GΩ and 10TΩ respectively, so a mere 10MΩ resistance should be negligible).

I am going to have to rework a big chunk of the book this summer, though, as the measurements ran into trouble with the input impedance of the voltmeters not being too large to matter, as we usually assume.  The AC voltmeters claim to have 1MΩ  || 100pF, which is great at low frequency but at 1MHz, that’s only 1.6kΩ.  The 1MΩ is tightly specified, but I believe that the 100pF is only an upper bound: there may be considerable variation in the capacitance from meter to meter.

The students who were attempting to measure the impedance of the new foam-backed EKG electrodes were probably actually measuring the impedance of the voltmeter.  Several of the measurements of the stainless-steel electrodes were also marred by the input impedance of the voltmeters.  On Tuesday afternoon, if I have any spare time in the lab, I’ll try measuring the input impedance of the voltmeters myself, to see what it looks like.  The test setup will be a simple one: two voltmeters in series, driven by a function generator.  I’ll shunt one of the voltmeters with a smallish resistor (say around 500Ω) and plot the ratio of the two voltages as a function of frequency (I’ll need a moderately high voltage from the function generator to make sure that the voltmeter on the shunt has enough voltage).  The voltage ratio should follow a simple pattern: \frac{V_{meter1}}{V_{shunt}}=\left| \frac{Z_{meter1}}{R_{shunt} || Z_{meter2}} \right|.  I can model the meters as a 1MΩ resistor in parallel with an unknown capacitor and fit the parameters (trying both meters having the same capacitance, and having different capacitances).  I can even do another set of measurements swapping which meter I shunt.

I think that a lot of the weird data we saw in Tuesday’s lab came from using large shunt resistors, so that the voltmeter impedance became more important (smaller) than the shunt resistor.

I’m considering also putting in the book a derivation of how to compensate for the meter impedance (if it is known).  I think that I’ll move the electrode lab later next year, closer to the EKG lab, so that we can go more directly from the microphone lab and the loudspeaker lab into the audio amplifier lab, and so that the electrode characterization is more immediately motivated.

In Friday’s lecture, I talked briefly about the possibility that the problems we were seeing with model fitting were that we had neglected the voltmeter input impedance, but I did not work out the details, because I had to introduce them to op amps and negative-feedback amplifier configurations.

I like to use a generic negative-feedback configuration, which includes inverting and non-inverting amplifiers as special cases, as well as the single-power-supply variants:

Generic negative-feedback amplifier design using op amps.

Generic negative-feedback amplifier design using op amps.

On Friday we got through the derivation of the various gain formulas, based on letting the open-loop gain go to infinity, but I’ll have to refresh that on Monday and introduce the unity-gain buffer: especially the unity-gain buffer as a voltage source for a reference voltage between the power supply rails.

2014 May 10

Second op amp lecture

Today’s lecture was the second one on op amps, after their audio amp lab.  I had 3 topics I wanted to cover: virtual grounds, transimpedance amplifiers, and gain-bandwidth product.  The gain-bandwidth product doesn’t really fit with the others, but they had just learned about voltage and current limitations in the audio-amp lab, and the only signals they use all quarter of high enough frequency for the gain-bandwidth product to matter are the audio signals—the heartbeat and breath pressure signals are very low frequency (DC to 20Hz bandwidth).

Before getting to the electronics part of the content, I did talk a little about the reasons I gave them such a long multi-step computation for the prelab last week, where they had to work through 8 or 9 steps to come up with the desired gain.  I explained that I knew they could do single-step problems, but that the quiz showed that they were having trouble putting their knowledge together to do two-step problems, so by giving them practice with long multistep problems, I was hoping to make two-step and three-step problems seem simple. Next week’s optical pulse monitor lab will again require a lot of steps, mostly in figuring out how much light gets through a finger.  This sort of computation (how big a physical signal is, how sensitive a sensor is, and how much gain is needed to observe and record the signal) is fundamental to the sensor interfacing that is the heart of the course, so I’m not apologizing to the students for the complexity of the task.

I started with virtual grounds, pointing out that next week’s lab would be powered off the KL25Z processor boards, which provide only 2 voltages: 3.3v and ground, so that they don’t have a symmetric power supply.  I drew a schematic for a non-inverting amplifier (gain 11, though that was irrelevant), with a 1.65v “virtual ground”, then we talked about how to get a 1.65v source.  I took the time to tell them about the existence of low-dropout voltage regulators, (LDOs)  and that those chips were how the KL25Z board produced 3.3v from the 5v power that came over the USB line.  I also told them that the LDO chips were capable of sourcing current, but not really capable of sinking current.  (I’m actually not sure whether they are incapable of sinking current—it would be possible to design a chip capable of both, with a small voltage change between the two directions of current flow to avoid excessive flow-through current.  I don’t think that chips normally have that capability, though.) I also told them that they did not have an LDO ship in their parts kits,  and challenged them to come up with another way to generate 1.65v from 3.3v.

Deer-in-the-headlights look.

After a fairly long wait, I asked them if they could produce 1.65v if they did not need to draw any current from it.

Deer-in-the-headlights look.

After a lot of random guessing, someone finally guessed “voltage divider”.  (I’ve told them almost every week that we have three concepts in the class: voltage dividers, complex impedance, and negative-feedback op amps, and they’ve been guessing voltage divider for almost every circuit question for 6 weeks, so I was surprised at how hard it was for them to see when a voltage divider would actually be appropriate.)  Once that guess was made, they quickly came up with two equal resistances.  I then showed them why sourcing or sinking current would cause the voltage to vary (by showing mismatched currents through the two resistors—I don’t know whether any of them got it though, as they seem to still be almost incapable of mapping any sort of math to the phenomena the math models).  I challenged them then to come up with a way to provide the same voltage but allow current to be drawn.  This took less time than before, with a student deciding that an amplifier was needed and remembering the unity-gain buffer from last week.

I was expecting students to have more trouble with the unity-gain buffer than with the voltage divider, because they’ve been using voltage dividers for 6 weeks, and this is the first time they’ve needed a unity-gain buffer. But it seems that recency trumps repetition in student thought—they are so inured to cram-and-forget learning strategies fostered by “unit-based” course organization that each new idea displaces all previous ones.

Almost all the useful ideas came from one student, though most of the class was participating. I’m worried that only that student is learning the material, and that I’m not reaching the rest.  (His group is usually the first to finish in lab also, no matter whom he is partnered with.)

After we had a virtual ground circuit consisting of a voltage divider and unity-gain buffer (and I reminded them of how the unity gain buffer worked), I pointed out that this virtual ground circuit was limited in the amount of current it could source or sink by the current capabilities of the op amp, which they had already encountered in seeing the difference in their audio amplifier outputs between having the 8Ω loudspeaker and not having it as a load.  For the MCP6004 chips they are using, with a 3.3v power supply, the current limit is about 15mA.

I also introduced them to another sort of voltage reference, using a Zener diode in place of the lower resistor in the voltage divider.  I think that this was a mistake though, as I may have confused them by giving them too much information.

After the virtual ground, I switched to talking about gain-bandwidth product.  I pointed out that the gain they had been getting was limited by the voltage rails and current limitations of the op amp, but that there was another limitation that affected the audio amplifier: a built-in low-pass filter that limited the open-loop gain.  I explained that the filter was there to prevent high-frequency oscillation due to stray parasitic feedback, but I did not even attempt to explain phase changes and oscillation—we’re sticking with amplitude for almost all analysis in this course, as their understanding of complex numbers is shaky enough that even that is stressing their skills.  I plotted the gain vs frequency on a log-log scale, which looks exactly like the low-pass RC filters they have seen already (at least in the range of frequencies they’ll use—there is usually a second-order effect with a steeper rolloff at frequencies above where the gain is less than 1).  I pointed out that the sloping line was proportional to 1/f, so that the gain times the frequency was constant (the gain-bandwidth product). For the MCP6004 chips, the gain-bandwidth product is 1MHz.

The gain of a negative-feedback amplifier is limited by the open-loop gain, so at 20kHz, their amplifiers could not produce a gain higher than 50.  I explained then the notion of multistage amplifiers, where each stage provides part of the gain (and possibly other functions, like filtering, level changing, or current-to-voltage conversion) as a way around the gain-bandwidth-product limitation.

We then switched to transimpedance amplifiers.  I first broke down the word into “trans-” and “impedance”, and explained that the “trans-” prefix here meant output/input (so opposite sides of the amplifier).  Since these are bioengineers, they are used to the “trans-” prefix from chemistry.  I asked them for the definition of impedance, and got the voltage/current definition from them after a few false starts.  So a transimpedance amplifier is one that provides a voltage output from a current input, and its gain is expressed in Ω (that is, volts/amps).

I pointed out that the pullup resistor in the microphone circuit that they had been using was a current-to-voltage converter, but that the voltage across the microphone varied with the current.  The microphone needs a nearly constant DC voltage across it, but the current fluctuations (around 1µA) were small compared to the DC current (around 200µA), so the voltage across the mic was nearly constant.  The devices they’ll be using next week (photodiodes and phototransistors) have essentially 0 current in the dark, so the signal is not a small fluctuation on a large DC current.  If we want to keep a nearly constant voltage across a photodiode or phototransistor, we can’t use a simple pullup.

So the transimpedance amplifier is needed not just to convert current to voltage, but to hold the bias voltage constant as the current changes.

I then tried to get the students to develop the transimpedance amplifier design from an op amp using the design goals. I started by asking them about the inputs of the op amp, trying to get them to remember that the negative-feedback circuits tried to bring the negative input to the same voltage as the positive input.  They’ve not had enough practice with op amps yet to have that useful rule of thumb easily recalled, so we ended up deriving it again.I started with asking them about what a bare op amp did.  It took a while before someone could come up with amplification of the difference between the two inputs.  I asked them what the gain was (looking for answers like “a lot” or “the open-loop gain”), but again got deer-in-the-headlight looks.  I ended up feeding them the answer to this one, as I ran out of Socratic questions to lead them to a good answer, and their guessing started getting wild.

I then asked them what keeping the output well within the power rails implied about inputs.  This took a while, but eventually one student realized that the difference has to be the output divided by the open-loop gain. (And yes, it was the same student.) So I was able to point out that a very large open-loop gain meant a very small difference in the input voltages, and that one could use as a rule of thumb that the inputs to an op amp in a negative feedback circuit was at the same voltage.

This got the student to the point where they figured out that the bias voltage could be put on the positive input and the current input whose voltage needed to be controlled on the negative input, but then they stalled again.  I pointed out that op amps were designed to have essentially no current through the input pins (about 1pA for the MCP6004 chips at room temperature), so the current on the input had to come from somewhere.  I don’t remember now whether a student suggested a connection to Vout or whether I gave them a resistor to Vout as a solution.

I then tried to get the students to figure out the behavior of the transimpedance amplifier from the current through the resistor.  They needed to realize two things:

  • That the voltage drop across the resistor was Vout-Vm
  • That the current through the resistor was the same as the current through the input port.

It took them a long time to get each of these—they kept wanting to make the voltage drop be just Vout. Physics classes do not seem to be doing a good job of getting across that notion that voltage is always a difference between two nodes in the circuit and I haven’t been able to make that an automatic response yet after 6 weeks—that must be a harder concept than I would have thought.

Even after they finally got the voltage drop right (yes, it was the same student), no one could come up with the idea that the current had to be the same as the current through the input.  I finally had to give it to them, pointing out the hint on the board—I’d drawn both currents with arrows on the board and had labeled them both “I”.  I reminded them of Kirchhoff’s Current Law, and pointed out that since no current flowed through the op-amp any current through the input port had to also be flowing through the resistor.

We then had the final formula: V_{out} = V_{p} + R I, and I could point out that the gain of the transimpedance amplifier was just the feedback impedance, R.  Since we were out of time at this point, I just mentioned two applications of transimpedance amplifiers they might have heard of—the nanopore lab and the nanopipette lab (where many bioengineers do their senior theses) both use very high gain transimpedance amplifiers (patch-clamp amplifiers) to measure currents in the 1–100pA range.

On Monday I’ll have to go over photodiodes and phototransistors, and probably repeat the transimpedance amplifier with a photodiode or phototransistor as the current source. I did direct them to do the prelab homework over the weekend, since we can’t afford to waste the entire Tuesday lab time doing the prelab as they did this week.  I’ll ask them on Monday about what results they got and where they bogged down in the computation—I expect that most of them will not have completed the prelab assignment, but I’ll be very disappointed if none of them have tried it.



2014 May 2

First op amp lecture

Filed under: Circuits course,Uncategorized — gasstationwithoutpumps @ 19:06
Tags: , , ,

Today’s lecture was the first introduction of op amps to the students.  I managed to present

  • The basic notion of a differential amplifier: V_{out} = A (V_{pa} - V_{ma}).
  • Generic negative feedback amplifier.

    Generic negative-feedback amplifier design using op amps.

    Generic negative-feedback amplifier design using op amps.

  • Formula for voltage divider when none of the nodes are ground. (I had the students derive this.)
  • Formula for negative feedback with effectively infinite open-loop gain (deriving V_{out}= (V_{p}-V_{m}) Z_{f}/Z_{i} + V_{p})
  • Inverting, non-inverting, and unity-gain configurations.

I even had the students figure out how to make an amplifier with a gain of 0.5. The design they came up with was a unity-gain buffer followed by a voltage divider, though they started with a voltage-divider followed with a unity-gain buffer.  If we had had more time, I would have gotten them (eventually) to come up with a pair of inverting amplifiers.

We’ve talked about the voltage limits on Vout, and about Vp having an extremely large input impedance, but we’ve not talked about the input impedance of inverting amplifiers, about current limitations of the output nor output impedance, nor about slew rate or gain-bandwith product.

We will  talk about current limitations on Monday, since those do matter for the audio amplifier design they’ll be doing next week.


%d bloggers like this: