# 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 http://www.learnabout-electronics.org/Amplifiers/amplifiers42.  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.

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.

## 2015 March 18

### Freshman design projects moderately successful

I just finished grading this year’s freshman design projects. I think that the projects were more successful this year than last year, in part because I kept the students focussed on electronics and programming (for which they had lab access and which I could help them debug), and in part because the projects were somewhat less ambitious.

There were two groups doing EKGs and 4 groups doing blood pressure meters.  Both EKG groups managed to demonstrate their projects working, as did one of the blood-pressure groups.  (I’m being fairly generous here about what “working” means—they had to get their electronics to work, capture the data, and plot the waveforms, but further interpretation or software was not required.)  The other three blood pressure groups did not manage to demonstrate their projects, but one of them managed to plot waveforms for the pressure measurements (without getting their high-pass filter and amplifier working for the pulse measurements).

Some things I learned for next year:

• Tell the students what op amp to get.  A number of students picked op amps that turned out to be rather old-fashioned ones with very low input impedance (as low as 2MΩ), rather limited output ranges, and external nulling circuits. The cheap MCP6002 or MCP6004 chips would have worked better at lower cost.  In fact, I gave one group that seemed to have a good schematic (but couldn’t get their circuit to work) an MCP6002 chip, which they wired in place of the op amp they had been using, and their circuit worked immediately.  I would have done the same for other groups, but the others with poorly chosen op amps were about a week behind and did not have circuits that were that close to being functional.
• Warn students sooner not to use FedEx.  My son’s and my experience with FedEx this year has been that they are ludicrously slow. At least one group was burned by a ridiculously long delivery time, having ordered with FedEx delivery just hours before I warned the class about them.  (The US Post Office is faster and cheaper for lightweight electronics orders from Digi-Key.)
• Students who never ask questions in class probably don’t understand much that is going on—all the groups that successfully demonstrated their projects had at least one active participant in class.
• Students who fail to turn in their progress report are almost certainly not going to complete the project on time—I need to be more assertive in getting them moving and demanding that they show me their schematics.  Almost everyone had errors in their schematics on their first design (and one of the successful groups went through 4 incorrect designs before getting to one that worked).  Students that are afraid to show me incorrect or incomplete work don’t get the feedback they need to correct the problems—I need to normalize errors more and insist on seeing stuff, even if it is wrong.

## 2014 June 26

### Instrumentation amp from op amps fine for EKG

Filed under: Circuits course — gasstationwithoutpumps @ 22:55
Tags: , , , , ,

As I mentioned in Instrumentation amp from op amps still fails, I’ve been trying to decide whether to have students build an instrumentation amp out of op amps in the circuits course.  I decided that it wouldn’t work for the pressure-sensor lab, because of the large DC offset.  One could calibrate each amplifier, either in software (by recording a a few seconds of 0 pressure difference, and subtracting a constant fit to that region from the data) or in hardware, but I’d rather they had a more straightforward experience where the DC offset was small enough to be ignored.

I conjectured that instrumentation amp built from discrete op amps would work ok for the EKG lab, though, as the EKG already has to deal with much larger input voltage offsets due to differing electrode-skin contact.  So I added a second stage  with a gain of 81 to the instrumentation amp in the previous post with a gain of 19, to get a combined gain of 1539.  I put in the high-pass filter needed to eliminate the DC offset, and a low-pass filter to reduce noise slightly (and make aliasing less of a problem).  The corner frequency is a bit high (60Hz noise is not going to be reduced much), but that may allow a better view of the fast R spike in the EKG waveform.

The EKG circuit has four modules: a virtual ground (here set to 0.5v), an instrumentation amp, a high-pass filter to eliminate DC bias, and a second-stage non-inverting amplifier with some low-pass filtering.

The amplifier worked surprisingly well. I did sometimes have trouble with 60Hz noise, but it did not seem to be any worse than the amplifier based on the INA126P. I can remove the noise by digital filtering, though I’ve only played with that by post-processing the data files, not by designing a notch filter to run in realtime on the KL25Z (something to do when I have more time).

Here are a few traces made with EKG circuit above, feeding into the PTE20-PTE21 differential input on the KL25Z board, recorded using PteroDAQ.

This is lead I (LA–RA), without filtering, showing a rather disturbingly large 60Hz noise signal.

This is lead I (LA–RA), showing how the digital filter cleans up the signal. This was Bessel bandpass filtered to 0.3Hz to 100Hz, followed by notch 57Hz–63Hz, followed by notch 117Hz–123Hz. Each filter was a 5th-order Bessel filter, applied first forward in time then backward in time (using scipy’s filtfilt function).

This is lead II (LL–RA), which for some reason had rather low noise even without filtering.

I noticed that sampling at 360Hz allowed me to see a bit more of the structure of the S and T complex than I’ve seen previously, particularly in lead II, and I can even make out a little bump of a U wave just after the T wave.

I now have to decide whether to have students do the EKG amplifier without an INA126P chip, using only op amps. The design will be fairly heavily constrained, as they’ll need to get it all working on a single MCP6004 chip, but it will justify my spending a bit more time on how instrumentation amps work.

I may redesign the blinky EKG to use a single MCP6004 chip also, which would reduce the price of that substantially.

« Previous PageNext Page »