Gas station without pumps

2014 May 14

Phototransistor lab

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

Once again, no one came to lab today with their prelab homework done. There was a lot to do again this week, as they needed to figure out how much light was emitted by an LED, how much of that would get through a finger, and how much photocurrent that would induce in a phototransistor. The models they are using are pretty crude, but should be able to get within a factor of 10 of the right amount of current. I provided much more scaffolding in the handout, even doing some of the computations for them, but it doesn’t seem to have helped any.  I need to come up with some way to get students to actually do the prelab calculations—maybe collecting them as homework on Mondays?

They also had to do some quick checks to make sure that they could get an LED to light up with the amount  of current they designed for, and that the phototransistor and photodiode provided roughly expected currents in room light (and that shadowing the photodetector resulted in a change of current). A lot of the students still had serious problems with debugging (like not being able to figure out that they had put the LED in the wrong way around).

I did show the students the trick of looking at IR emitters with a digital camera to see them light up blue, but the trick did not work with one of the student’s cameras (an iPhone, don’t know which model), which apparently has an IR-blocking filter for its camera.

Only one group got as far as building their transimpedance amplifier, and then only by extending the lab to 4.5 hours instead of 3.  I suspect I’m going to have a late night on Thursday this week as well shepherding the rest of the groups through both the first-stage and second-stage of the amplifier.

I found one serious error in my handout for the lab, giving myself a REDO for the lab—the transimpedance amplifier had the + and – inputs swapped! The problem arose because I always put the – input on top, but SchemeIt puts it on the bottom, and I forgot to flip the component before wiring it up. I have already redone the handout, fixing that figure.

Tomorrow’s lecture class is supposed to be on filtering and amplifying the output of the first stage, but with only one group having finished the first stage and observed the output on the scope, this may be a difficult task to explain.  I’ll probably have to give them some numbers computed from my results, which were that I got about a 2–9nA pulse-based signal on top of a 100–150nA DC signal.

One important observation that my son made tonight was that the big pulse signals only came when I pressed my finger down with a pressure between my systolic and diastolic blood pressure.  I knew that there was a sweet spot, where I could feel my pulse, but I had not stopped to think what caused that.  Both feeling the pulse and the large change in blood volume come from stopping the flow during diastole, but allowing blood through during systole.

 

2014 May 12

Lecture for pulse monitor

Filed under: Circuits course — gasstationwithoutpumps @ 19:27
Tags: , , ,

Today’s class started with handing back the audio-amp lab reports, which spanned a much wider range than usual. Everyone had an ok design, but some students explained it well, while others had numbers that appeared by magic or with completely incoherent explanations. Although I could have predicted a couple of the worst reports, the group that did the best was not the one I expected.  I’m quite pleased that they did such a good job, as I was not sure I was getting through to them—it made up for my disappointment at the relatively poor performance of a couple of the groups I had expected better of.

I pointed out to the students that there was no “correct” answer to most design problems, and that being able to explain how they came up with the design was at least as important as the design they came up with.  If some spec changed, an engineer would want to be able to modify the design without having to do the whole thing over from scratch.  (I didn’t say it, but I think that some of the groups that couldn’t explain their work would not be able to redo their designs from scratch, even if none of the specs changed.)

The multistep problems in last week’s lab and this week’s are difficult just because they have so many chained steps, though each individual step is pretty easy. I suspect that many of the students have never worked multistep problems before and are shutting down the moment they don’t have a predefined protocol to follow.

I asked how many people had done the prelab for tomorrow’s lab (as I had requested they do over the weekend). As expected, no one. I asked how many had attempted it—only about a third of the class. I asked where they were getting stuck—on the first step, figuring out how much light came out of the LED. Rather than going on and doing the rest of the chain of computations symbolically, they just gave up, so that they had nothing done, rather than an almost complete problem solved, with just one hole in it to be filled.

My lecture for most of the remaining hour consisted of explaining to them almost exactly the same thing that was in their lab handout. Luckily, I was expecting this inability or unwillingness of students to learn from written material, because I saw it last year also (though not on this lab, since this lab is all new).  I would really love it if students would read things and at least try to do the assigned homework before class and come in with specific questions, rather than expecting to get everything in lectures for the first time. But I’ve resigned myself to students having less than zero initiative about learning new things.

Today had been scheduled for photodiodes and phototransistors, but we only got to those topics for the last 15 minutes of class, as I spent the first 55 minutes patiently going over what they needed to do to convert candelas to lumens to watts for the LEDs, to estimate how much light is absorbed or scattered in a finger, to estimate how much of the remaining light makes it to the sensor, and to compute how much current one would then see in the sensor. I didn’t do the computations for them (which seems to be what they expect—too much scaffolding in their other classes?), but I’m hoping that they can now read the homework assignment.

Despite my warnings that they would need to have the prelab done before lab starts tomorrow, or they are likely to run out of time for this lab, I’m betting that only one group will have gotten as far as a schematic, and that most of the class will again waste most of the lab time doing their prelab homework.  I’ve not figured out a way to break them of this, but I’ll need to get better at getting students to work outside lab, or I won’t be able to handle  two lab sections next year.

I am going to suggest that they write up half their lab report before Wednesday’s class, so that they can uncover the places where they can’t reconstruct their thinking before the final report is due on Friday, while there is still time to ask questions and modify the design.

On Wednesday, I plan to talk about the second stage of the amplifier for the pulse monitor, adding gain for 0.2Hz–30Hz but blocking DC.  But figuring out how much gain they need requires them to have completed the first stage of the amplifier on Tuesday, and looking at the output with an AC-coupled oscilloscope, to see and measure the small fluctuation caused by opacity changes in the finger. I’m not sure that all groups will get that far, having not started on the design over the weekend as I told them to.

The class ended after a very brief and informal presentation of how a diode works, what causes photocurrent, and why the phototransistor has 100–1000× the current of a photodiode.

Sorry if I seem to be too much of a curmudgeon today—I’m very tired and even entirely expected behavior from the students was depressing.  This isn’t even a “students-nowadays” complaint, as I remember having the same sort of disappointment about students being unwilling or unable to read assignments when I started as a professor 32 years ago. Perhaps there is some Shangri-La somewhere, where most students do the assigned reading and struggle to understand it before class rather than waiting to be spoonfed, but I’ve never taught there.

 

2014 March 16

New phototransistor lab

Filed under: Circuits course — gasstationwithoutpumps @ 00:54
Tags: , , , , , ,

In Phototransistor I talked about one possible phototransistor lab, that looked at the response speed of a phototransistor, as a function of the load resistor.  I rejected that last year as insufficiently interesting for bioengineers.

The lab for phototransistors that I used last year was a “tinkering” lab, where I tried to get the students to play with the hysteresis oscillator that they had built, modulating it with light (see Idea for phototransistor/FET lab). I didn’t think that it was a very successful lab (see Tinkering lab reports show problems), and I’d rather have a lab that seems more directly “bio” oriented.

One lab I’ve not given in class, but have played with a lot at home, trying to find something that works at the right level of complexity for the students is an optical pulse monitor:

Scott Prahl's estimate of oxyhemoglobin and deoxyhemoglobin molar extinction coefficients, copied from http://omlc.ogi.edu/spectra/hemoglobin/summary.gif The higher the curve here the less light is transmitted.  Note that 700nm has very low absorption, but 627nm has much higher absorption.

Scott Prahl’s estimate of oxyhemoglobin and deoxyhemoglobin molar extinction coefficients, copied from http://omlc.ogi.edu/spectra/hemoglobin/summary.gif
The higher the curve here the less light is transmitted. Note that 700nm has very low absorption, but 627nm has much higher absorption.

I played around with the idea some more last week, using a transimpedance amplifier to convert current to voltage (as in Colorimeter design—weird behavior). I can easily get enough gain to see pulse for a 700nm LED shining through a finger, but I listed the “brighter” LED red diffuse 3mm 625nm WP710A10ID part for this year’s parts kit, so I need to test with it (or with LED IR emitter 5mm 950nm SFH 4512). Because I’ll be making the mechanical part of the pulse monitor for the students, I have to know whether a 5mm or 3mm LED will be used.

Because oxyhemoglobin has its lowest absorbance near 700nm, I expect that switching to either 950nm or 627nm will greatly reduce the signal, needing an extra gain of 5.

The mechanical design I’m thinking of using is a simple one: a 3/4″ diameter hole drilled 2″ deep into a 3″-long block of wood that is 1.5″ by 1.5″, with a 1/8″ hole drilled at right angles to accommodate the LED and phototransistor. Carving out a small channel allows the block to sit flat on the tabletop.
The block with LED in the top hole and the phototransistor in the bottom hole. The phototransistor has a bit of rim, necessitating a shallow 5/32" drill allow the phototransistor to go deep enough into the block for the block to sit flush on a tabletop.

The block with LED in the top hole and the phototransistor in the bottom hole. The phototransistor has a bit of rim, necessitating a shallow 5/32″ drill allow the phototransistor to go deep enough into the block for the block to sit flush on a tabletop.

Block viewed from end with 3/4" hole.  The cross hole for the LED (or phototransistor) and the channel for its wires can be seen on the front.

Block viewed from end with 3/4″ hole. The cross hole for the LED (or phototransistor) and the channel for its wires can be seen on the front.

To connect the LED and phototransistor to a breadboard, the leads need to be extended:

I added color-coded leads to the phototransistor and LED, making sure that the negative lead (the cathode for the LED and the emitter for the NPN phototransistor) were given the black wire. Careful folding and crimping with long-nose pliers gives a good mechanical connection.

I added color-coded leads to the phototransistor and LED, making sure that the negative lead (the cathode for the LED and the emitter for the NPN phototransistor) were given the black wire.
Careful folding and crimping with long-nose pliers gives a good mechanical connection.

Next the connections are soldered to make good electrical connections. It will be good for students to do a little freehand soldering, as their other soldering projects use PC boards.

Next the connections are soldered to make good electrical connections. It will be good for students to do a little freehand soldering, as their other soldering projects use PC boards.

Finally, one or both of the connections should be covered with electrical tape, so that the wires don't short.  (The students don't have electrical tape in their kits—I'll have to remember to bring some in.)

Finally, one or both of the connections should be covered with electrical tape, so that the wires don’t short. (The students don’t have electrical tape in their kits—I’ll have to remember to bring some in.)

In order to help me remember which side has the phototransistor and which the LED, I color-coded the leads differently (yellow wire for LED anode, green wire for phototransistor collector), and used colored electrical tape to hold the optoelectronic parts in the block (red tape for the LED, blue tape for the phototransistor—matching their package colors).

I did manage to get  the pulse monitor working sometimes, but it seems to be excessively finicky—I need very high gain with careful setting of the bandpass filter parameters to get a signal. The biggest problem is that the second stage of the amplifier, where I do the high-pass filtering to remove the DC component and slow drift, can end up getting saturated.  Because of the high impedance of the feedback resistor, the output stage takes a long time to recover from being saturated. Saturation is a frequent problem with high-gain amplifiers, but I’m not sure I want students dealing with it on this lab.

Initially, the light is bright and the amplifier saturates at one rail.  When a finger is inserted in the sensor, the light drops enormously, and the amplifier output swings to the other rail.  It takes a very long time (about 30 second here) before the limited current through the feedback resistor can charge the capacitor in the high-pass filter enough to restore the op-amp inputs being the same voltage.

Initially, the light is bright and the amplifier saturates at one rail. When a finger is inserted in the sensor, the light drops enormously, and the amplifier output swings to the other rail. It takes a very long time (about 30 second here) before the limited current through the feedback resistor can charge the capacitor in the high-pass filter enough to restore the op-amp inputs being the same voltage.

The combined gain of the two stages at 1Hz (about the frequency of my pulse) is around 132MΩ, and the output is still only about 0.25V, so the fluctuation in the input current must be around 2nA. That’s not as small as the signals in a nanopore, but it is small enough to be troublesome.

I tried a different set of components that gave me a gain of about 240MΩ at 0.9 Hz, and that amplifier started clipping the output, swinging from around -0.8v to +1.6v.

After the first stage (with a gain of about 1.7MΩ at 0.9Hz and 5.6MΩ at 0Hz), I see about a 10mV swing on top of a DC signal of 0.6 to 0.8v (with considerable drift). That implies about a 6nA signal at 0.9Hz, while the DC signal is about 125nA.  The magnitude of both the DC and the AC component varies a lot, depending on which finger I use and how firmly I press the finger against the sensor.  I can pretty consistently get 2–9nA of AC on top of 100–150nA DC.  I think that good corner frequencies for the low-pass and high-pass filters are around 0.3Hz and 30Hz. By making the gain of the transimpedance amplifier as high as I can (without saturating with the DC signal), I can keep the gain of the second amplifier low enough to avoid the problem of saturation in the second stage, and the pulse monitor can detect the pulse within 5 seconds.

 

Another option is to make the first-stage amplification be a logarithmic transimpedance amplifier, rather than linear one, by using a Schottky diode as the feedback element instead of a resistor.  But that is getting well outside what I’m comfortable assigning as a design exercise to the Applied Circuits class. I tried it anyway, but the signal from the log amplifier was too small:  a 10% variation in current only results in a 2.4mV change in the output of the log amplifier, needing a much higher gain than my second stage currently provides.

While the 700nm LED provides a stronger signal, the 627nm LED works well enough, and a 2-stage transimpedance amplifier is reasonable for the students to design.  I probably want it to be a 2-day lab, though, with the low-pass first stage designed and tested for the first day, then the high-pass second stage added to solve the problem of DC offset and drift.  That will require reworking my schedule, as I only allowed one day for the lab in the current schedule.

2014 February 26

Colorimeter design—almost working

Filed under: freshman design seminar — gasstationwithoutpumps @ 00:34
Tags: , , , ,

Since my freshman design students did not show much interest in designing their own colorimeters, and my son has just gotten to the colorimetry labs in his online AP chemistry class, I decided to prototype my own colorimeter design.  (His AP lab relies on eyeballing the light through two columns of fluid and adjusting the length of the light path through one until the intensities seem to match—that’s a very low tech approach, but it seems rather tedious.)

I had made a prototype colorimeter out of black foamcore,which I mentioned in Seventh day of freshman design seminar. I’d meant to blog about it earlier, but I got a bad virus infection of some sort and was out of action for a while.  The prototype I’d made earlier was not very functional—it fit the cuvette tightly, but did not provide an easy way to remove the cuvette from the colorimeter.  I went through two more prototypes today that would allow me to remove the cuvette, but they looked like they would have bad light leaks.  I finally settled on a 4th design, that uses a separate lid, rather than trying to make a hinged lid.  I’ve included a PDF file that has the design for this version: Colorimeter-draft4.

I constructed the colorimeter by spray-gluing the pattern I made to the black foam core, then carefully cutting it out with a razor knife.  The dashed lines are cut only through the top layer of paper and part way through the foam—bending the foam core then snaps the rest of the foam and leaves the paper on the back as a hinge.  I used black electrical tape to hold the colorimeter together, and to block light from coming through the backs of the phototransistor and the LED.

Top view of the colorimeter with the lid in place.

Top view of the colorimeter with the lid in place.

Top view of the colorimeter with the lid off and the wings open to allow grasping the sides of the cuvette.

Top view of the colorimeter with the lid off and the wings open to allow grasping the sides of the cuvette.

I connected the LED through a current-limiting resistor to the 3.3v supply on the Freedom KL25Z board, and the phototransistor with a current-to-voltage resistor to E22. I actually ended up doing two different circuits, using different LEDs:

    I started with the circuit on the left, using a deep red LED that has a peak wavelength of 700nm. Later I switched to a different LED, with a peak wavelength of 627nm. In both cases, I picked the current-to-voltage resistor so that I got near full-scale readings on a blank cuvette.

I started with the circuit on the left, using a deep red LED that has a peak wavelength of 700nm. Later I switched to a different LED, with a peak wavelength of 627nm. In both cases, I picked the current-to-voltage resistor so that I got near full-scale readings on a blank cuvette.

When the KL25Z is reset, the analog-to-digital measurement on E20 is recorded as the intensity for the blank cuvette.  Then the transmittance (measurement/blank) and absorbance (–log10(transmittance)) are reported 10 times a second on the USB serial line.

With the 700nm LED, I could measure from A=0 to A=1.8 (with an opaque piece of foam core blocking the light). Light leakage around the cuvette and from the outside prevented me from measuring higher absorbancy.

The first thing we tried measuring was a solution of blue food coloring (blue dye #1). My son made a stock solution of 1 drop in 10 ml, and we measured the absorbance (with the 700nm LED) at about 0.0028, which seemed rather low to us. He then made a very concentrated solution with 5 drops in 5ml, which looked almost black to us, and the colorimeter reported it as having an absorbance of 0.157, which seemed absurd—that’s almost clear! We tried looking at the sky through the solution and noticed that the sky looked deep red through the blue. This lead me to suspect that the dye was transparent in the near IR where much of the light from the LED was concentrated.

When I switched to a 627nm LED, I had to use a larger current-to-voltage conversion resistor, as the phototransistor is less sensitive to those wavelengths. This meant that the noise level from light level was increased, and so an opaque object read as absorbance around 1. The stock solution read as 1, as did a 2-fold and 4-fold dilution. We went to a 40-fold dilution (so equivalent to 1 drop in 40ml) and got a reading of 0.637. From there, we started 2-fold dilutions:

dilution Absorbance at 627nm
1/40 0.637
1/80 0.407
1/160 0.230
1/320 0.139
1/640 0.0679
water 0.0040
1/1280 0.0380

I was worried that cuvette was stained by the dye, but putting in distilled water after the 1/640 dilution showed that any residual staining could only be contributing a small error.

Here is a plot of one run of the colorimeter:

The colorimeter is reset with a blank cuvette (filled with distilled water).  After a few seconds the blank is removed and the test cuvette is inserted.  After waiting about 20 seconds, it is removed and the blank re-inserted.  The absorbance is fit on the flat part in the middle.  Note that the colorimeter did not return exactly to 0 on this run.

The colorimeter is reset with a blank cuvette (filled with distilled water). After a few seconds the blank is removed and the test cuvette is inserted. After waiting about 20 seconds, it is removed and the blank re-inserted. The absorbance is fit on the flat part in the middle. Note that the colorimeter did not return exactly to 0 on this run.

The data from the run did not fit the straight line of Beer's Law.  It did fit a power-law curve, but the exponent is too low.

The data from the run did not fit the straight line of Beer’s Law. It did fit a power-law curve, but the exponent is too low.

I’m now trying to figure out why we did not get a good fit for Beer’s Law. Here are some possibilities:

  • The dilutions were not done accurately.  That would explain random fluctuations, but seems unlikely to give such a clean, consistent deviation from theory.
  • Beer’s Law doesn’t apply to this example.  That seems really, really unlikely, since this is the canonical experiment done by 1000s of students a year.
  • The colorimeter is not linear.  I’m relying on the phototransistor providing a current proportional to light intensity, even though the voltage across the phototransistor varies.  I think that this is likely to be the problem.  To check it, we’d have to redo the experiment with a different circuit—probably a transimpedance amplifier to do the current-to-voltage conversion.

Unfortunately, my son did not keep all the serial dilutions, so to test a different colorimeter circuit I’d have to make a new series.  I might do that this weekend if I have time.  At least I know what stock concentration to start with—about one drop of food color in 25ml of distilled water.

I’m also interested in trying the colorimeter design with an RGB LED, so that we could try different wavelengths—perhaps doing a Beer’s Law test with yellow food coloring.

2014 February 6

Lying to my students

I’ve been lying to my students a bit with the simple circuit I gave them for measuring light levels:

Simple circuits for measuring light with an Arduino.

Simple circuits for measuring light with an Arduino.

First, previous schematics have been showing a PNP phototransistor, when an NPN one was clearly needed (and I’ve been talking all along to them about NPN phototransistors, and simply not noticing that I was drawing a PNP one).  I’ll have to correct this in class!

Second, although the simple circuit that I gave them is sometimes used, photodiodes are usually used with a constant voltage drop across the diode, with a transimpedance amplifier to measure the current:

The standard design for using a phototransistor uses a current-to-voltage (transimpedance) amplifier.  This holds the voltage across the photodiode constant and provides an output voltage proportional to the current

The standard design for using a phototransistor uses a current-to-voltage (transimpedance) amplifier. This holds the voltage across the photodiode constant and provides an output voltage proportional to the current.

Two common bias voltages are used: one which puts zero volts across the photodiode, so that there is no dark current, and one that puts a few volts of reverse bias on the diode, so that the depletion region at the diode junction is thicker and parasitic capacitance of the junction reduced (improving the bandwidth of the detector).

An even better design, and the one that I would probably use if I wanted to hook up a photodiode to an Arduino or KL25Z for good measurements is a two-stage amplifier:

This two-stage amplifier provides current-to-voltage conversion in the first stage and a simple non-inverting voltage gain in the second stage.  Using two stages allows using a much smaller value for R1, which in turn means a much wider frequency response.  Again the V_bias voltage can be adjusted for minimum dark current (V_bias=V_ref) or for better bandwidth (V_bias several volts lower than V_ref).

This two-stage amplifier provides current-to-voltage conversion in the first stage and a simple non-inverting voltage gain in the second stage. Using two stages allows using a much smaller value for R1, which in turn means a much wider frequency response. Again the V_bias voltage can be adjusted for minimum dark current (V_bias=V_ref) or for better bandwidth (V_bias several volts lower than V_ref).

Of course, the biggest lie I told them was about the meaning of the Open Circuit Voltage spec for photodiodes. A photodiode acts like a tiny photocell, and if not externally biased will produce a small voltage. With the simple circuit at the top of the page, using a PD204-6C photodiode and a 5.6MΩ resistor for R2, I got V2 output voltages from 3mV up to 5.55V.  The photovoltaic effect can raise the voltage substantially above the 5V power rail!  This is not a problem with transimpedance amplifier designs, since the amplifier can provide enough current to keep the cathode of the photodiode clamped at V_ref.  The phototransistor design also does not have the same problem with the photovoltaic effect—using WP3DP3BT as Q1 and R1=120kΩ, I get readings from 1mV to the full 5v, but not beyond 5v.

I think I’ll let the freshman design class know about this problem with the photodiode circuit, and that there is a relatively simple solution, but I don’t think I’ll try to get them to design the improved circuit.  I think it would be a good replacement for the rather unsuccessful phototransistor lab in the applied circuits course, though, especially as transimpedance amplifiers are fundamental to a lot of bioelectronics (patch-clamp measurements of ion channels, nanopores, nanopipettes, …).

Next Page »

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 260 other followers

%d bloggers like this: