Gas station without pumps

2016 October 2

Pulse monitor using log amplifier

I am currently rewriting the optical pulse monitor lab for my Applied Electronics for Bioengineers book, because I’ve moved it earlier in the course, and because I need to remove the calculation of how big the signal should be, which never worked out very well.  There were way too many assumptions in the calculation, and it turned out to be much easier and more accurate to “try it and see” than to do the calculations.

I always do the labs (often several times in different ways) while writing the lab chapters, so I’ve been playing with pulse monitors again.  I’ve decided that I will definitely have the students do a logarithmic transformation of the photocurrent to voltage, as that eliminates the need to guess a resistance value for the first-stage amplifier.  The amplifier can be designed in two stages, with the first one doing the logarithmic conversion and the second one providing sufficient gain over the desired frequency range (where “sufficient” gain is determined by measuring the output of the first stage).

In Using 4¢ diode for log-transimpedance, I talked about using a 1N914 diode as the feedback element of a transimpedance amplifier to get an output voltage as (roughly) the log of the input current.  There are actually two circuits that are subtly different ways to convert the log of current to voltage:

Two circuits that convert the logarithm of light intensity to voltage.

Two circuits that convert the logarithm of light intensity to voltage.

One of the exercises in the book is to compare the circuits (particularly looking at the constraints on what Vref can be in each).

Because I’d not played with it before, I tried using the unity-gain buffer design this weekend, to make sure the circuit worked and to see whether a single-stage amplifier provided enough signal to record with PteroDAQ using the 16-bit ADCs in the Teensy boards. I was also interested in trying out a new design for holding the phototransistor, so that students could experiment with ambient-light pulse monitors and cisillumination, where the illuminating LED is on the same side of the finger as the phototransistor.  In previous years we have always used transillumination, shining the light through the finger, but most wearables use a cisillumination design, because it is mechanically simpler and much cheaper to make.

I played around with a couple of different ways to make a finger cradle and ended up with the following design:

This is cut from a scrap of some softwood (pine? fir?), with a 1" diameter hole for the finger, a ¼" hole at right angles for the wires, and two ⅛" holes between them for the 3mm LED and phototransistor.

This is cut from a scrap of some softwood (pine? fir?), with a 1″ diameter hole for the finger, a ¼” hole at right angles for the wires, and two ⅛” holes between them for the 3mm LED and phototransistor.

The finger cradle worked great for ambient light, but when I tried using it for cisillumination, I could not get it to work—I had plenty of photocurrent, and if I modulated the LED the photocurrent was modulated, but I never saw a fluctuation that corresponded to the pulse in my finger. It turned out that the problem was that the wood is too transparent—I was getting so much light through the wood, that the fluctuation in what was returned from my finger was a tiny fraction of the total light—too small to be visible above the noise floor.

I mentioned this problem to my wife, who suggested I use black electrical tape. I’m not sure she quite understood the problem, since the wood was solid between the LED and phototransistor, but her solution was a good one—I just needed to put the tape in the middle of the block of wood!

By cutting between the two 3mm holes I could put black electrical tape to block the short-circuiting light path.

By cutting between the two 3mm holes I could put black electrical tape to block the short-circuiting light path.

With this design I could get small but recordable signals with either ambient light or cisillumination:

Response of first stage amplifier with an LED desk lamp shining through my left thumb.

Response of first stage amplifier with an LED desk lamp shining through my left thumb.

Output of first stage using an IR emitter on the same side of the left thumb as the phototransistor.

Output of first stage using an IR emitter on the same side of the left thumb as the phototransistor.

Both the plots above are a little misleading, as they were sampled at 60Hz, to alias out any 60Hz or 120Hz interference. With steady bright light from my LED desk lamp, I got similar plots even at 600 Hz, but with compact fluorescent illumination, the signal was buried in 120 Hz interference:

With 600 Hz sampling, it is easy to see the effect of modulated light.

With 600 Hz sampling, it is easy to see the effect of modulated light.

I don’t particularly like the electrical tape and wood approach to making the finger cradle—it is a bit fragile, and the tape needs to be replaced frequently.  Furthermore, ambient light reaches the phototransistor through the sides and ends of the block, unless the whole thing is wrapped in electrical tape. I think that I’ll buy a chunk of black ABS plastic and try making the whole thing out of it. I can probably get a dozen finger cradles out of a 1′ length of plastic, if I don’t mess anything up (and if all my drills work with ABS—I’ve never worked with ABS as anything but Lego bricks).  Another alternative is to go to the hardware store and see how thick the black ABS couplers are—I might be able to make a finger cradle by cutting one in half lengthwise, if the wall thickness is at least 6mm.  I’d still have to add something to keep it from rolling around.

In the past, I’ve thought about using pulsed light to make pulse monitor measurements that are less sensitive to fluctuations in ambient light. The idea is that I would make a measurement with the LED off, turn the LED on, wait a little while for the sensor to settle, then make another measurement. The difference between the measurements would be due just to the LED light, if the ambient light is changing slowly enough not to be very different between the measurements. I’m not sure that this is a good idea (the large change in light level means that there would have to be less analog amplification than for steady illumination, for example), but I was curious how long the on-pulse would have to be to get good measurements.

I hooked the IR emitter up to a hysteresis oscillator, to get nice sharp square waves, then recorded the output of the amplifier with my Bitscope USB oscilloscope. I used the differential probe to get an extra gain of 5 and AC coupling. I recorded 1156 traces, then used my retriggering and averaging program to superimpose and average the pulses. I ended up with between 2300 and 3500 pulses being averaged (depending where on the waveform you look).

The circuit responds fairly quickly to a rising edge, roughly like having an RC time constant of 84.5µs.

The circuit responds fairly quickly to a rising edge, roughly like having an RC time constant of 84.5µs.

The response to a falling edge is slower, roughly like an RC time constant of 207.8µs.

The response to a falling edge is slower, roughly like an RC time constant of 207.8µs.

The response to rising and falling edges is quite different, because of the nonlinear nature of the diode. When we are charging the parasitic capacitance, we have a fairly large photocurrent to do it with, but when we are discharging, the current gets quite small as the voltage across the diode drops. With a linear system, response to a positive step and negative step would be identical, except for the sign.

Both response times are fast enough that the shape we were seeing for the pulse waveforms is due to changes in the opacity of the finger, not due to distortion or filtering in the amplifier.  There is a sudden increase in opacity, followed by a gradual recovery as the blood flows through the capillaries and veins out of the thumb.

If I were to try the difference between LED-on and LED-off measurement, I’d want to have the LED on for at least 400µs, then off for at least 1ms.  (I’d probably do on for 400µs, then off until the next 1/60s tick, making a 2.4% duty cycle for the LED.)

Note also that the 50mV swing here is much larger than the 3mV swing that I got from pulse measurements, so gain would have to be limited to avoid clipping.

2016 August 20

Using 4¢ diode for log-transimpedance

In Transimpedance pulse monitor does need low-pass, I realized that Schottky diodes were not going to work well for the transimpedance amplifier, and in Using nFET body diode for log-transimpedance, I tested using the body diode of a power nFET, finding that it worked quite well over at least 7.5 decades (from 1nA to 40mA).  But I wanted to see whether students could use a cheap 4¢ general-purpose diode.

I used the same setup as when testing the nFET body diodes.  The results were pretty much the same whether I used a 1N914B or 1N4148 diode (they share a datasheet, but the 1N914B has somewhat better constraints on the forward voltage):

The gain (in mV/dB) is about 85% larger than using an nFET body diode.

The gain (in mV/dB) is about 85% larger than using an nFET body diode.

Note that at currents over about 1mA the diode current starts to saturate, deviating from the exponential pattern.

Note that at currents over about 1mA the diode current starts to saturate, deviating from the exponential pattern.

When I tried using the 1N914B diode in the same log-transimpedance amplifier as I used for the nFET body diode, it didn’t work—I got output that looked nothing like a pulse (nor like 60Hz interference). I could recover proper behavior by putting a large (100nF) capacitor in parallel with the diode, to make a low-pass filter to remove signals above a few Hz, but that wasn’t necessary for the nFET body diode (perhaps it had enough internal capacitance to do the filtering). I could reduce the capacitor to 100pF, with 60Hz interference coming in, though not being too bad, but reducing to 10pF gave me noise again rather than the pulse signal.

I was hoping not to need that extra capacitor, because the design is already more complicated than I would like for this stage of the course, and figuring out what capacitor to use is difficult—trial and error is easier than rational design here!

I tried tracking down the big, short (less than 250µs) spikes that were corrupting the signal. The first thing I tried cleaned up the problem entirely: disconnecting the power supply from the laptop so that the USB power was coming from the laptop battery rather than the power supply . That this worked actually surprised me, since the 3.3V supply and the 1.65V Vref both had beefy bypass capacitors.

I don’t know whether the noise problems are in the microcontroller (which is providing the regulated 3.3V from the noisy USB 5V) or are coupled into the analog circuit some other way. Putting a 10µF capacitor from the USB5V to GND did not help when the power supply was connected, so perhaps the problem is radiated from the power-supply cable rather than conducted through the USB cable.

I’ve noticed problems before with noise from the laptop power supply causing problems in my analog circuits (the 90kHz interference in my ultrasound experiments), and I’ve see much bigger problems with some of the cheap Windows laptops students use. The bottom line, I guess, is that  I have to tell students to run PteroDAQ from battery power, not switching-supply power, even if the power supply seems more than adequately bypassed.

2016 August 15

Using nFET body diode for log-transimpedance

Filed under: Data acquisition — gasstationwithoutpumps @ 21:20
Tags: , , ,

In Transimpedance pulse monitor does need low-pass, I realized that Schottky diodes were not going to work for the transimpedance amplifier, but I didn’t have any ordinary silicon signal diodes to test with.  I’ve previously used the base-emitter junction of bipolar transistors for log amplifiers, but I decided this time to test the body diode of an nFET.

I spent a fair amount of time trying to measure the V-vs-I characteristic over a fairly wide range (though only with low currents).  I ended up using several tricks:

  • using several different sense resistors to measure the current
  • censoring the data so that very low differential voltages across the sense resistor are not plotted
  • using unity-gain buffers to provide sufficient drive for the analog-to-digital converter (essential when using large sense resistors)
  • using low-pass filters after the unity-gain buffers to try to reduce 60Hz interference (not entirely successful for the largest sense resistor)
  • doing fitting to estimate the effective input offset of the differential analog-to-digital input for the voltage across the sense resistor (mainly from the unity-gain buffers)
Here is the test fixture I used. (I reduced the noise a bit more on the 5.6MΩ run by increasing the low-pass filter resistors to 2.2kΩ, but that made things worse for the 120kΩ sense resistor.)

Here is the test fixture I used. (I reduced the noise a bit more on the 5.6MΩ run by increasing the low-pass filter resistors to 2.2kΩ, but that made things worse for the 120kΩ sense resistor.)

The result of all this care was one of the cleanest logarithmic response plots I’ve collected:

I have over 7 decades of data here, and the log fit is excellent over the whole range.

I have over 7 decades of data here, and the log fit is excellent over the whole range.

Measuring down to 1nA on a breadboard is not easy, as the 60Hz interference is a big problem.

I fitted the slope of the log curve by alternating between fitting the offset using the 4.7Ω data and the slope using the 120kΩ data (the 5.6MΩ data seemed a bit too noisy to me). I collected several other sets of data but the plot was too cluttered when I tried to include them, so I kept just enough to get good overlap between the ranges. I’ve got a good logarithmic fit here for about 150dB, and it looks like I could go another 20dB higher (though thermal effects might start mattering above 0.1A).

The equivalent resistance at the bottom of the current range is about 150MΩ and about 14Ω at the highest current I measured with (47mA). Because the equivalent resistance varies so much, the corner frequency of the low-pass filter made by putting a 680nF capacitor in parallel to the diode also varies a lot (17kHz@14Ω, 1.6mHz@150MΩ).

I tried using the body diode in the same minimally filtered circuit as I used for testing the Schottky diode, and got usable results in even in moderately low light:

The 60Hz noise is huge, but can be filtered out digitally.

The 60Hz noise is huge, but can be filtered out digitally.

Brighter light makes the 60Hz noise be smaller (probably because the capacitive coupling introduces a current which is a smaller fraction of the total current), but does not change the strength of the filtered signal. When I switch to very bright light (a 650 lumen bike headlamp right against the finger), then the signal gets stronger, but I had to shift the bias voltage down to 1.65V, as the DC bias on the diode got to 0.55V or more.

So the question still plaguing me: can I use a log-impedance amplifier as the second amplifier lab, given that low-pass filtering is essential?

Putting the filtering in the second and third stage is simpler than putting it in the transimpedance stage, as the corner frequency is independent of the light level then.  It is sufficient to put the RC filter in just the second stage, as long as the attenuation at 60Hz is sufficient—I found that about 48dB attenuation was enough, though with just one RC element that distorts the pulse signal also, since the corner frequency has to be very low (0.24 Hz), below the 1–2Hz of the pulse.  If I do low-pass filtering in both stages, I could use 3Hz cutoffs, which preserves the interesting part of the signal.

Doing two stages of low-pass filtering with 1.06Hz and 1.17Hz cutoffs provides enough suppression of the 60Hz interference that I did not need digital filtering. In medium light, I got a signal large enough to saturate the third stage (so I’d need to redesign with lower gain).  With 1.6Hz and 2.6Hz cutoffs, the signal is still much larger than the 60Hz noise, and less distorted by the filters.  The pulse shape is still more dependent on the filters than on the actual signal from the transimpedance amplifier, which is almost a sawtooth (hence having high-frequency components that are removed by the filter).

If the 60Hz interference is small enough that the amplifiers don’t saturate, I can eliminate it by aliasing (sampling at 60Hz, so I’m at the same place in the interference waveform on each sample). But if the 60Hz interference is too large, then the signal is clipped and aliasing can’t recover the pulse signal.  So digital filtering is definitely optional here—students can get good results with just analog  filters and aliasing.

Alternatively, we could look at just the transimpedance amplifier output, and use digital filtering to clean up the baseline shifts and 60Hz interference.  The biggest problem is that the PteroDAQ sparkline looks like a constant—the fluctuation of a few mV is only visible once the data has been plotted on a larger scale.

 

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.

Next Page »

%d bloggers like this: