Gas station without pumps

2015 May 21

Pulse monitor lab part 2 and power-amp lecture

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

Wednesday’s lecture covered a reasonable amount.  I went over PWM again, stressing the key concept: that the relevant value is the average value of the output. I showed the derivation of the average value from the high value, low value, and duty cycle.  I introduced nMOS (and, to a lesser extent, pMOS) field-effect transistors, and showed how they worked as switches, which is the only way we’ll use them.  I introduced both nMOS low-side switches and cMOS output stages, and talked about shoot-through current.

I did not get to comparators, open-collector outputs, and how to create PWM signals from a comparator and a triangle-wave generator, which is the meat of tomorrow’s lecture.

I spent over 9 hours in the lab again today, because I’ve promised the students that I’ll be in the lab 5 p.m.–7 p.m Tuesdays and Thursdays for the rest of the quarter, but the students were done with this week’s lab by 6 p.m.  I think all but one or two of the groups got working pulse monitors.  Debugging was difficult today.  The most common problems were

  • Wires in the wrong holes on the breadboards—usually an off-by-one error.
  • Phototransistor connected up backwards. Students kept thinking in terms of “long lead” and “short lead” and somewhat arbitrarily assigned a positive and negative meaning to them, without going back to the datasheet to see which was the collector and which the emitter.  This was difficult for me to debug, because the phototransistors had wires soldered on and were covered with electrical tape, so I could not see the original wire length nor the flat on the package, and had to trust the students’ claims about which wire was which.  In one case the problem was only debugged after I connected my LED and phototransistor (where I knew the color coding I’d used) to the student’s circuit and saw that the circuit was working.
  • Centering the high-pass filter and second stage of the amplifier at 0V, even though we were using a single-sided power supply, so they needed to make a virtual ground.
  • Swapping the wiring of the LED and the phototransistor.
  • Insufficient gain in the second stage.
  • Difficulty getting appropriate amounts of pressure on the finger to get a good pulse fluctuation.

The students having the most trouble had not prepared a schematic to work from or had very sloppy un-color-coded wiring, or both.  I’ll have to remind students that taking a half hour at the beginning to set things up carefully can save hours of debugging—too many want to dive in and wire up stuff without a clear idea what they are going to do, just hoping that it will somehow get fixed by the group tutor or me debugging their work. I refuse to do debugging for a group without a schematic, and in some cases I gave students some properly colored wire and asked them to rewire the circuit so that it could be debugged.

One student was unable to get a pulse reading from his finger on anyone’s circuit (including mine).  I don’t know what the difficulty was—he attributed it to too much caffeine today, so that he could not hold his finger steady in the block.  I suspect that he might have been pressing down too hard and squeezing the blood out of his finger.  One student even managed to get a pulse  reading through fingernail polish (she was wearing a red polish, which apparently was transparent enough to still work).

I had set up my transimpedance amplifier (which has adjustable gain from 66MΩ on up) with an oscilloscope for students to see what a good signal looked like.  There is a lot of 60Hz noise capacitively coupled in, but I was getting a 0.5V pulse signal with only about 200mV of interference.  I probably want to lower the corner frequency for the low-pass filter, to reduce the 60Hz signal further (one group that had miscomputed their corner frequency had very low interference, but their signal was also attenuated too much—I think that a reasonable compromise position can be found).  Even groups with very high 60Hz interference were able to get clean signals by sampling at a multiple of 1/60th of a second (20Hz or 30Hz, for example)—the aliasing eliminates the 60Hz signal, turning it into a DC offset.  The only ones who ran into trouble with 60Hz interference were ones who had the gain set so high that the 60Hz interference caused clipping, obscuring the pulse waveform added to the interference.

I expected this lab to be a little easier for students than it turned out to be, but I think that several students who had been having trouble with some of the concepts (like the virtual ground) were now getting the idea.  I hope so, as most of what they did in this lab will be directly applicable to the EKG lab in the last week of classes.

2015 May 19

Pulse monitor lecture and lab

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

I didn’t get a blog post up for last Friday’s lecture, because I spent the weekend alternately socializing with my in-laws and grading. Monday night was spent grading and working on the next chapter of the book, and most of today (Tuesday) was spent working on the book.

Last Friday was the one day I talked about pulse monitors, photodiodes, phototransistors, and transimpedance amplifiers.  It was a rather packed lecture, but seemed to go all right.

Monday’s lecture started out OK, answering questions about the homework exercises the students were about to turn in, but then fell apart when I tried to cover real power and pulse-width modulation.  Both presentations seemed too vague to me—having neither mathematical rigor nor clear exposition.  The written presentation I wrote for the book is much better than the lecture, which is a bit unusual for me.  I think I need to start getting more sleep, if my presentations have deteriorated to that level.

The prelabs I graded Monday night indicated to me that many students can’t follow a long chain of computations for computing signal levels, even when the chain is broken down into single steps for them.  The problem was estimating how much photocurrent we would get from an LED shining through a finger, starting from the power into the LED, figuring out how much light that would produce, how much would be absorbed by hemoglobin, how much scattered, how much collected by the phototransistor, and how much photocurrent the transistor would produce.  Some students managed to get about 80% of the steps, but a lot got only parts of one step right.

Today’s lab (the first half of the optical pulse monitor lab) took too long, because the students wasted a lot of lab time trying to redo the prelab computations that they had messed up over the weekend, rather than moving on to measuring the photocurrent as I had asked in the lab.  Only a few of the groups got as far as I thought they should have in the first half of the lab: getting their transimpedance amplifiers working and showing a pulse-rate fluctuation. They’ll be set up for adding a high-pass filter and second gain stage on Thursday, and recording pulse waveforms to pass through the digital filter script I provided them.

I spent a long time in the lab today, since I promised the students a 5–7 p.m. lab time for make-up or redone labs. I ended up in the lab from before 10 a.m. to after 7:30 p.m., and I expect to do that every Tuesday and Thursday for the rest of the quarter (2 and a half more weeks). I spent the time when I wasn’t helping students working on revising the class-D power amp chapter of the book, so that I could release the new draft of the book to the class—they’ll have to start work on the design of the class-D amplifier before they have quite finished the pulse monitor, or they won’t have enough time—there is no class next Monday for answering questions.

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.

Next Page »

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 313 other followers

%d bloggers like this: