# Gas station without pumps

## 2014 May 30

### Class-D amplifier lab done, EKG block diagrams begun

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

Yesterday’s lab ran long (as expected), because students had not gotten enough done in Tuesday’s lab.  But everyone in the lab did get a working class-D power amplifier.  Several also managed to measure the turn on and turn off times for the comparators driving the FETs, though that required some hands-on guidance in using the digital scopes (setting the trigger level to the FET threshold voltage, then looking to see how long the rise or fall was before reaching the trigger level.  As expected, everyone had chosen values that made the pFETs turn on and off quickly, but it was difficult to get the nFETs to turn off quickly.  I don’t know whether anyone managed to equal turn on and turn off times for the nFET (they turned on fairly fast), but several groups managed to keep their FETs cool.  Even those with warm FETs did not dissipate so much in them that they got dangerously hot.

I’ll be reading the design reports over the weekend, and I’ll see whether the students really understood PWM or not.  I suspect that about half the groups understood what they were doing well enough, and the other half got part of the ideas.  There should be time on Monday to review the idea of PWM and to explain again why it is a good choice for efficient power delivery, particularly for inductive loads.

Today, I returned the quiz 2s redone as homework.  Students did fairly well on them as homework (range 18.5 to 31.5 out of 36, up from 7 to 17 on the timed quiz).  The biggest difficulty was with the last problem, which asked them to design a simple amplifier, giving both a block diagram and a schematic.  A lot of students did not understand the question as I phrased it, perhaps because I had not been clear enough earlier in the quarter about what a block diagram means and how to use it.

Students have not yet internalized the idea of something having inputs and outputs, and a block diagram being a refinement of an I/O spec into I/O specs for subunits.  I may need to use that language more explicitly earlier next year. I’m thinking also that I need to add more text to the lab handouts next year and refer to them as a draft textbook rather than as lab handouts.  How many pages do I have so far?

handout pages
01-thermistor  11
02-microphone  9
03-hysteresis  11
04-electrodes  7
05a-loudspeaker  8
03b-sampling  7
06-audio-amp  6
07-pulse-monitor  11
08-pressure-sensor  8
09-power-amp  13
10-EKG  5
total  100

One hundred pages is a bit short for a textbook, but there is a lot of explanatory material still missing (most of which I provided in class or in lab). If I worked on it diligently over the summer, I could probably create a book with most of what the students need that would be around 200 pages. Do I have the energy to turn this into a textbook? Is it worth the effort?

After going over the block diagram of the quiz problem, I helped the students develop an EKG block diagram.They did get to the realization that the unknown but potentially large DC offset from the EKG electrode half cells limits the gain that they can ask from the first stage of the EKG, and that they’ll have to high-pass filter and add more gain.  The design is similar to their pressure sensor instrumentation amp, but the gain needs to be higher (1000 to 1500, rather than 100 to 250), and the pressure sensor amplifier had to go down to DC, so did not include a high-pass filter.

I was a little worried that I may have suggested too high a lower end for the passband (0.1Hz to 40Hz).  They’ll get less baseline drift with a 0.5Hz cutoff instead of 0.1Hz.  My EKG designs have used 0.05Hz—88.4Hz and 1.0Hz–7.2Hz for the blinky EKG.  Both worked ok, but I now think that the 7.2Hz cutoff is too low (it was adequate for blinking an LED, but not for recording the waveform).  Since I did not have much problem with a 0.05Hz corner frequency, I think they’ll be ok with a 0.1Hz one.  The blinky EKG circuit has an adjustable gain (needed to make the R spike large enough to light the LED), but it is probably better to have a fixed gain.

It would be really nice if they could finish the EKG on Tuesday, since the annual undergraduate poster symposium is scheduled for the same time as the Thursday lab, and I always like to spend an hour or so looking at the posters.

## 2014 May 5

### Block diagrams and audio amps

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

In today’s lecture, I introduced the notion of block diagrams as having two types of objects: functional blocks and connections between them. I emphasized that both parts were equally important, though computer programmers tended to focus more on the connections and electrical engineers more on the blocks.  I pointed out that basic action of decomposing an engineering design problem into separable subproblems was common to all forms of engineering, and so block diagrams were a common notation in almost all branches of engineering.

I also pointed out that block diagrams were only useful as a tool if they had a reasonable number of blocks (say 3–10), so that the system was broken into manageable pieces, but could still be viewed as one coherent system, not a rats’-nest of tiny components and wires.

As a class, we then developed a block diagram for and audio amplifier, starting from the overall task (sound in, louder sound out) and working our way inwards.

I spent quite a bit of time at each connection.  For example, for the sound in we talked about dB, dBA, and sound pressure levels.  I did not remember the reference value for 0dB of sound, but I have it in the lab handout (20µPa RMS).

We then talked about the sensitivity of the microphone, which we treated as a sound-to-current converter (with units being A/Pa).  I pointed out that the data sheet for the microphone we used did not give sensitivity in that form, but in dB for a reference of 1v/Pa, even though the microphone is a current output, not a voltage output device!  I explained that the data sheet used a current-to-voltage conversion of 2.2kΩ, though there is no particular reason to choose that value.  We also talked about the DC voltage or current bias needed for the microphone, which is much larger than the small AC signal.

The students realized that they needed a high-pass filter for blocking the DC, and realized (after a moment) that the voltage divider circuit meant that the input and output of the DC blocker meant that the microphone’s current output needed to be converted to a voltage.  Luckily, they’ve already designed a simple pullup resistor for current-to-voltage conversion, as well as a simple RC high-pass filter, so they should have no trouble doing so again.

We then jumped to the other end of the circuit and looked at the model for speaker.  I talked them into using the simplest possible model (just an 8Ω resistor), which is reasonable if we limit the frequency to 200Hz to 10kHz (adequate for speech, but not for music).  If we directly connected the circuit so far to the speaker, the students estimated that the signal would be less than a microwatt, so clearly not of much use for driving a 10w speaker. We also looked at the maximum voltage or current we’d want to apply to the speaker, to keep within the 10W RMS limit.

We then added a gain stage, which the students initially wanted to make a gain of about 4000.  I pointed out that voltage out of the op amp was limited to staying between the power rails, and that the MCP6004 op amps they have don’t have a very wide power supply range. I also pointed out that we did not want to exceed the current limits for the op amp, as that could clip the signals and distort them.  So they will need to choose a gain that will amplify the loudest sounds at the microphone to stay within the current limit of the op amp driving an 8Ω load.

Here is the block diagram they came up with:

Audio amplifier using an electret mic.

One student asked a very good question—what do you do if you want more sound than the maximum current from the op amp? I told him that we would address that question in a later lab: the class-D power amp lab.

I told the students to flesh out their block diagram to a detailed schematic (with component values!) before tomorrow’s lab, so that they could spend the lab time building, testing, and debugging the amplifier. I think that they will try, but they will bog down somewhere in the multi-step process of designing the amplifier. I’m guessing that half of the class will have the structure right, but that no one will get reasonable values for all the components.

I have told them that I expect them to come up with expectations for what they should see at each point of their circuit, so that they can compare what they see on the oscilloscope with what they expect, and use the discrepancies to help them debug.

## 2014 February 19

### Twelfth day of freshman design seminar

Filed under: freshman design seminar — gasstationwithoutpumps @ 23:12
Tags: , , ,

My counts of which days were which in the freshman design seminar were all messed, so three of my blog posts were misnamed:

date which day of class blog post
Mon 2014 Jan 6 1 First day of freshman design seminar
Wed 2014 Jan 8 2 Second day of freshman design seminar
Mon 2014 Jan 13 3 (Baskin lab tour) Third day of freshman design seminar
Wed 2014 Jan 15 4 Fourth day of freshman design seminar
Wed 2014 Jan 22 5 Fifth day of freshman design seminar
Mon 2014 Jan 27 6 Sixth day of freshman design seminar
Wed 2014 Jan 29 7 (Biomed lab tour) Biomed lab tours and online discussions
Mon 2014 Feb 3 8* Seventh day of freshman design seminar
Wed 2014 Feb 5 9 no post (ill and group tutor ran class)
Mon 2014 Feb 10 10* Ninth day of freshman design seminar
Wed 2014 Feb 12 11* Tenth day of freshman design seminar
Wed 2014 Feb 19 12 Twelfth day of freshman design seminar (this post)

Today we started by having the students turn in their Arduino programming homework, then start writing the program as a group. I told them that I particularly wanted those who had trouble with the assignment to provide input—I’m trying to get them to realize that questions and confusion are normal, and that the right action to take in college is to ask questions, rather than to hide ignorance.

This particular assignment was expected to be hard for them—I had not done the scaffolding for it that I had originally planned, but threw them into it with very little preparation. I told them that, but also that I was trying to get them used to looking things up and figuring them out, rather than waiting to be told exactly what to do. Again, I’m trying to get them out of the “regurgitate what the teacher said” mode that K–12 education has trained them into. If I accomplish nothing else this quarter, I hope to increase their willingness to ask questions (of their teachers and of the things they read).

We did get the program written, with some digressions into the difference between “==” and “=” in C++ and the convention in C and C++ that 0 is false and any other value is true. I also managed to work in the importance of good variable names to tell people what things meant, though this particular program doesn’t need any variables.  The students now have the notions of serial execution, conditional expressions, if-statements, digital I/O, serial communication (we had a digression into baud rate), and the Arduino setup/loop structure, which may be enough for their projects—they may also need analogRead(), which I should be sure to demo on Monday.

I then typed in the program we had created together and demoed it with Arduino. I had deliberately left in a bug that I had spotted (no space between the printing of the different fields), and the class spotted it and came up with a reasonable correction when the first output came out.

We only had about 10 minutes left, so I gave them feedback on their project proposals:

• Type homework for college classes!  Two of the groups had turned in hastily scribbled notes.
• Give explicit specifications for the project.  How big an incubator? How precisely does the temperature need to be controlled? How fast does temperature have to change for PCR? What temperatures are needed and how precisely? How many tubes need to be run through the PCR machine at once?  How much acceleration does the centrifuge need to produce? How precisely does the speed need to be controlled?
• Provide a block diagram giving all the components of the system (power supply, motor, fan, rotor, temperature sensor, … ) and lines showing the connections.  I talked about the importance of specifying the interfaces between components so that people could work simultaneously on different parts, and the need to renegotiate interfaces if the initial specification of them caused problems.

We talked a bit about prototyping—I want them to build something and learn enough to make an improved design, even if they don’t get a fully functional prototype.

For Monday, I assigned them the task of fleshing out the specifications for their project and producing a block diagram, filling in as many details as they could.  The group tutor is going to try to find time to meet with each group for an hour before then, to help them with flesh out their designs.

## 2013 March 2

### Quiz 2, better than quiz 1

Filed under: Circuits course — gasstationwithoutpumps @ 18:19
Tags: , , , ,

In Quiz too long and too hard, I reported on the first quiz of the circuits course, and how I had made it much too tricky for the course.

Yesterday I gave another quiz covering the material of the first quiz (impedance, voltage dividers, low-pass and high-pass RC filters) plus some new material on inverting and non-inverting amplifiers using op amps.  I also asked a fairly big design question that ended up being worth about 40% of the points:

Design a circuit that takes an AC input signal with a frequency above 1Hz and below 50kHz that is centered at about 1v and has a swing of ±100mV, and provides an in-phase AC output signal that is centered at 2.5V and has a swing of ±1V. (Note: “in-phase” means that the signals move up and down together.) Draw a block diagram of your design and a schematic.  You may assume that you have an external 5V power supply.

I was aiming for a test that would have a mean of 50% and a standard deviation of 20%, for a “typical” class. (Of course, given that this is the first time I’ve taught the class, I still have no calibration for what a typical class should look like, so I’m basing my estimates on where I think the current class should be, given what we have covered). I knew from taking the quiz at the same time as the students that it was a bit too long. It took me 26 minutes to do all the problems, and they had 70 minutes. I usually figure that I should be able to do their 70-minute quizzes or exams in 20 minutes, so the quiz was about 30% too long. The group tutor for the class also took the quiz, and I graded both his quiz and mine before grading the class. I gave myself 95% (I’d done a divide by 2π instead of multiply by 2π in one place, and my schematic was missing some labels and a capacitor to keep the virtual ground low-noise). I gave the group tutor 65%, which was a little lower than I expected from him (though, of course, he has not been studying for this course, but just relying on what he has learned in previous courses). His score was still higher than anyone taking the class got.

I just finished grading the quiz, and the mean was 38.55 with a (sample) standard deviation of 14.6 (out of 100 points), range 13–60, median 35. I had to be fairly generous in my partial credit for the design problem, looking for pieces of the circuit that made sense, as no one got the entire design right. A lot of the block diagrams were nonsense, looking more like random collections of ideas than a block diagram (the people who teach “mind mapping” have a lot to answer for). If we correct for the quiz being 30% too long, it looks like the difficulty level was about where I intended it to be, at least with the generous grading.

I’ll have to assign letter grades to everyone on this quiz (I didn’t for the first quiz—since I decided not to count that quiz after I saw how poorly everyone did on it), and I’m not sure where to make the cut points. The highest scorer in the class was still only what I’d consider a B+ performance—the design problem was not bad (about 2/3 credit), but there were a lot of errors in the earlier, more straight-forward problems. At the low end, I need to decide whether then 13 is a low pass or not passing, and what grade to give the second lowest score—it was clearly passing, but at what level?

[Correction 2013 Mar 3: I regraded some of the quizzes, looking to see if there was any partial credit I had overlooked on the first pass.  This made a big difference at the bottom of the distribution, changing the range to 22–60,  µ=39.45,  σ=13.1.  With those changes, everyone passes.]

I had graded the quizzes a problem at a time, not looking at the names of the students, so I was curious to see how students ranked compared to how they’ve been doing on the lab reports. As it turned out, I was not surprised by the identities of the top and bottom scorers, but some of the other ranks surprised me a bit, with one of the students whose lab reports were generally poor being near the top of the class on the quiz, and one whose lab reports where generally fairly good near the bottom.

## 2013 February 25

### Twentieth day of circuits class

Filed under: Circuits course — gasstationwithoutpumps @ 17:41
Tags: , , , ,

We started today with a do-now problem, asking what the following circuit does:

After 5 minutes, no one had any idea, so I asked questions until we got that In had a voltage of 0V, that the interesting property of In was its current, and that the same current flowed through R1. Then I gave them another 5 minutes. At that point, one or two students had an inkling that the circuit was a current-to-voltage converter, and one student even suggested that $V_{out} = I_{in} R_{1}$, which was almost right. I had draw the current into the circuit from In, so the output voltage was the negative of that. I walked them through the analysis that leads to that conclusion.

Then one student asked the obvious question—the one I was hoping a student would ask—how this differed from just using a pullup resistor as we had done for the electret mic.  So I tried to get them to compute the input impedance $V_{in}/I_{in}$.  After a great deal of difficulty, they came up with 0Ω.  We then compared $V_{in}$ for the op-amp current-to-voltage converter and a pull-down or pull-up resistor.  I think that they see the difference between the op-amp circuit and the single resistor, but I’m not sure they understand when to use one and when to use the other.

I’ll probably see some op-amp current-to-voltage converters in next week’s audio amp lab, though they really aren’t needed with an electret mic (and they’ll probably get the bias voltage wrong, since the FET in the mic has to be kept in saturation, so needs to be at 1v or more). Hmm, with the proper biasing, the op-amp current-to-voltage converter could be used to get a fairly good gain from the mic without needing a DC-blocking capacitor to do level shifting, so maybe it isn’t such a bad idea to try use it.  I’ll try that out in the preamp for the class-D amplifier and see how well it works.

I then returned the lab reports and ranted about how important it was to get schematics exactly right, and how they’d keep redoing the lab reports until they got them right. I also lectured them about using “would” incorrectly (though only a couple of students are still doing that), about doing factoid dumps without connecting the information to the design problem they are addressing (again, just a few students still doing that), and about citations not being sufficient for copied figures or text—there must be explicit “Figure copied from … ” figure credits and explicit quotation marks or block quotes.  Lots of students are still omitting the figure credits.

I also talked about the value of having chunks of the schematic match the blocks of a block diagram, not mixing different blocks randomly, using the tinkering lab schematics (where the hysteresis oscillator board was a block of the block diagram) as an example.

Finally, I talked about the importance of thinking of voltages as being between two points: an FET does not know where “GND” is, and is controlled by VGS, not Vgate. I showed how putting a pFET between a loudspeaker and ground rather than between the positive power rail and the loudspeaker would result in the source voltage being just about the negative of the threshold voltage (so around 2V with our pFETs), and the pFET dissipating a lot of power.

I then took questions about this week’s lab. The first question to come up was about how to choose the Rgain resistor, which I used both as a chance to talk about the instrumentation amp and about gain in general.  I introduced them to gain-bandwidth product, and explained why one might want to use a multi-stage amplifier to get high gain with high bandwidth.  The amplifiers we use are about 1MHz gain-bandwidth product, so we could go up to 100kHz with a gain of 10, but only 1kHz with a gain of 1000.  Of course, for the pressure-sensor lab, we don’t need high frequencies so the gain-bandwidth product is not a limit in this lab.

The students then talked me through a block diagram for the lab, and we discussed (without coming to any conclusion) whether a low-pass filter was needed/useful and whether a second stage amplifier was needed/useful.  I did point out that they had two free screw terminals on the board for talking to the Arduino, so if they wanted to have two different gains or filtered and unfiltered outputs, they could.  There was a little discussion of what corner frequency was appropriate for a low-pass filter, and with a little nudging, I got them to remember last week’s sampling and aliasing lab.

We ran out of time before getting to material I had queued up in case things went faster than I expected:

• common-mode rejection ratio
• looking at the predictions for the tinkering lab as a group
• AC power computation
• microphone current-to-voltage conversion (choosing bias voltage)
• more complicated loudspeaker model
• Zobel networks for compensating loudspeakers

It’s actually a good thing that we didn’t get to the more complicated loudspeaker model, because I was playing around with a non-linear model (the main inductance varying as a power of frequency) and it looks like a better fit with fewer parameters than the linear model I had been using.  I’m considering rewriting the class-D amplifier handout to use that model instead.  Unfortunately, the LC filter design looks like we’ll have more pass-band ripple than I had previously thought, though still not too bad.