Gas station without pumps

2014 April 10

Second mic lab went well

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

The second half of the mic lab went fairly well, but there were a couple of overly ambitious requests in the handout that I’ll have to trim out for next year.  Because we have not gotten to complex impedance yet (tomorrow, I swear!), the students were unable to choose a reasonable size for the DC-blocking capacitor, and guessing was not good enough.  The 10MΩ input impedance of an oscilloscope with a 10× probe makes for too long a time constant with the 0.1µF capacitor I  initially suggested, at least with the digital scopes—they did not manage to get the DC offset removed even after a minute, which surprised me.  Students got decent results with a 0.022µF capacitor, though.  I even got some of the students to be able to make measurements with the Tektronix digital scopes (always a feat, since they have mind-bogglingly complex menu systems).

I did tell the students not to bother with the last question on the handout and just to write up what they actually did.

It took the students longer than I had expected to come up with a reasonable value for the pullup resistor for the mic. But I was careful not to be too helpful, so that I’m reasonably sure that at least one in each pair of students knew how they got their answer. I did have them add load lines to their i-vs-v plots of the electret microphones, corresponding to rounding their desired pullup up or down to the nearest value they had in their kits.  That probably added a little time over a simple rounding, especially since I suggested to a couple of the students that they think about which resistor would give higher sensitivity.

I did have one student ask what a “pullup” resistor was—I had used that term in the handout without ever explaining it!  I gave a one-minute lecture explaining that a pullup was a resistor to the positive power supply and a pulldown a resistor to ground (we had examples of each already on the whiteboard). Speaking of things on the board, I’ll have to remember to bring markers to the lab on Tuesday, as the ones in there are all dead. A spray bottle of alcohol and some rags for cleaning the year-old buildup off the boards would also be good.

Even the pair of students who had run over on Tuesday finished on time today, despite collecting all the data that the other students collected on Tuesday, so I’m feeling a bit better about the size of the labs.

Next week may get a bit hectic, though, with two unrelated labs: hysteresis and relaxation oscillators on Tuesday and sampling and aliasing on Thursday.  I’ll have to remember on Tuesday to upload the hysteresis oscillator code to all the machines in the lab.





2014 April 9

Protein essentials and second gnuplot demo

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

I gave two lectures back-to-back today, which I found a little stressful.

The first lecture was a guest lecture in “Molecular biomechanics” on the basic of protein structure.  I spent some time earlier this week picking out protein structure to show the students; digging out my old Darling models protein chain, which I last used for assigning homework in Spring 2011( see also my instructions for building protein chains with the Darling models); and trying to boil down the basics of protein structures to one 70-minute talk. I was up at 3 in the morning setting up the proteins I wanted to show on my laptop, even though I planned to rely mainly on the chalkboard and the Darling model kit.

The protein talk went ok. I covered such basics as primary=covalent, secondary=H-bond, tertiary≈packing, quaternary=multiple chains; hydrogen bonding patterns for helices, antiparallel sheets, and parallel sheets; supersecondary structure; domains; CO-R-N mnemonic for chirality; s-twisted and z-twisted helices (left- and right-handed in the confusing nomenclature used by biochemists); SCOP and PFAM; and maybe a handful of other topics.  I only showed two structures on the screen: a TIM-barrel and alpha-hemolysin, and I pointed them to the PDB education pages, which are actually quite good.

The most exciting thing during the lecture was that we had the fire alarm go off, and had to vacate the room for 10–15 minutes.  I might have covered a little more if there had been more time, but I did not have a set topic list I had to cover, so it didn’t really matter—I was just giving an extemporaneous dump of protein structure information. I certainly told them all the stuff I had decided ahead of time was essential—I’ve no idea what else would have come out if I’d had 10–15 more minutes.  I also managed to get in a plug for the library—they have Darling model kits that the students can check out—and for the information sessions that I arranged for the library to run for bioengineering majors next week.

Right after that talk, I went to the classroom for my applied circuits class and set up for another gnuplot demo. I had about 10 minutes to get some candy from the vending machine also.

In the applied circuits class, I started out by showing them the result of fitting models to (some of) the data I had collected:

The linear-scaling version of the graph the students should produce (they should also plot it on a log-log scale, for a better view of the resistive region).

The linear-scaling version of the graph the students should produce (they should also plot it on a log-log scale, for a better view of the resistive region).

I had to lend my data to a couple of the students who had not managed to finish the lab yesterday—I assured them that they could continue the lab tomorrow, and that I would stay until everyone had completed both parts of the lab. They will have to use their own data in the design report. While they were copying the data, I took some time to talk about the “zone of proximal development”, imposter syndrome, and how my goal in the class was not to “weed them out”, but to help them achieve difficult success. My goal is to maximize their learning, which means that they will often be struggling with concepts or skills that seem just a bit too difficult. I’ll help them, but it might be such “unhelpful” help as telling them “your breadboard doesn’t match your schematic” and leaving them to find where the mismatch is, rather than debugging for them.  Sometimes I’ll have to do more, when the problems are beyond reasonable expectations (like finding the blown fuses in the multimeter and the broken clipleads yesterday). I promised to stay in the lab until everyone finished, even if it took them a long time.

Sometimes I’ll goof on the difficulty of a homework or lab, and they’ll be pushed into frustration rather than just being challenged, but my goal is to get them to persevere and to achieve that very rewarding feeling of finally accomplishing something that seemed too difficult when they started.  This course is only 3% of their college education, but I’m going to try to make it accomplish a lot more than that share.

Fortuitously, in my email today I got a story about someone (a marketing manager for an electronics parts company) learning to solder for the first time. I shared that story with my class by e-mail, as I thought that they could sympathize with him (having just learned to solder themselves last week), but also recognize the symptoms of imposter syndrome.

Getting back to the main material for the day, I started the guts of the gnuplot lesson. Building up the plot a little at a time, we first plotted the raw data from one PteroDAQ, then scaled the y values first to amps, then to microamps.  Because each group used a different resistor in their test setup, they couldn’t blindly copy what I was doing, but understand at least enough to put in the correct resistance value.  I showed them how to switch between linear and log scales on each axis with the plot-window keyboard shortcuts (“L” toggles the scaling on the nearer axis) and we noticed that the data from the first data set (the red one above) was rather sparse at the low end.

I then showed them how to get two plots on the same set of axes, and I managed to get them to tell me what the plot would look like if we had been testing a resistor instead of the electret mic.  We then fit a simple resistor model to the low end (the resistive region) of the curve.

I then took a break from gnuplot to explain how an electret mic works.  They were a little astonished at how many transformations of the information occurred in a simple device like a microphone: pressure to force to displacement  to capacitance to gate-source voltage to drain-source current (and I promised that we would convert back to voltage in tomorrow’s lab). We managed to follow the transformations and see that they were all linear (well, displacement to capacitance to gate-source voltage was a pair of inversions, and I had to wave my hands at \frac{d I_{DS(sat)}}{d V_{GS}} \propto I_{DS(sat)}, since we don’t have a model of FETs yet, and may not get to one complicated enough to derive that this quarter.

I then went back to gnuplot and showed them how to fit the Isat model to the data, first deliberately trying to fit the whole curve (which gives an obviously wrong result). I had deliberately omitted the amp-to-microamp scaling, and gotten a straight line at zero for my fit—I had them debug that as a group before we got a constant line that was in the middle of the graph. I got them to figure out what went wrong there also. Once they realized I was fitting the whole curve, I showed them how to limit the range of their fitting, and got a reasonable Isat value. My goal here was not to “show them how to use gnuplot”, but to show them that they could debug mistakes that they were likely to make, and that they should not shut down when things went wrong. (A lot of today’s class was this sort of meta-cognition stuff, while still getting in a reasonable amount of technical material.)

I then gave them the blended model, with R_{DS} = \sqrt{R^2 + (V_{DS}/I_{SAT})^2}, converting it to a current model on the board, then trying to fit the data. The result was (unexpectedly) a terrible fit—I did not have them try to debug this, because were were almost out of time, and just showed them that the problem was one of units: my initial guess for R was in Ω, but my currents were all in µA, so I needed to make the resistance in MΩ to have consistent units. After scaling the guess for R by 1e-6, I reran the fit and it worked fine. This gave me a chance to talk about the importance of starting fitting procedures with reasonable guesses, since they might not otherwise converge.

I’ve been getting good participation from the class, only occasionally having to get them to speak up (I’m getting a bit deaf, and when they mumble a guess, I can’t hear them). I’ve been trying not to suppress students who provide incomplete or wrong answers, but encourage them to amplify on or correct each other.  So far it seems to be working.

We did not have time to fit the 3-parameter empirical model, but they have the model in the lab assignment and they should be able to fit it using gnuplot now.  One student asked me if I was going to distribute a script, as I did last week. I assured him that I was not going to do that. The goal was to build up their gnuplot scripting capabilities, not provide them with crutches. There was very little “new” in this week’s lesson as far as gnuplot was concerned, and gnuplot does have an adequate help system for the sort of stuff they need (though I find the hierarchical help system to be quite poor for finding out about features you’ve not been exposed to—you have to know precisely what names things are hidden under).

I still haven’t gotten to complex impedance, but that will have to be Friday’s lecture.  I also wanted to get to load lines today, so that they could select an appropriate size for their load resistors that do the current-to-voltage conversion, but I’ll do that at the beginning of lab tomorrow, when they’ll be scratching their heads about how to choose the resistor.  Just-in-time teaching can be a powerful motivator, if they get concepts just after they realize the need for them, rather than months earlier in anticipation of need. I may at the beginning of lab if anyone figured out on their own how to choose the resistor, and get them to present first.


First mic lab slightly too long

Filed under: Circuits course — gasstationwithoutpumps @ 09:32
Tags: , , , , ,

The first half of the microphone lab took a little longer than anticipated.  I had expected it to take about 2.5 hours, with some groups taking the full 3 hours, but it took more like 3–4 hours.

I have two conjectures about reasons for the extra time:

  •  I had the students label all their bags of capacitors. this had originally been planned for a week ago, but the capacitors had not been ordered in time, and Thursday’s lab had been way too packed already, so this was the first opportunity we had.  I probably should have waited until this Thursday, when the lab time is less packed.
  • The group that fell the furthest behind had really terrible luck, having sat at a bench where both multimeters had blown fuses and two sets of multimeter leads had open circuits. I helped them debug their setup, but we did not initially suspect the test equipment, and the delay in finding the problem cost them at least half an hour. It also cut into their confidence in debugging their own circuitry later in the lab. Problems with the equipment is one of the difficulties with using a shared lab—a lot of the courses are taught by EE TAs who do not bother to teach students proper use of the lab equipment (if they even know it themselves), so there is often damage of this sort to deal with.

A number of the students in the class are suffering from “imposter syndrome”—not confident of their abilities to master this new material. I’ll have to reassure them that they are doing fine—this class is intended to be pushing them into unfamiliar territory.  I may take a moment in today’s class to mention both “imposter syndrome” and “zone of proximal development”, so that they are aware both that it is ok to be uncomfortable and that I’m trying to maximize what they are learning.

Students had a lot of trouble wiring up their breadboards accurately. Most of the lab time was taken up with students asking for my help and my taking a quick look at the breadboard and telling them that it didn’t match the schematic they had copied. I eventually had the students write on each wire of the schematic what row (or rows) of the breadboard it was on, so that debugging the connections was easier.  I’ll have to try to remember to put that in the instructions for next year, as a way to get the students to learn to debug their breadboard wiring more independently.  I should also add a picture of the trimpot and an explanation of what a potentiometer does—students had a little trouble figuring out what the 3 pins on the package were for.

I’m pleased with the latest version of PteroDAQ, as students had no trouble getting their measurements. Adding a patterned light sequence to the reset sequence to let students know that they had the latest version of the software installed was very useful.

Many of the groups managed to look at their data in the lab using gnuplot, and collecting more data as a result of what they saw. The students got 1000s of data points that fall nicely along a curve, and they were able to superimpose different data sets that had different scaling for the current measurements. We’ll have excellent data to use in class today for fitting models to. I’m not going to give them real FET models for the FET in the electret mics, though.  Instead we’ll use some simple empirical models:

  • current source.  This is the same as a saturation current model.
  • resistance. This is essentially the same as the linear-region model for FETs.
  • blended model with R_{FET} = \sqrt{R^2 + (V_{DS}/I_{SAT})^2}  This is a simpler blend than is usually used in FET models, I think, but it fits the data fairly well.  This blend is mathematically very similar to the ones that compute the gain in RC filters (where we take the magnitude of a complex number and either the real or the imaginary component provides most of the contribution).  Using the same function for rounding the corner when we join two straight lines in different contexts reduces the math burden on the students.
  • blended model with R_{FET} = \sqrt{R^2 + (V_{DS}/I_{SAT})^{2\rho}} The extra parameter here is to handle the increase in saturation current with increasing drain-to-source voltage. Normally, that is modeled with a fairly complicated “channel-length” model, and is not even mentioned in intro circuits classes.  But the phenomenon is very obvious in the data, and can be adequately modeled in the electret mic for our purposes with this 3-parameter empirical model.

I will have to give them one more concept about FETs: that the derivative of the saturation current with respect to the gate voltage is proportional to the saturation current. I’m not going to derive that for them from some more general model, because we have no way (in the mic) of actually measuring the gate voltage. Later in the quarter, when we look at FETs again before doing the class-D amplifier, I may give them a slightly more detailed model of an FET.

In addition to gnuplot tutorial today, I want to give them an intro to complex impedance, but I doubt that we’ll get far enough for them to choose the right size for a DC-blocking capacitor for the AC mic lab tomorrow. I may have to suggest that they try one of the biggest sizes of ceramic capacitor that they have (either the 4.7µF or the 0.1µF). We’ll need to get to RC time constants and corner frequencies before next week’s lab though.





2014 March 31

New modeling lab for electret microphone

Last year, in Mic modeling lab rethought, I designed the DC measurement of an electret microphone around the capabilities of the Arduino analog-to-digital converters:

Circuit for measuring DC characteristics of an electret microphone.  The four labeled nodes are connected to the Arduino.

Circuit for measuring DC characteristics of an electret microphone. The four labeled nodes are connected to the Arduino.

  • The highest voltage allowed is 5v and the lowest is 0v.
  • The resolution is only 10 bits (1024 steps).
  • The steps seem to be more uniformly spaced at the low end of the range than the high end (so differences at the high end are less accurate than differences at the low end).
  • The external reference voltage AREF must be at least 0.5v (this is not in the data sheet, but when I tried lower AREF voltages, the reading was always 1023).

Test fixture for measuring I-vs-V DC characteristics of electret microphone.

Test fixture for measuring I-vs-V DC characteristics of electret microphone.

This year we’ll be using the KL25Z boards, which have different constraints:

  • The highest voltage is 3.3v and the lowest is 0v.
  • The resolution is 16 bits (15 bits in differential mode).
  • Differential mode only works if you stay away from the power rails—clipping occurs if you get too close.
  • The external reference must be at least 1.13v.  With less than a 3-fold range for the external reference, varying the external reference to get different ranges seems rather limited.

I think I’ll still have the students start with using the multimeter and the bench power supply to measure voltage and current pairs for 1V to 10v in steps of 1v.  But then I’ll have them wire up a different test fixture. The resistor R2 is one that students will have to choose to get an appropriate measuring range. Resistors R3 and R4 keep the voltages for the differential measurements E20–E21 and E22–E23 away from the power rails. I tried using smaller values, but 200Ω was not enough—I still got clipping problems. So 63mV is too close to the rails, but 275mV seems fine.  I suspect that the limit is around 100mV to 150mV, but I did not try to narrow it down.

I found that the differential measurements had less noise than single-ended measurements, despite having a resolution of about 100µV rather than the 50µV of single-ended measurements. Doing 32× hardware averaging also helped keep the noise down. (Note: the data sheet for the KL25 chip does claim a higher effective number of bits for differential measurement than for single-ended measurement, perhaps because of reduction in common-mode noise.)

I was able to get fairly clean measurements with just two different resistor sizes, to which I fit 4 different models:

  • linear resistance: I = V /R
  • constant current I = I_{sat}
  • blended: I = V/ \sqrt{ R^2 + (V/I_{sat})^2)}
  • blended with exponent: I = V/ \sqrt{ R^2 + (V^p/I_{sat})^2)}


    The blended fit with the extra exponent on voltage does a pretty good job of fitting over the full range (it looks good on a log-log scale also)

The blended fit with the extra exponent on voltage does a pretty good job of fitting over the full range (it looks good on a log-log scale also)

Because of the large characters used for the data points, the lines look fat, but the noise level is fairly small—about ±300µV Some of that may be due to the movement of the potentiometer, as the voltage and current aren’t measured at precisely the same time, but I suspect most is electrical noise in the processor itself.

2013 July 31

Microphone sensitivity exercise

Filed under: Circuits course — gasstationwithoutpumps @ 13:46
Tags: , , , ,

I’ve been thinking a bit about improving the microphone lab for the Applied Circuits course.  Last year, I had the students measure DC current vs. voltage for an electret microphone and then look at the microphone outputs on the oscilloscope (see Mic modeling lab rethought).  I still want to do those parts, but I’d like to add some more reading of the datasheet, so that students have a better understanding of how they will compute gain later in the quarter.

The idea for the change in this lab occurred to me after discussing the loudness detector that my son wanted for his summer engineering project.  He needed to determine what gain to use to connect a silicon MEMS microphone (SPQ2410HR5H-PD) to an analog input pin of a KL25 chip.  He wanted to use the full 16-bit range of the A-to-D, without much clipping at the highest sound levels. Each bit provides an extra 6.021dB of range, so the 16-bit ADC should have a 96.3dB dynamic range.  The sound levels he is interested in are about 24dB to 120dB, so the gain needs to be set so that a 120dB sound pressure level corresponds to a full-scale signal.

He is running a 3.3v board, so his full-scale is 3.3v peak-to-peak, or 1.17v RMS (for a sine wave).  That conversion relies on understanding the difference between RMS voltage and amplitude of a sine wave, and between amplitude and peak-to-peak voltage. The full-scale voltage is 20 log10(1.17), or about 1.3dB(V).

Microphone sensitivity is usually specified in dB (V/Pa), which is 20 log10 (RMS voltage) with a 1 pascal RMS pressure wave (usually at 1kHz).  The microphone he plans to use is specified at –42±3dB (V/Pa), which is fairly typical of both silicon MEMS and electret microphones.The conversion between sound pressure levels and pascals is fairly simple: at 1kHz a 1Pa RMS pressure wave is a sound pressure level of about 94dB.

Scaling amplitude is equivalent to adding in the logarithmic scale of decibels, so for a sound pressure level of 120dB, the microphone output would be about 120–94–42±3=–16±3dB(V), but we want 1.3dB, so we need a gain of about 17.3dB, which would be about 7.4×. Using 10× (20dB gain) would limit his top sound pressure level to 117dB, and using 5× would allow him to go to 123dB.

One can do similar analysis to figure out how big a signal to expect at ordinary conversational sound pressure levels (around 60dB):  60–94–42=–76db(V).  That corresponds to about a 160µV RMS or 450µV peak-to-peak signal.

I tried checking this with my electret mic, which is spec’ed at –44±2dB, so I should expect 60–94–44±2=–78±2dB, or 125µV RMS and 350µV peak-to-peak. Note that the spec sheet measures the sensitivity with a 2.2kΩ load and 3v power supply, but we can increase the sensitivity by increasing the load resistance.  I’m seeing about a 1mV signal on my scope, so (given that I’m not measuring the loudness of my voice), that seems about right.

I’ll have to have students read about sound pressure level, loudness, and decibels for them to be able to understand how to read the spec sheet, so these calculations should be put between the microphone lab and the first amplifier lab.  I’ll have them measure peak-to-peak amplitude for speech, and we’ll compare it (after the lab) with the spec sheet.  This could be introduced as part of a bigger lesson on reading spec sheets—particularly how reading and understanding specs can save a lot of empirical testing.


Next Page »

The Rubric Theme. Create a free website or blog at


Get every new post delivered to your Inbox.

Join 251 other followers

%d bloggers like this: