Gas station without pumps

2016 August 13

Transimpedance pulse monitor does need low-pass

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 18:16
Tags: , , ,

In More thoughts on log-transimpedance for pulse monitor lab, I wondered

I’m wondering now whether I can have students do a log-pulse monitor without bandpass filtering—just high-pass to get rid of the DC signal from overall illumination.  Given the new position of the lab in the course, as the second amplifier lab, I don’t really want to get too tricky with RC filtering.  The “gotcha” that was a problem before is that I had to remove short glitches in the very first stage, to avoid the bandpass filter lengthening them into things that looked like pulses—I don’t want students to have to do that sort of debugging on their second amplifier lab. If I can eliminate the hardware bandpass filters, and just have them use software ones, then the lab becomes more feasible.

I was also concerned that the Schottky 1N5817 diode I had tested did not have provide gain at low currents—the low threshold voltage for Schottky diodes is a disadvantage in this application. So this morning I wired up a log-transimpedance amplifier followed by a couple of op amps as inverting amplifiers.  I first tried a combined gain of 408 (which I had used before with an IR emitter as the transimpedance diode), then upped the gain to 4453. I used high-pass filters to block DC, but no low-pass filters.

The circuit was not functional without adding at least one low-pass filter (a 680nF capacitor in parallel with the diode), because the 60Hz interference saturated the amplifiers, and the smaller pulse signal was completely buried.

With the capacitor, the circuit worked fine in moderately high light, but the signal got weak in low light (due to the transimpedance amplifier having a max gain of about 35kΩ—the asymptotic equivalent resistance of the diode as current goes to 0).  With just the single capacitor for filtering, the 60Hz noise was larger than the pulse signal, but a digital filter could still recover the signal:

Notch filtering does a great job of removing the 60Hz noise from this signal sampled at 360Hz.

Notch filtering does a great job of removing the 60Hz noise from this signal sampled at 360Hz.

So it looks like I do have to have students do low-pass filtering for the pulse monitor. Can I fit that into the second amplifier lab, along with the log transimpedance, or will it all get too complicated?

2016 August 12

More thoughts on log-transimpedance for pulse monitor lab

I’ve been having some more thoughts on having students do a log-transimpedance amplifier for the optical pulse monitor lab (see Pulse monitor with log-transimpedance amplifier). Previously I’ve looked at V-vs-I curves for base-emitter junctions and for the IR emitter—the silicon transistors gave me about 60mV per decade of current, and the IR emitter gave me about 105mV/decade.

I’ve been thinking of having students do the V-vs-I fitting for a simple diode. I don’t have any signal diodes at home at the moment, so I tried testing a 1N5817-TP Schottky diode (about 16¢ in 100s). I used the same setup that I used for testing power nFETs, so I could go up to a high current, but did not have good resolution at low voltages and currents.

The Schottky diode has about 63.6mV/decade, up to around 100mA.

The Schottky diode has about 63.6mV/decade, up to around 100mA.

The Schottky diode has a very similar slope to the emitter-base junctions I’ve tested in the past, but I’d really have to test down to much lower currents—we’re interested in the range 10pA to 500µA, which is buried in noise in these measurements.

I can get down to 1µA fairly easily, by eliminating the voltage dividers and just using unity-gain buffers to get low-impedance values to drive the analog-to-digital converters. I tried with four different sense resistors (470Ω, 15kΩ, 560kΩ, and 5.6MΩ) and got very consistent results. The noise levels are much lower, because the larger sense resistor and lack of voltage divider makes for much larger voltages being measured for the current-sense channel.  I also used the differential ADC channel for measuring the voltage across the sense resistor, which should remove a little noise compared to taking separate measurements and subtracting them.

I have more confidence in the 60.2mV/decade and 0.37V offset from these measurements than the high-current measurements I did for the first plot. At low currents, the diode behaves more like a 33kΩ resistor than like a logarithmic element.

I have more confidence in the 60.2mV/decade and 0.37V offset from these measurements than the high-current measurements I did for the first plot.
At low currents, the diode behaves more like a 33kΩ resistor than like a logarithmic element.

The 60.2mV/decade fit seems pretty good from 10µA to 10mA, and the noisier high-current measurements suggest that it is good to 100mA.  The sensitivity is less below 10µA and more above 10mA, behaving almost like a fixed 33kΩ resistor at low currents.

I can get a pretty good fit over a wide range with a three-parameter model of the equivalent resistance as a function of current: a resistor in parallel with a device that has a power-law fit for resistance as a function of current:

There is no theoretical justification for this model, but it seems to match the data better than the standard voltage-as-logarithm-of-current model, at least at low currents.

There is no theoretical justification for this model, but it seems to match the data better than the standard voltage-as-logarithm-of-current model, at least at low currents.

At low currents, the Schottky diode acts like a 35kΩ resistor, but at high currents, the voltage seems to be 0.409 I. This model seems to fit to better than 10% over 7 decades, which is not too bad for a 3-parameter model!

I’m wondering now whether I can have students do a log-pulse monitor without bandpass filtering—just high-pass to get rid of the DC signal from overall illumination.  Given the new position of the lab in the course, as the second amplifier lab, I don’t really want to get too tricky with RC filtering.  The “gotcha” that was a problem before is that I had to remove short glitches in the very first stage, to avoid the bandpass filter lengthening them into things that looked like pulses—I don’t want students to have to do that sort of debugging on their second amplifier lab. If I can eliminate the hardware bandpass filters, and just have them use software ones, then the lab becomes more feasible.

2016 June 25

Pulse monitor with log-transimpedance amplifier

Filed under: Uncategorized — gasstationwithoutpumps @ 02:04
Tags: , , , ,

I’ve been planning since the Santa Cruz Mini Maker Faire to wire up an optical pulse monitor with a log-transimpedance amplifier as the first stage, so that I could use the pulse monitor in full sun or in a dimly lit room, with a dim green LED or with a bright infrared LED. The idea is to make the output of the first stage proportional to the log of the photocurrent, rather than to the photocurrent, then use a band-pass filter to get rid of the DC component and any 60Hz fluctuation, leaving only the fluctuation due to the pulse.

This pulse signal should be independent of the overall light level but on the absorbance of the finger, because
\log(I) = c + \log(\mbox{transmitted}) = c+ \log(\mbox{illumination}) + \log(\mbox{transmitted}/\mbox{illumination}, for some constant c. If the illumination is constant or has only high-frequency components, then the bandpass filter will eliminate both c and \log(\mbox{illumination}), leaving only the absorbance \log(\mbox{transmitted}/\mbox{illumination}).

I deliberately did not start working on it until I had finished my grading for the quarter, so only got it built last week, just before going to Montreal for a family reunion of my wife’s family. So I’m only now getting around to blogging about it.

To make the log-transimpedance amplifier, I need a component where the voltage is proportional to the log of the current.  For this I used a diode-connected PNP transistor:

The base-to-emitter diode has a current that is exponential in the voltage, and the collector-to-emitter current is proportional to the base-to-emitter current, at least until the transistor approaches saturation (which starts around 10mA).

The base-to-emitter diode has a current that is exponential in the voltage, and the collector-to-emitter current is proportional to the base-to-emitter current, at least until the transistor approaches saturation (which starts around 10mA).

The A1015 PNP transistor has a voltage proportional to the log of current, with about 60mV/decade. I did not use a unity-gain buffer when measuring the voltage and current, connecting the Teensy ADC channels A10 and A11 directly to the emitter and base+collector of the transistor. Measurements at less than 5µA were difficult, because the high impedance of the sense resistor made the ADC measurements inaccurate.

I tried a pulse monitor using the A1015 PNP transistor as the log-impedance element, and it worked ok, but I can do better, I think, using an IR LED as the log-impedance element:

The WP710A10F3C IR LED has a low forward voltage, and can be used from 100nA to 30mA, given that we don't need high accuracy on the log function. We get about 105mV/decade, so it is more sensitive than the A1015 transistor.

The WP710A10F3C IR LED has a low forward voltage, and can be used from 100nA to 30mA, given that we don’t need high accuracy on the log function. We get about 105mV/decade, so it is more sensitive than the A1015 transistor. Note: I did use a unity-gain butter for these measurements, which allowed me to get down to about 50nA—still much higher than the photocurrents I observed in very low light.

The IR LED has a wide range over which the voltage is the logarithm of the current, or \frac{dV}{dI} \approx 241mV/I. For 10nA, the equivalent gain is about 24MΩ, and for 1µA, the gain is about 240kΩ. For 10pA (about the smallest current I’ve observed for operating the pulse monitor in very dim light), the equivalent gain is 24GΩ.

This amplifier uses only 3 op amps: a log-transimpedance stage with an IR LED as the impedance, and two bandpass inverting amplifiers.

This amplifier uses only 3 op amps: a log-transimpedance stage with an IR LED as the impedance and two bandpass inverting amplifiers.

The 330pF capacitor in parallel with the log-impedance is very important—without it I get very short glitches which the next two stages lengthen into long glitches in the passband of the filters.  Making the capacitor larger reduces the glitches, but makes the corner frequency of the effective low-pass filter too low when light levels are very low, and the signal is attenuated.  Any smaller, and the glitches don’t get adequately removed.

I have tested the pulse monitor over a wide range of light levels, with a DC output of the first stage from 234mV to 1.033V, corresponding to photocurrents of 11pA to 463µA, a range of 42 million (7.6 decades). At very low light levels, the signal tends to be buried in 60Hz interference, but if I ground myself, it is still usable.

In very low light, the capacitive coupling of 60Hz noise buries the signal, but the bandpass filters help recover it.

In very low light, the capacitive coupling of 60Hz noise buries the signal, but the bandpass filters help recover it.

At high light levels, it is easy to get clean signals, as the 60Hz interference is swamped out by the large photocurrent.

At high light levels, it is easy to get clean signals, as the 60Hz interference is swamped out by the large photocurrent.

Note that the voltage swing is almost independent of the overall light level, as it depends only on the percentage fluctuation in opacity of the finger, which depends mainly on how much pressure is applied. If you get the pressure on the finger close to the mean arterial pressure (so that the finger throbs), you can get quite a large change in opacity—I’ve computed changes of 17% in opacity.

2016 April 28

Revised microphone pre-amp lab too long

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

How many of my posts have the theme “lab too long”? (answer: too many)

I spent 10 hours in the instructional lab on Tuesday and 11 hours today (Thursday) helping students do the microphone pre-amp lab, and my group tutor is going to have to open the lab on Sunday for several students to finish soldering and testing their boards.

This means that the lab is between 1.5–2× longer than it should be.  You’d think that I would be able to predict the length of a lab better by my fourth year of teaching this course!

What went wrong, and how can I fix it for next year?

  • The design is somewhat harder for the first op-amp lab than in previous years, because I made a decision to do all the op-amp labs this year with a single power supply, not dual supplies.  That makes for a slightly more difficult start, but students don’t have to make the transition from dual supplies (which are getting quite rare these days) to single supplies. The transition is a surprisingly hard one for students to make, as the simplification that they learned for the case when the reference voltage is zero no longer apply, and they have to learn everything over again.  Learning the more general form first will, I believe, result in less confusion in the long run, but it does make for a slightly more complex first project.
  • This year I’m having students solder their pre-amp boards, so that they can re-use them as part of their class-D power amplifier in three weeks.  This was a deliberate choice, to reduce the amount of effort in the class-D lab, which was running too long in previous years, but it roughly doubled the time it took students to finish the lab.
  • Because students had larger ceramic capacitors this year, and I had them set the high-pass cutoff frequency near their speaker resonances, some students opted to use very large capacitors and small resistors for their high-pass filters. This made a very small impedance in the passband, and attenuated the signal from the microphone and its large-impedance biasing resistor.
    I’ll have to put a warning in the book about the high-pass filter needing to have a larger impedance than the bias resistor, to avoid changing the current-to-voltage conversion.
  • Some students had the opposite problem, putting a small capacitor with a very large resistor, so that there was a very high impedance signal driving the input to the amplifier. Since we are using op amps with tiny bias currents, this is not a problem for the circuit’s functioning, but it made looking at the signals with the oscilloscope difficult—increasing the difficulty of debugging.
  • Many students were surprised to see that the output voltage was not centered at their Vref voltage.  This provided a teaching moment for looking at the MCP6004 data sheet and explaining the notion of the input offset voltage. Because they were using gains of 100×–300×, the ±4.5mV offset became an output offset of ±0.45V–1.35V, sometimes resulting in serious clipping.  I need to warn students about that imperfection of op amps before they do the design.  A better design would use a multi-stage amplifier, with high-pass filters between stages to get rid of accumulated DC offset.
  • I suggested to several students that they look at Vout vs. Vin, by recording a slow sine wave (say 300Hz) at 5kHz sampling with PteroDAQ.  This turned out to have some interesting effects when students used 32× averaging, because the time delay between the two channels was enough to get the signals far enough out of phase to open up the plot into an ellipse. Again, I’ll need to talk about that in class tomorrow.
  • Lots of students made the mistake of incorrectly applying Ohm’s Law and getting too large a bias resistor, so that their microphones were not in saturation at the power-supply voltage of 3.3V.  Luckily, increasing the voltage to 5V (as we will do in the power-amp lab) will rescue their designs.
  • Lots of students made the standard mistakes of skipping a wire or two, or putting a wire in the wrong hole while soldering, but a surprisingly large number connected both nodes for a resistor to the same end of a resistor, leaving the other end unconnected.  I’ve not seen that mistake before, so I don’t know what triggered it.
  • The lead-free solder we have to work with this year (99.3% Sn, 0.7% Cu) is a pain to work with—it doesn’t tin the soldering irons well, and it is difficult to remove from the boards in the event of a mistake.

I think that the soldering lab should not be the first op-amp lab, but I still like the idea of the students having to solder up their microphone preamps. So I’ll have to do a major reorganization of the book this summer, to move a different lab into the first position.

Currently, I’m thinking that the transimpedance amplifier and pulse monitor lab would be a good choice as the first op-amp lab.  It would be a bit unusual to start with a transimpedance amplifier rather than a standard voltage amplifier, but the transimpedance amplifier is actually conceptually simpler.  Unfortunately, the pulse monitor using a transimpedance amplifier really needs to be 2 stages, with a transimpedance amplifier to bias the phototransistor, a high-pass filter, and an AC gain stage.  (Yes, I know I’ve posted about pulse monitors without amplifiers, but a major point of the lab is to teach about transimpedance amplifiers.)

The corner frequencies for the pulse monitor are really low, requiring big resistors even with their biggest capacitors, so the “too small a resistor” problem goes away, though not the “too big a resistor” problem.

By making the microphone preamp the second, or even third, op amp lab, students will spend less time on getting a breadboarded design working, and more time on learning to lay out and solder their circuits. They’ll also be much more amenable to a 2-stage design, to reduce the output offset voltage.  I think that rearranging the labs may be worth the effort it will take to rewrite the corresponding chapters of the book, but undoubtedly something else will go wrong next year, and I’ll have to do yet another major revision.

Ah well, at least I’ve gotten the demo for tomorrow’s class (blood and breath pressure) working tonight, and I’ll be able to get to bed before midnight.

2015 July 5

Pullup vs. transimpedance amplifier

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

I have used both pull-up resistors and transimpedance amplifiers to read light signals from phototransistors and photodiodes (see Colorimeter design—weird behavior and Optical pulse monitor with little electronics, for example, though any of the posts tagged phototransistor or transimpedance amplifier may be relevant), so I decided to do a post about what the difference is in terms of performance.

Test setup for comparing pullup resistor and transimpedance amplifier.  The Arduino board outputs a pulse train with two different pulse widths (approx 65µs and 125µs).

Test setup for comparing pullup resistor and transimpedance amplifier. The Arduino board outputs a pulse train with two different pulse widths (approx 65µs and 125µs).

Obviously, a pull-up resistor is simpler and cheaper—it is hard to get much simpler or cheaper than a single resistor—so why ever use a transimpedance amplifier with a phototransistor?

I believe that the answer comes down to speed.

With a pullup resistor, you have a common-emitter amplifier—the photocurrent generated at the base-collector junction becomes the base-emitter current, which controls the collector-emitter current, and the voltage swing at the output is the change in the collector current times the resistance of the load resistor. As you increase the load resistor, you get more voltage swing. But there is a fly in the ointment—the Miller capacitance between the base and the collector, which serves as a negative feedback loop limiting the slew rate of the output.  I’ve looked at that feedback loop before in More on nFET Miller plateau, for example, but the analysis here is slightly different.

Phototransistor with pullup resistor, showing the Miller capacitance (collector-base capacitance) that provides a negative feedback loop.

Phototransistor with pullup resistor, showing the Miller capacitance (collector-base capacitance) that provides a negative feedback loop.

The current through the capacitor from the collector to the base is C \frac{dV_{C}}{dt}, assuming that the base voltage is roughly constant.   We end up with a differential equation:

I_{CE} = \beta I_{BE} = \beta \left( I_{photo} + C \frac{dV_{C}}{dt} \right)

V_{C} = V_{cc} - R I_{CE} = V_{cc} - \beta R I_{photo} - \beta RC \frac{dV_{C}}{dt}

In response to a step change in  the photocurrent, the voltage does an exponential decay towards the endpoint  V_{cc} -\beta R I_{photo} with a time constant of \beta RC.  If we choose a large R to get a large voltage swing, then we end up with a slow rise and fall time.  At high frequencies, we end up with a considerable loss of signal—we have a low-pass filter with corner frequency \frac{1}{2 \pi \beta R C}.

We can speed up the transitions by using a  transimpedance amplifier, which eliminates the change in voltage of the collector, holding it at the same voltage as the positive reference input. The photocurrent still has to charge and discharge the base-collector capacitor C, but there is no longer the pesky multiplication by \beta, the current gain of the transistor, so our bandwidth is  theoretically \beta times higher than with the pullup resistor.

Of course, the slew rate of the output of the transimpedance amplifier is  also limited by the amplifier characteristics. Using an MCP6004 op amp (which has a 600mV/µs slew rate, and 1MHz gain-bandwidth product) and  feedback resistor of 3kΩ to get the same low-frequency gain as with a 3kΩ pull-up resistor, we get much faster rise and fall times than with the pullup resistor:

The top, green trace is using the transimpedance amplifier, while the bottom, yellow trace is from the pullup resistor.  Both are at 100mV/division and 50µs/division, but the DC offsets are different.

The top, green trace is using the transimpedance amplifier, while the bottom, yellow trace is from the pullup resistor. Both are at 100mV/division and 50µs/division, but the DC offsets are different.

I see about 5 times faster edges with the transimpedance amplifier, but I expected a bigger improvement than that—the current gain on NPN transistors is usually in the hundreds. I have a fairly large VCE (2.5V for the transimpedance amplifier and 4.5V—4.7V for the pullup), so the transistor should be well into the saturation region.

If I have a stronger input signal (by lining up the LED and phototransistor better), I get much sharper edges from the transimpedance amplifier:

Again with 3kΩ pullup or transimpedance amplifier, but with a stronger light input.  The vertical scale is now 1V/div, but the horizontal is still 50µS/div.

Again with 3kΩ pullup or transimpedance amplifier, but with a stronger light input. The vertical scale is now 1V/div, but the horizontal is still 50µS/div.

The fast edges for the large signal may be an illusion—the op amp output is hitting the 5V rail and clipping. That saturation also explains why the low-going pulses are shorter than they should be. So maybe the rise and fall for the larger pulses is still slow. I changed the resistors to 1kΩ, which should speed up the rise and fall and avoid clipping for the strong signals:

With 1kΩ pull-up and transimpedance resistors and a strong input signal, the ratio of the transition times looks about how I expected with a 1V/div, 50µs/div trace.

With 1kΩ pull-up and transimpedance resistors and a strong input signal, the ratio of the transition times looks about how I expected with a 1V/div, 50µs/div trace.

I think that the ringing on the rising edge is due to the slew rate of op amp not being fast enough to keep up with the phototransistor and the negative input of the op amp dropping a bit below the positive one.  There is such a triangular blip, about 50mV and lasting about 10µs.  There is a similar upward blip on the downward transitions of the op-amp output, but those don’t seem to cause any any overshoot.

So I think I understand most of what is going on here, but why is the rise/fall time so slow for small inputs?

« Previous PageNext Page »

%d bloggers like this: