# Gas station without pumps

## 2017 January 2

### LM2903 open-collector comparator characterization

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

In Last power-amp lecture, I posted an I-vs-V plot for the LM2903 comparator’s open-collector output, which I had made sometime in 2013, I think:

There are two regions of operation for the open-collector output of the LM2903. In the saturation region, the current goes up slowly with voltage (as about V^0.15, while in the “linear” region, it goes up as about V^1.5). The transition occurs when VOL is about 0.25 V, so we are almost always in the saturation region.

I decided to redo the plot using the Analog Discovery~2, as I now include the open-collector curve in the textbook (in an optional section, since we no longer use open-collector comparators). I used a 12V wall-wart and both the function generator and oscilloscope functions. I used the “custom channel” and XY plot features to get the I-vs-V plot on the screen (though I saved the data and replotted with gnuplot, to superimpose different runs). I also averaged 10 sweeps to reduce noise.

R1 was 56Ω for testing high voltages and currents, and R1 was 2.2kΩ for testing low voltages and low currents.

The triangle-wave generator and the nFET makes a variable load for the comparator, from slightly more than R1 up to about 1MΩ.

Even up to 11V, the LM2903 collector stays below the 20mA maximum current, but I’d want to make sure that there was some current-limiting resistor for any power-supply voltage above 12V.

The results with the Analog Discovery 2 are much cleaner than my old results, which were most likely done with an Arduino, which has a very low resolution ADC.

## 2015 May 28

### Power amps working

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

The power-amp lab went quite smoothly today—just about everybody got a class-D power amp working and a couple of groups wired their sup to a headphone plug and played music from their cell phones.  They were impressed at how loud the amplifiers were (though they were only producing about 4W of music, and their speakers could go to 10W or 15W, depending which model they got).

The biggest problems I saw in helping students debug was careless wiring—often because students had not bothered to make complete schematics including pin numbers and every power connection.  Connecting power up incorrectly was common.  Another common problem for students who did multi-sheet schematics (not recommended for such a small circuit), was having discrepancies at the boundaries between the sheets (like leaving out the high-pass filter needed for recentering the output of the pre-amplifier at the same voltage as the triangle wave).  A number of students got confused between the lowest power rail and ground (especially since the LM2903 data sheet calls the low power voltage to it GND, even though in the student schematics it was connected to the lowest power rail.

Despite my rather awkward lectures on the class-D power-amp, I think that the building and testing went smoother this year—perhaps because I tried having them do a crude-approximation-and-test approach to sizing the pull-up resistors.  I think that few groups ended up using the resistor sizes they started with.  Most had to make the nFET gate’s pull-up larger and the pFET gate’s pull-up smaller, to make the transistors turn off fast enough.  I’ll have to see if I can come up with some design guidance that will make the initial estimates closer, without complicating the design process.

I have to correct something I said yesterday in Last power-amp lecture—I did include a current-vs-voltage graph for the LM2903 comparator!  I need to rewrite the prelab to have them use that figure to compute their open-collector pull-up resistors: choose a desired low output voltage, figure out the current at that voltage, then use the voltage drop across the pull-up resistor to size the resistor.

I tried using the digital scope in lab today to get Miller plateau pictures without slowing down the transitions, and I recorded a few with the lower power rail at –6V, the upper power rail at +6V and a 330Ω pull-up resistor to 0V on the open-collector output:

Rising edge for the gate voltage with a 330Ω pullup to 0V from –6v.

Falling edge for the gate voltage with no load on the FET, from 0v down to –6v.

With an 8Ω loudspeaker as a load, turning off the nFET (gate voltage in blue) causes a large inductive spike on the drain (yellow).

Here is a detail of turning off the nFET, showing both the Miller plateau on the gate voltage (blue) and a large inductive spike on the drain (yellow).

The on-transition of the nFET shows the Miller plateau clearly in the gate voltage (blue), with a smooth transition in the drain voltage (yellow).

Unfortunately, these tiny little images were all the scope recorded, and they are too low quality as images to put in the book.  I’ll have to do it again sometime, with the scope downloading the data for me to plot properly.  Unfortunately, the download format is a 3.8Mbyte CSV file, which takes a long time for the scope to download to a flash drive (slow USB 1 speeds, I fear). I did not have the patience to do that today, together with writing scripts to ignore the meta data and plot just the real data.  I saved one file, which I’ll use for script writing, and some time later go back and record the transitions again.

## 2015 May 27

### Last power-amp lecture

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

I gave the last of the lectures on class-D power amps today, starting by answering a question about how they could hook up a phone or iPOD to the power amp.  Basically, the line output replaces the microphone and preamp circuit, before the high-pass filter that recenters the voltage, which is convenient, as they have mostly been building the preamp on a separate breadboard, with only two wires over to the class-D power stage. I also had the students figure out how to combine a left and right signal into a single monaural signal (as with most of the questions in the class, the answer is a voltage divider).

For most of the lecture I talked about how to decide whether the pull-up resistors for the open-collector comparators outputs needed to be bigger or smaller. I gave up on doing anything mathematical, and went for more cut-and-try approach (many, but not all, of the students already made mathematical estimates in the prelab, sometimes reasonably, sometimes off by moderate amounts).

The basic idea is simple: look at the output high voltage and the output low voltage. The output high voltage is whatever the other end of the resistor is connected to—for the pFET gate this is the same power rail as the pFET source is connected to, so it guaranteed to be high enough to turn the pFET off, while for the nFET gate this can be either ground or the positive power rail, which are guaranteed to turn the nFET on, as long as the power supply voltages are high enough. The output low voltage results from the voltage drop across the pull-up resistor, so is $V_{hi} - R I_{sat}$ if that voltage is enough above the bottom power rail for the comparator output transistor to be saturated. The saturation current for the LM2903 they are using is guaranteed to be at least 6mA on the data sheet, but in practice is typically larger.

One thing I did not do was include a current-vs-voltage graph for the LM2903 comparator, though I had created one two years ago—I’ll have to put it in the book!

There are two regions of operation for the open-collector output of the LM2903. In the saturation region, the current goes up slowly with voltage (as about V^0.15, while in the “linear” region, it goes up as about V^1.5). The transition occurs when VOL is about 0.25 V, so we are almost always in the saturation region.

I probably should have presented this graph (I’d forgotten I had made it) and then justified using a saturation current of 10–16mA (maybe 12mA for the nFET driver where we want the low output to be well below the nFET threshold voltage and 16mA for the pFET driver, where we may not need to get anywhere near the lower power rail).

So the main constraint on the pull-up resistors is that they must be large enough to make the VOL voltages low enough to turn on the pFET, $-I_{sat} R < V_{th(p)}$, and turn off the nFET, $V_{OH}-I_{sat}R < V_{-supply} + V_{th(n)}$.

But making the resistors large slows down the upward transitions, making the pFET turn off slowly and the nFET turn on slowly, so we really want to make the resistors about as small as we can while reliably turning the pFET on or the nFET off. (This is an oversimplification, because the on-resistance of the FETs drops as we turn them on more firmly, so there is an incentive not to use the smallest possible values—but that tradeoff gets complicated without either measuring actual power consumption or doing extensive simulation.)

I then showed the students how to get the turn-on or turn-off time by looking at the gate voltage of the FET when the FET was switching a load (using the loudspeaker as a load, since they don’t have 8Ω 10W resistors). The time is from when the gate starts to change until the end of the Miller plateau, and I showed them the slowed down transition plots that I made for the book:

Here are the gate and drain voltages for an AOI518 nFET, slowed down by adding a series resistor to the gate signal and a large capacitor between the gate and drain. I slowed it down so that I could record on my low-speed BitScope USB oscilloscope—students can see high-speed traces on the digital oscilloscopes in the lab. The Miller plateaus are the almost flat spots on the gate voltage that arise from the negative feedback of the drain-voltage current back through the gate-drain capacitance.

I should probably take some of the 9–10 hours I’ll be spending in the lab tomorrow to try to make plots without the slowdown, using the high-speed digital oscilloscopes in the classroom. The oscilloscopes can save screen images onto flash drives with a single button push, but I’ve not yet figured out how to get data off of them in a usable format—I guess I’ll need to look in the manual (there is a copy cabled down in the lab).

I also mentioned the problem of overshoot when using only one FET (rather than the cMOS arrangement) to switch an inductive load, and showed how to use a flyback diode to provide a return path for the current that continues to flow from the inductor.  With the cMOS arrangement, the built-in body diodes of the FETs provide good flyback diodes, with each FET’s body diode protecting against the overshoot when the other FET turns off.  I should probably have some plots of that overshoot also for the book.

One thing I did not get enough time for in class is talking much about the LC filter design for removing the high-frequency PWM signal and delivering just the audio signal to the loudspeaker.  I showed them the basic idea, and pointed them to the gnuplot script I’d written for them (where they need to plug in their own loudspeaker model), but I did not get a chance to demo it.  I think that only the top third of the class got enough to be able to choose the capacitor (I only have one size of inductor available—I should probably buy a few other sizes). I covered the LC filter better last year (see post on that lecture), but I did a little better with real power this year.

Overall, it was not a great lecture—too much material and too sloppily done, so that I’m not sure that any of it got through clearly.  Being so short on sleep for the past couple of weeks has really been killing my performance.  Still, I think it was a little better than last Monday’s lecture, which was probably the worst of the quarter.

Blog at WordPress.com.