Gas station without pumps

2016 October 11

Lego as LED holder revisited

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

In Lego as LED holder, I wrote

I think that the Lego bricks work about as well as the old trans-illumination wooden blocks that I’ve been using for a few years, and they are certainly much easier to make, requiring only drilling two ⅛” holes.

I’ll want to play around with different illumination, also.  Lots of cis-illumination pulse monitor kits seem to use green LEDs, for example.  Do those work better?

Since then, I’ve played around with a couple of different approaches for using Lego.  The first, and most obvious, move was to use separate bricks for the LED and the phototransistor. If the phototransistor brick is clicked onto the top of the LED brick, then there is the ABS of the brick top between them, and very little light leakage.  I tried both 1×1 and 1×2 bricks, which cost about the same at about 3¢ each on the used market.

Because I was too lazy to wire leads onto all my different LEDs, I also tried just sticking the LED in the breadboard and resting my finger on the bricks—it isn’t very sturdy, but for quick testing it is not bad:

The LED can support the bricks, if you don't press too hard.

The LED can support the bricks, if you don’t press too hard.

I tried using several different LEDs. I got good results with 700nm and 607nm peak LEDs, but nothing but DC drift with green (565nm) LEDs. I would have tried a yellow LED, but I only had ones in 5mm packages, which is too big even for the axle holes, so the poor results there may have been due to mechanical, rather than optical difficulties (some signal was visible).

Here are the results with a 700nm red LED:

There is a lot of DC drift, but the underlying 3–4mV signal is clear.

There is a lot of DC drift, but the underlying 3–4mV signal is clear.

So, I have (at least) three choices for how to do cis illumination with Lego bricks, all of which I like better than using wooden blocks:

I can drill off-center holes in Lego Technic bricks, or centered holes in 1×1 or 1×2 bricks.

I can drill off-center holes in Lego Technic bricks, or centered holes in 1×1 or 1×2 bricks.

Drilling the bricks is very easy, and it would be even easier, if I made a jig that aligned the brick, rather than having to fiddle with the drill-press vice. I might even have the students drill their own bricks. I did not put Lego bricks on the parts list, but if I have to buy $5 worth of Lego bricks for this Winter’s class, it is no big deal.

2016 October 9

Lego as LED holder

Filed under: Circuits course,Uncategorized — gasstationwithoutpumps @ 15:00
Tags: , , ,

In Pulse monitor using log amplifier, I talked about the problems I was having with using wooden blocks for holding an LED and phototransistor side-by-side, because the wood was too transparent, and the rather clumsy test I made using electrical tape:

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.

I suggested in that post that I would buy a chunk of black ABS plastic for $10 and try making the finger cradles out of that. I realized later that I already have some black ABS plastic, in the form of Lego bricks. If I could use them, that would save me a lot of trouble, and provide a more easily duplicated block for others to use.

I ended up trying a black 1×2 Technic brick (which would cost about 1¢–3¢ each on Bricklink), drilling two ⅛” (~3mm) holes in the faces on either side of the axle hole. The axle hole in the Technic brick provides a light barrier between the two optoelectronic components:

View of the Lego Technic brick from the bottom, showing the light barrier between the two optoelectronic parts. The bottom needs to be covered (with another brick or electrical tape), and the optoelectronic components need to be taped in place.

View of the Lego Technic brick from the bottom, showing the light barrier between the two optoelectronic parts.
The bottom needs to be covered (with another brick or electrical tape), and the optoelectronic components need to be taped in place.

View of the drilled Lego Technic brick, showing the optoelectronic components.

View of the drilled Lego Technic brick, showing the optoelectronic components.

I had hoped to be able to insert the 3mm LED and phototransistor from the bottom of the brick, but there was not enough clearance to do so easily, so I inserted them from the opposite face of the brick.

I tried recording the light levels with the front face taped over with black electrical tape, and with a finger covering it. The difference in voltage was large, indicating that the light through the finger was much more than the light leakage around the axle-hole light barrier. I was using an LTR-4206 phototransistor and a 1N914 diode followed by a unity-gain buffer.

I got around 394mV with the finger and 275–284mV with the holes taped. The variation on any given recording run with the holes taped was only about 0.3mV, but different runs, with different amounts of sunlight falling on the brick gave different levels. The minimum difference between the finger and the taped block is about 110mV, which translates to a 19.8dB difference in light (or a factor of 9.8).

But I was not able to get a pulse measurement with cis IR illumination.  I could get a signal of about 1mV peak-to-peak with ambient (shaded sunlight) illumination, which corresponds to about 0.18dB, or 2% fluctuation in finger opacity, but that depended critically on the pressure on my fingertip—if it wasn’t just right, I got no visible pulse signal, just noise.  I could get a bit more consistent results by putting the Lego block between my index and middle fingers and using a rubber band to clamp the fingers together.  If the squeeze was just tight enough to throb, then I got fairly clean results, and I could get them fairly consistently, but I’m not sure whether others will be able to get similarly consistent results.

I also tried taping up the block with no IR illumination, to measure the dark current.  I got 67mV, which should correspond to about 10nA, which is pretty good, since the spec for the LTR-4206 phototransistor give the max dark current as 100nA.

Bottom line: I think that the Lego bricks work about as well as the old trans-illumination wooden blocks that I’ve been using for a few years, and they are certainly much easier to make, requiring only drilling two ⅛” holes.

I’ll want to play around with different illumination, also.  Lots of cis-illumination pulse monitor kits seem to use green LEDs, for example.  Do those work better?

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.

 

Next Page »

Blog at WordPress.com.

%d bloggers like this: