Gas station without pumps

2013 March 2

Rethinking the power-amp lab yet again

Filed under: Circuits course — gasstationwithoutpumps @ 14:05
Tags: , ,

In Rethinking the power-amp lab again, I described the failure of my class-D power amp on Thursday afternoon, and the dilemma I faced in whether to revise the lab or cut it from the course.  Some of the students favored cutting it (they’re hitting end-of-quarter crunch time), but I know that they would not learn any of the material that lab is intended to help them understand without actually doing the lab.  Also, if I had one less lab report to evaluate them on, I’d probably have to add a final exam, which I don’t think they would like any better.

So Thursday night I woke up around 3 a.m. and thought about ways to salvage the power-amp lab.  First, I had to figure out what differences there were between the circuit I had working at home, and the same board, with slightly different power-supply options in the lab on campus.  The only real difference was the voltages for the power-amp stage (the comparator and power FETs).  At home, I was using a 6.6V power supply—the same one I was using for the pre-amp stage, so that the FET sources were at 0V and 6.6V (and the loudspeaker had a DC bias that is undesirable).  On campus, the preamp had a +6V supply, and the comparator and FET sources were at ±4V, but I wanted to be able to go to ±7V or even ±9v.

I came up with some ideas for potential solutions.

  1. The first was a fairly trivial one: just have them use a single 6V power-supply the way I had, and not worry about the DC offset to the loudspeaker. I don’t like this solution very much, because it doesn’t provide much power to the speaker (about 0.5W), and has that DC bias.
  2. A minor variant of the first idea is to add a large series capacitor to the loudspeaker.  Our big electrolytics are 470µF, and we’d have high-pass filtering with a corner frequency of about 66Hz, which is ok for the small speakers (whose resonant frequency is around 155Hz.  The 16V limit for the electrolytic capacitor is no problem, since the pre-amp using an MCP6004 chip shouldn’t really be run with more than 6V.
  3. Another minor variant eliminates the series capacitor by using a ±3V supply, with the preamp powered from -3V and +3v.  This has the advantage of eliminating the need for a virtual ground in the pre-amp, as well as powering the loudspeaker cleanly.  But we are still limited to 0.5W.
  4. The second major solution was to change the output stage from having a simple cMOS inverter (with the pFET and nFET gates connected together) to using a separate comparator to drive each of the FET gates.  By changing the pull-up resistors on the open-collector outputs of the comparators, I could adjust the rise and fall rates.  By using a very small pull-up, the voltage would rise rapidly, fall slowly, and not get very low.  By using a larger pull-up, the voltage would fall rapidly, rise slowly, and get quite low.  Since I don’t want the nFET and pFET on at the same time, I want to turn the FETs off quickly, but on slower, so that one is off before the other turns one.  That lead me to a design with a large pull-up resistor for the nFET gate and a small one for the pFET gate.  (“Large” and “small” are relative terms here—mine were within a factor of 10 of each other, since they are constrained by how much current the comparator can sink and by how fast we want the gate voltages to change.

On Friday morning, I went into the lab and tried out potential solutions 1, 3, and 4.  (Since we have a dual supply handy there is no reason not to use it.)

Since solution 1 is essentially identical to what I had debugged at home (but with a 6V supply instead of a 6.6V supply) it worked fine.  Splitting the supply into a +3V and a -3V supply with the loudspeaker connected to the middle eliminated the DC bias on the speaker without changing anything  else, so it worked fine also.

It took me a while to debug the design with the separated comparators, mainly because I had forgotten to allow for one very important constraint: the inputs to the comparators have to be between the power rails of the comparator.  With the preamp powered from 0V and 6V, and the comparators powered at ±3V, that constraint was violated.  I upped the voltage for the power stage to ±6V and the comparators worked ok.  I did have to fuss around a bit with pull-up resistor for the nFET, since we need to make sure that the comparator will have an output low voltage < 1V above the bottom power rail.  That means that the size of the pull-up for the nFET needs to be based on the power-supply voltage and the current sunk by the comparator (which we should assume is around 5–6mA if the output voltage is below 1 v, up to 7.5mA if we can tolerate a larger output voltage from the comparator).  The pull-up for the pFET can be much smaller (so that the pFET turns off quickly), but that means that the pFET gate does not go close to the lower power rail.  Still, the pFET works fine as long as the gate is at least 3V below the upper power rail, so if we can get away with a fairly small resistor.  I probably should play around with the resistors some more on Monday, so that I can give the students better guidance on how to design them based on experience, and not just theory.

The separate-comparators option is the closest to a real power-amp design, and is the one I think I’ll write up a lab-handout addendum for this weekend.  I’ll try to get that done and an EKG lab handout, and make a final decision about whether to drop the power-amp lab (adding a final instead) or keep it.

I’ve definitely rejected the idea of a bipolar current gain before the FET gates (too complex for a 1-week lab) and pretty much rejected the idea of class-A amplifier (both the DC offset and the heating of the FET are problematic).  I will think about switching to teaching a bipolar class-AB power amp next year, though, instead of a class-D.

2013 February 28

Rethinking the power-amp lab again

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

I took the breadboard that had been working for me at home for the class-D power amp to the lab today, and tried getting it to work in the way that I expected the students to do it, with 3 power supplies.

It failed miserably.

Even after tinkering with the circuit a bit, the FETs kept getting hot (indicating that I was not successfully having only one on at a time).  I’ve already released the handout for the power amp lab,  but the students will not be able to get the amplifier working from those instructions.  I have several choices facing me:

  • Get rid of the power-amp lab entirely, and take 2 weeks for the EKG lab.  Originally, I had planned 2 weeks for the EKG lab, as it is slightly more difficult than the pressure sensor lab, but the difference in difficulty is not 2-to-1.
  • Modify the class-D lab to use a single power supply, as I’ve been doing at home.  I think that the problem I was facing was that the larger voltages of the dual supply made the overlap range where both FETs were on much larger, and the simple cMOS-inverter output stage could not be driven fast enough to pass rapidly through the range.  It may be enough to use two 3-v supplies, with everything except the loudspeaker running from +3V to -3V, and the other end of the loudspeaker at 0V.  I’d be limited to the voltage range of the MCP6004 chip, which is 6V (the absolute max is 7V, and I’ve been running them at 6.6V at home without much trouble, though I’ve probably shortened their lifetime a lot).  That would limit the power to the loudspeaker to around 0.6W, which is still a lot more than the op amps can deliver.  Dual 3V supplies (and no extra 6v supply) would be a simpler design that what I have in the handout, but it should be very close to what I debugged at home.  I should probably try it out in the lab tomorrow.
  • Use bipolar transistors to drive the FET gates with more current so that they switch faster.  We haven’t talked about bipolar transistors (except very,very cursorily in the context of the phototransistor, and the lab reports indicated that only one or two people had followed through to understand how the phototransistor works).
  • Give up on class-D and do a simpler class-A amplifier with the loudspeaker as the load resistance.  This is not the right way to use the loudspeaker, since it will have a large DC bias (pushing the cone out or pulling it in, rather than having it rest in the middle), but is a very simple circuit, and can use negative feedback from the loudspeaker to correct for any nonlinearity in the the circuit.  It is also horribly inefficient, and whatever FET we use is almost sure to get warm. We could solder a heat sink onto the transistors, if needed, but that adds a different sort of complexity to the lab.
  • Do a class-A amplifier with a power bipolar transistor.

I don’t really like any of these solutions, but I’ll have to pick one this weekend and write it up for the students.  If we start the EKG lab a week earlier than planned, I’ll have to try building an EKG amplifier on the protoboard this weekend, to make sure that it works well enough, and get the handout for it written. Doing a lower-voltage class-D amplifier would require the least modification to the handout.  Bipolar transistors would require not only acquiring the transistors, but debugging the lab with bipolars (and I might want to switch back to a class-AB amplifier if I use bipolars).

 

 

 

2013 February 16

Teaching students to build and use models

Filed under: Uncategorized — gasstationwithoutpumps @ 11:45
Tags: , , , , , ,

In a comment on her post Student Thinking About Abstracting, Mylène says

What frustrates me and disorients my students is that those justifications are never discussed, and even the fact that this is a model is omitted. To further “simplify” (obscure) the situation, most discussions of the matter don’t distinguish between two ideas: “the model has a change in behavior at 0.7V,” vs. “they physical system has a change in behavior at 0.7V.” Finally, the chapter starts with the most abstracted model (1st diode approximation) and ends with the less abstracted (3rd diode approximation).

On getting students to understand models:  I agree that this is a huge problem.  I’ve been trying various techniques and can’t claim to have found a silver bullet.

One thing I tried in class yesterday (disguised as a gnuplot tutorial) was to build up a model a little at a time to match measured data.  I was trying to build an equivalent-circuit model for a loudspeaker, so I started by gathering data (rms voltage measurements across the loudspeaker and across a series resistor at different frequencies) and plotting magnitude of impedance vs. frequency from the data, then building the model a component at a time.  Before doing the modeling, we had spent some time looking at the behavior of building-block circuits (R+C, R||C, R+L, R||L, C||L, C||L||R) using gnuplot, so I could ask them things like “how can we model the impedance increasing with frequency above about 1kHz?”  We could then immediately modify the model and plot the results.  Once things were close, we could use gnuplot’s “fit” command to tweak the parameters.

We didn’t start with “loudspeakers are …”, though we did start with one of the specs—that this was an 8Ω loudspeaker—for our first model. I didn’t even point out to the students that the frequency of main resonance peak is given as a spec on the data sheet. The data sheet gives it at 191Hz, while our measured data show 148Hz (more than 22% off, while factory tolerances for the resonant frequency are usually ±15%). They also give the voice coil inductance as 0.44mH, while our model gets 35µH, a factor of 12.6 difference! And they give the Qes of the resonance peak as 3.52, while our model of the R||L||C for the peak has Q_{es}=R\sqrt{C/L} = 5.71.

Maybe the inductance difference can be explained by the standard measurement for the voice-coil inductance being made at 1kHz for the Theile-Small parameters, while I fitted for a wider frequency range and added an extra 112µH inductor in parallel with a 32Ω resistor to bump up the impedance around 10kHz. Or maybe my fitting is a really bogus way to get the inductance, since I’m only looking at the amplitude and not the phase of the signal, and non-linear resistance could throw things off. Or maybe the Parts-Express people mis-measured or had a typo—I have no idea what measurements they made to get the parameters they report, or maybe these loudspeakers were so cheap because they didn’t meet the specs, though they are certainly good enough for our lab.

I think that one could do the same sort of model-building with diodes (the part whose models Mylène’s students were confusing with reality): start by measuring the I-vs-V characteristics. The setup I used to get a lot of data points with the Arduino for characterizing the FET in an electret mic might be a good one for them to use, though the unipolar ADC in the Arduino might be more challenging for characterizing diodes.  Then try fitting different curve families to the data.  Forget about physics for explaining how the diodes work, but concentrate on finding simple models that fit the data. For example, the FET models we used for the mic are not quite the standard ones, since there is a clear slope in the saturation region, and it doesn’t match the channel-length modulation model—but it can be fit with some simple curves.

Of course, I gave up on some modeling before even having the students collect data themselves—the power FETs they are using are incredibly messy, having threshold voltages that shift a lot as the transistors warm up and having an undocumented negative dynamic resistance region when diode-connected.

So it is important that their attempts to build models be of phenomena that are relatively easy to model, but they should build and fit the models (with some guidance) rather than just be handed them. I made the mistake of handing them models to fit for the electret mic lab and for the electrode lab.  They not only didn’t understand the models, but they didn’t understand how to do the fitting.

I’m planning next year to do the model-building/gnuplot tutorial much earlier in the quarter, before they do the electrode labs, so that they can build the electrode models with some understanding. I’ll need to rearrange some other material, to do inductors much sooner, if I plan to use the loudspeaker data again.  I may want to rearrange the labs a lot next year, since all of my first three labs involved model fitting, and the students weren’t ready for it.  It may be better to move the sampling lab (which is currently lab 6) into the beginning, so that students can learn to use the Arduino in a simpler lab.  As currently written, though, that lab calls for designing a high-pass filter for DC level shifting and a low-pass filter for removing aliasing, neither of which are suitable for a first-week lab in circuits.

Scheduling the labs and the classes is difficult. Fitting in all the topics they need before each lab is a tricky jigsaw problem, particularly when I discover them having problems with topics that I assumed they knew or could pick up quickly. Sigh, some stuff in the first week or two of lab is probably going to have to be “magic” as they’ve learned so little in physics classes that I can’t count on them having any useful lab or modeling skills when they come into the class.  I just have to decide which things I’m willing to give them, rather than having them do for themselves.

Currently, I’m leaning toward having every lab have a design component, and to have them build models for important concepts, but I’m willing to give them a model for thermistor behavior that they just have to fit the parameters for.  The design in the first two labs this year is very light (selecting a resistor value), but the measuring and model fitting is pretty heavy.  The electrode lab has no design currently, but a lot of measuring and model fitting.   I think I underestimated the relative difficulty of model fitting and design for these students, and may need to move the model fitting later in the quarter.  I don’t think I can start with RC filters in the first week though, as they need voltage dividers, complex numbers, sinusoids, and complex impedance—probably at least 4 classes worth of material.  Maybe by week three, though.

2013 February 2

Idea for phototransistor/FET lab

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

Based on the conversation I had with the students at the beginning of class yesterday, I came up with an idea for a lab that uses both the phototransistor and an FET that should be fairly fun and easier than many of the labs we’ve done.  The students were saying they would enjoy a musical application—the student who mentioned it was thinking of a light harp, where the “strings” are light beams that you break with your hands to trigger synthesized notes.  It would be pretty easy for them to make a circuit that detects the presence or absence of light, but all the fun parts of such a lab are in the programming, which is not part of this class (and which most of the students have no training in).

I decided to try making a sound that the students could control in some way with a phototransistor, but not necessarily a particularly musical sound.  The obvious application of an FET is to put it in series with the loudspeaker and a power supply and turn the FET on and off.  The relaxation oscillator that they did for the hysteresis lab this week could be used to drive the FET (at least, if we lower the frequency down into a comfortable part of the audio range). The students don’t have another 74HC14N chip, but they don’t need one, since all four nodes of the hysteresis oscillator (+5v, out, in, GND) are available at the screw terminals of the board they soldered.

Since we are interested in increasing RC, we can do it by increasing C—adding another capacitor in parallel with the one on the board. All they need to do is connect wires from the board to a breadboard, add capacitance to lower the frequency, and connect the output to the gate of the FET.

So we’ve got sound (pretty loud sound if they use a high pitch) out, all we need is control.  The simplest thing I could think of was to put the phototransistor across the capacitor.  In bright light, it conducts a large current, discharging the capacitor and keeping the input low (thus keeping the output high).  In darkness, it conducts essentially no current and the oscillator oscillates as it did before we added the phototransistor.  At intermediate light levels, it conducts some current, which means that it takes the oscillator much longer to charge the capacitor up to the high threshold, so the output-high time is stretched.  If the current through the resistor is slightly larger than the current through the phototransistor, the oscillator oscillates at a low frequency.  If it is much higher, the oscillator output is stuck high, and if it is much lower, the oscillator oscillates at its maximum frequency.  So by shadowing the phototransistor, one can modulate the frequency of the output.

One problem with the design as a toy is that the resistor used determines the amount of ambient light needed to shut the thing off.  I had to add resistors in parallel with the one already in the oscillator to make the current large enough to oscillate even in dim light, and I needed to increase the current a lot more to have any control in sunlight.  When I had the current that high, though, the oscillator would not shut off with just room lights at night.

I suppose I can make a virtue out of this problem, though, by having the students measure the range of currents that they get from the phototransistor (with a bias voltage around the VIH threshold) for the lighting in the room and the shadowing they can do with their hand, then pick the resistance they would need to use in parallel with the existing resistor. After that, they could compute the capacitance they would need to add to get a reasonable high frequency in darkness.

This is a simple design exercise, gets another use out of the hysteresis oscillator board, and is sort of fun to play with (though the pulse-train buzzes do get annoying to listen to after a short while—I’m sure I’ll have a monster headache by the end of the lab session. I’ll try to write up this lab as soon as I get Monday’s quiz written.

I’m now thinking that next year I’ll rearrange the first 6 labs into several shorter labs:

  1. buying parts kit and familiarization with it.  Marking bags of capacitors, learning to use multimeter to measure resistors.
  2. thermistor lab using multimeter  (and make sure we have water hotter than 70°C and colder than 10°C)
  3. thermistor lab using voltage divider and  Arduino
  4. microphone lab getting DC characteristics with Arduino
  5. microphone lab setting DC bias and learning to use the oscilloscope
  6. hysteresis oscillator on breadboard
  7. soldering hysteresis oscillator design
  8. phototransistor and FET lab
  9. characteristics of stainless steel electrodes
  10. characteristics of Ag/AgCl electrodes
  11. audio amplifier with op amp, dual power supply
  12. audio amplifier with op amp, single power supply

That order would give us more time to develop the notion of impedance before the electrode lab, as well as more time to learn to use gnuplot, but after 6 weeks will be in about the same place I hope to be at the end of next week after 6 weeks.  It might be necessary to spend two of the shorter labs on the dual-power-supply op amp, but we’ll see.

 

2013 January 7

Negative resistance oscillator

Filed under: Circuits course — gasstationwithoutpumps @ 06:50
Tags: , , , , ,

In More mess in the FET modeling lab, I reported observing an S-type negative resistance in the nFET that I had not expected:

The straight line for low currents is the expected subthreshold conduction.The spreading of the curves at high current are due to the same threshold shifting that we saw before.But what is going on between 12mA and 50mA?

Negative resistance 12mA and 50mA. (click to enlarge)

I decided to see if the negative resistance was really there and usable by making a negative resistance oscillator. The usual such oscillator for a negative resistance is a loop containing an inductor, a capacitor, and the negative resistance. Because I wanted an audio frequency oscillator, I needed a fairly large inductor (the angular frequency is \omega=\frac{1}{\sqrt{LC}}). However, I am also constrained by the resistance of the inductor, since the sum of the resistance around the loop has to remain negative. Estimating the negative resistance by fitting a straight-line to the appropriate part of the V-vs-I curve gave me a negative resistance of –2.145Ω. So the inductor needs a DC resistance under 2Ω.

Inductors are not something I have many of, but I looked through my parts drawers for any I might have gotten years ago in surplus grab-bag of parts. I found some tiny transformers with unknown specifications, so I tried measuring one to see if it had a high enough inductance with a low enough resistance. Transformers seemed more promising to me than simple coils of wire, because they are likely to have a ferrite core to increase the inductance without increasing the resistance, and the secondary coil gives another possibility for resonance.

I measured the DC resistance of the transformer and found that the tapped coil has a resistance of about 106Ω and the untapped coil about 0.1Ω (but my meter is not too good at resistances less than 1Ω). I then tried measuring the inductance using the same techniques I used for characterizing loudspeakers and electrodes (see Better measurement of conductivity of saline solution or Characterizing tactile transducer again), making a number of measurements of RMS voltage across the device and across a series resistor at different frequencies, then fitting a model.  Since I was looking mainly for the inductance in a simple R+L series model, I mainly looked at higher frequencies.  For the tapped coil, I got R=107.2Ω, L = 0.0226H, and for the untapped coil I got  R<0.1Ω and  L=6.76µH (I hadn’t gone to low enough frequencies to estimate R well, and I didn’t really care, since it was much less than 2Ω).

I tried the tapped coil first, but as expected from the resistance, could not get an oscillation.  I then tried the untapped coil with an electrolytic capacitor, and still couldn’t get an oscillation.  Finally, I tried the untapped coil with a 4.7µF ceramic capacitor and got an oscillation around 29.9kHz with a bias current around 21mA.  The waveform was not pretty:

Waveform of the negative resistance oscillator with no load on the secondary of the transformer. Bias is about 21mA.

Waveform of the negative resistance oscillator with no load on the secondary of the transformer. Bias is about 21mA. Note, the oscilloscope is connected across the secondary coil of the transformer, which appears to have around 3300 times as many turns as the primary, making the voltage larger and easier to observe with the BitScope USB oscilloscope.

I tried cleaning up the waveform by adding a capacitor across the secondary coil of the transformer. Too large a capacitance killed the oscillation and too small a capacitance did little to clean up the signal. I got the best results with a 680pF capacitor:

Waveform with a 680pF capacitor loading the secondary coil of the transformer.

Waveform with a 680pF capacitor loading the secondary coil of the transformer.

Here then is the final circuit:

Negative resistance oscillator using the unexpected S-type negative resistance of the NTD5867 nFET.  Biasing the diode-connected nFET around 21mA produced oscillations.

Negative resistance oscillator using the unexpected S-type negative resistance of the NTD5867 nFET. Biasing the diode-connected nFET around 21mA produced oscillations.

This is not a particularly practical circuit, as 21mA is a lot of current to get rather feeble, noisy oscillations, but it does show that the negative resistance I observed is a real phenomenon, and not an artifact of sloppy measuring on my part (as I had first feared). I wonder whether the negative resistance when switching from subthreshold to above-threshold conduction is a common property of diode-connected power FETs (or of FETs in general), or whether it is something specific to this part. I’ve never heard of it before, but I only used FETs in nMOS and cMOS digital VLSI design, where simple models sufficed—no one bothered to teach me anything about how FETs behave in this region.

For those interested in the spectra of the oscillations, I took screen grabs of Bitscope’s spectrum analysis. Unfortunately, the cursor obscures the fundamental peak—there doesn’t seem to be any way to see the peak and display the frequency at the same time. (I also hate the black-background display, which is only there because scopes have “always” had dark backgrounds—they are no longer a necessary evil, just an evil.)

Spectrum without a capacitor on the secondary coil of the transformer.

Spectrum without a capacitor on the secondary coil of the transformer.

Spectrum with 680pF on secondary coil of transformer.

Spectrum with 680pF on secondary coil of transformer.

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 166 other followers

%d bloggers like this: