Gas station without pumps

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 2

Colorimeter design—weird behavior

In Colorimeter design—almost working, I talked about the prototype colorimeter made out of foamcore, and the non-linear behavior of its phototransistor circuit. I suggested some possible reasons for the non-linearity, and I tried experiments this weekend to try to remove the problems.

The first thing I did was to remake the dilution series, with one drop of blue food dye in 10ml of distilled water for the highest concentration, then twofold serial dilution to get 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, and 1/128, each in its own cuvette.

The next thing I did was to make a transimpedance amplifier (current-to-voltage converter), so that I could have a constant voltage across the phototransistor, even as the current changed. I also made it so that I could swap out the phototransistor and use a photodiode instead, to see if that gave me more linear behavior.

LED circuits and transimpedance amplifiers for phototransistor and photodiode. The phototransistor amplifier has a gain of 100kΩ, and the photodiode one a gain of 22.4MΩ.  Only the 627nm LED has been tested so far. Both are intended for differential (E20–E21) analog-to-digital conversion.

LED circuits and transimpedance amplifiers for phototransistor and photodiode. The phototransistor amplifier has a gain of 100kΩ, and the photodiode one a gain of 22.4MΩ. Only the 627nm LED has been tested so far.
Both are intended for differential (E20–E21) analog-to-digital conversion.

I have not yet managed to get full-scale range with the phototransistor—the 1/64 and 1/128 dilutions often come out having lower absorbance than the blank! I did manage to get some decent series with the photodiode:

I began and ended with a blank (distilled water only) cuvette.  The difference between the beginning and the ending values is fairly large (an absorbance of about 0.02), and probably reflects changes in alignment of the optical components, which are not very rigidly held by the foamcore.

I began and ended with a blank (distilled water only) cuvette. The difference between the beginning and the ending values is fairly large (an absorbance of about 0.02), and probably reflects changes in alignment of the optical components, which are not very rigidly held by the foamcore.

The high gain on the photodiode transimpedance amplifier causes another problem: 60Hz pickup from capacitive coupling. I get a 60Hz signal that is quite large compared to the DC signal I’m interested in. Adding a 0.022µF capacitor in parallel with the 5.9MΩ resistor got rid of most of the 60Hz noise (a corner frequency of about 1.2Hz). It may be better to use 0.01µF, for a corner frequency of 2.7Hz—that seems to work fairly well also, and may give a bit better time-domain response to changing absorbance.

My first calculation of the desired capacitor size was way off (what I get for doing it in my head instead of with a calculator).  Using only a 100pF capacitor did not reduce the 60Hz noise.

My first calculation of the desired capacitor size was way off (what I get for doing it in my head instead of with a calculator). Using only a 100pF capacitor did not reduce the 60Hz noise.

Adding a 0.022µF capacitor in parallel with the 5.6MΩ resistor did clean up the 60Hz noise.

Adding a 0.022µF capacitor in parallel with the 5.6MΩ resistor did clean up the 60Hz noise.

The values from three runs (no capacitor, 100pF, and 0.022µF) were monotonic (except for one or two measurements of 1/64 and 1/128), fairly consistent, and substantially larger than the error in the re-reading of the blank cuvette, so I tried plotting them against the relative concentration:

 Three different sets of measurements with the photodiode colorimeter. Ideally , the measured absorbance should be linear with the concentration, but I am getting a relationship that looks more like the square root of concentration!

Three different sets of measurements with the photodiode colorimeter. Ideally , the measured absorbance should be linear with the concentration, but I am getting a relationship that looks more like the square root of concentration!

I’ve been getting pretty frustrated with this design, as I have no idea where the non-linearity is coming from.  I’ve checked that both Beer’s Law and the current from a photodiode refer to the same measure of light intensity (W/cm2).

The non-repeatability of the measurements (which is probably due to changes in the light path from movement of the LED and photodiode) also limits the usefulness of this colorimeter.  If I could figure out was going wrong with the light measurement and conversion to absorbance, I could probably fix the changing light path by making a new holder out of sturdier materials—drilling 3mm holes in wood or aluminum is pretty simple.

I did try to do some debugging—the problem is not in the Freedom board or the software, as the voltages reported by the Freedom board are consistent with ones measured with a multimeter, and calculating absorbance from the multimeter measurements gives me the same numbers as the program on the Freedom board (within measurement errors).  The dilution series looks good—if I stack cuvettes,  1/2+1/4+1/8 is almost as dark as 1/1 (and similarly for other combinations).  That leaves only my understanding of how photodiode currents are generated and how transimpedance amplifiers convert current to voltage as potential failures (unless I’m missing something obvious).

2014 February 11

Ninth day of freshman design seminar

Filed under: freshman design seminar — gasstationwithoutpumps @ 17:10
Tags: , , , , ,

The astute reader of this blog may notice that there was no “eighth day of freshman design seminar” post.  I was sick last Wednesday and unable to attend class, so I had the group tutor (a senior in bioengineering) take the class and have them discuss possible projects to take on.  I asked them to turn in proposals yesterday, but forgot to collect them—I’ll collect them tomorrow.  We’re about halfway through the course, so it is time for students to start on their projects.

I returned two homeworks yesterday: the colorimeter design and the RGB LED resistor sizing.

The colorimeter designs were not very good, lacking necessary details, but were somewhat better than previous spectrometer attempts. I think I’ll try reversing the order of those assignments in future, as the colorimeter is a simpler device. The biggest problem with the designs is that most of them were pieced together from web pages, with no citations.  Two of them were blatantly copied from Science Buddies, which has a decent design, but the students did not cite the source. I yelled “Cite your sources!” at the class, and explained that I could have flunked several of them out for plagiarism, and that in an upper-division course I would have. I hope they get the message, so that they don’t fail out later on. I decided not to prosecute academic integrity cases in this 2-unit, optional course, though I am making the science-buddy copyists redo the assignment.

I then explained to students the mistake I had made in the photodiode explanations (see Lying to my students) and corrected the understanding of the “open-circuit voltage” spec from the photodiode datasheets. I think that the students are a little more comfortable about finding things on datasheets now—I hope that lasts for them.

We then went over one of the RGB LED datasheets and did the resistor sizing for it.  About a third of the class had done a decent job on that assignment, and I cleared up the common mistakes:

  • If a battery is used in a schematic, both ends need to be connected.  Other options are to use +5v and Gnd port symbols, or a +5V DC voltage source symbol.
  • The LED diode must be forward biased (with a large current flow), and the triangular shape of the diode symbol shows which way conventional current flows.
  • The voltage needed for determining the resistance is the voltage across the resistor, not the voltage across the diode, so it is 5v–VF, not VF.

I think I managed to get these points across—I relied fairly heavily on asking the students to do each step, so I’m pretty sure that at least half the class can now size a resistor for an LED.

Finally we could get to some new material. I wanted to show them how to program an Arduino, so we built up the standard blinking-LED first example for an Arduino.  To make it a little more interesting, I started with a true statement—I did not know whether the LED on pin 13 was hooked up with the anode or the cathode connected to pin 13.  We looked at the two possible circuits and how they would behave differently when the pin was high and when it was low.  I then explained “void setup()”, “void loop()”, and “pinMode(13,OUTPUT);”.  I had the students come up with the body of loop, feeding them the important constructs (digitalWrite and delay) only once they had expressed the action they wanted.  We ended up with a loop that help pin 13 high for a second and low for ¼ second.  After I typed in the program we had written, I showed them how to select the appropriate board type and download it to the Arduino.  The light blinked, and the students were able to figure out from the pattern of on and off that the LED was connected between pin 13 and GND (with a series resistor), with the anode towards pin 13.

I ran out of time and material at about the same time (a first for this quarter), and assigned the students to read about Arduino programming from the Arduino reference website, with particular attention to “if”, “while”, “pinMode”, “digitalWrite”, “digitalRead”, “analogRead”, and the timer functions.  I expect to go over some analogRead stuff in class tomorrow, and assign a small programming assignment over the weekend, probably using “Serial”.

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, …).

2014 February 3

Seventh day of freshman design seminar

Today we continued looking at photodiodes, phototransistors, and LEDs, in the context of the colorimeter I had asked them to design.  I think that next year I may go to the colorimeter first, and then to the more complex photospectrometer.  Since the students weren’t familiar with spectrometry, starting with it was of no help, and all the other concepts (absorbance, irradiance, linearity of phototransistors, …) are more than enough to start with.

I started the class by collecting the work I had asked them to do on fleshing out the design of the colorimeter, which I have not read yet. I’ll have to grade their colorimeter designs before Wednesday, but I hope we can start learning some Arduino programming by then (probably just setup, loop, analogRead, Serial.print, and delay), rather than going over the homework.

After reading what they turned in for photospectrometer and photodiode assignment, I’m not setting my expectations very high for the colorimeters.  I think (hope?) that the students are getting something out of the class, if not quite as quickly as I would like. I guess it takes some time for them to turn around habits of a lifetime and start generating new answers and new questions to answer, rather than just coughing back what the teacher said.

I wanted to get to Arduino programming today, but we didn’t get that far. I started with going over the homework, which was to find the resistor values for the following circuit:

Simple circuits for measuring light with an Arduino.

Simple circuits for measuring light with an Arduino. Update 2014 Feb 6: Q1 is intended to be an NPN phototransistor, not PNP as shown here!

  • For Monday, 2014 Jan 27, as individuals (not groups), find a data sheet for the phototransistor WP3DP3BT. Also, select a cheap photodiode that is available in the same size and shape of package as the WP3DP3BT phototransistor and look up its data sheet.For the photodiode and the phototransistor, report the dark current, the voltage drop across the device (that would be collector-emitter saturation voltage for a phototransistor and the open-circuit voltage for a photodiode), and the sensitivity (current at 1mW/cm2 at λ=940nm, which is the wavelength where silicon photodiodes and phototransistors are most sensitive).Find a plot of the spectral sensitivity of a silicon photodiode or phototransistor (it need not be from the data sheets you found—all the silicon photodiodes and phototransistors have similar properties, unless the packaging they are in filters the light).

    We want to make a circuit so that the full-scale (5v) reading on the Arduino corresponds to an irradiance of 204.8μW/cm2 at 940nm, so that each of the 1024 steps corresponds to an increment of 0.2μW/cm2. Remember that 1000μW=1mW. (We may not be able to use the full range, as the circuit should saturate at a somewhat lower value, depending on the saturation voltage or open-circuit voltage of the photodetector.)

    For the circuits above, figure out what values of R1 and R2 to use to get the desired voltage range at A1 or A2. Look up what standard resistance values are available with 2% tolerance, and pick the nearest one. (Hint: Google is your friend for finding tables of information.)

    In class on Monday, we’ll try building this circuit and seeing how it works with the Arduino Data Logger.

  • By Wed 2014 Jan 29, redo the homework originally due on Monday, and turn it in on paper, typed, with the questions echoed and answered in full sentences. If you have any questions, discuss them on the class e-mail list. (I don’t want “I don’t know” to come up for the first time in class—you should have been asking for help over the weekend!)

The first thing I did in class was to go over that homework, giving them useful advice for adapting to college courses:

  • No one computed R2 correctly. It didn’t bother me (much) that no one knew how to do it, but it did bother me that no one asked for help. I tried to impress on them that asking for explanation is not a sign of weakness, and that it should not be their goal to hide from view when they are confused about something. I don’t know whether this rant got through to them, but maybe if they hear it enough they’ll start asking questions in class or on the e-mail list.
  • Only one person cited a source for the plot of spectral sensitivity for silicon photodiodes, and that more by accident than by design (the URL was printed by the browser). I explained the notion of plagiarism to them, how it was the most serious of academic sins, and how other engineering faculty (and me in other courses) might fail them for the course if they continued to claim other people’s work as their own (which is what an uncited figure is).
  • I told them that they had to get very comfortable with the metric prefixes (only femto, pico, nano, micro, milli, kilo, mega, giga—they mostly won’t have much use for the smaller and larger ones) and their single-letter abbreviations.  This is clearly something they need to work on, as one of the common problems in the homework was off-by-a-factor-of-1000 errors, as students changed µW to mW without scaling the numbers.
  • I also impressed on them the importance of typing part numbers accurately—several had mistyped the part numbers for the photodiode they were specifying, and it took me a little detective work to figure out what they had really meant.  Some had not provided part numbers at all, and I could not check whether their numbers were right (those students still got the computations wrong).
  • Only three students found photodiodes that matched the specs: “a cheap photodiode that is available in the same size and shape of package as the WP3DP3BT phototransistor ” and that was sensitive to visible light.  That meant finding a 3mm diameter, through-hole package.
  • Several students found photodiodes in black packages that block visible light, which was not useful for this application.  I explained why such parts exist (listening to IR emitters like in remote controls, without being swamped by ordinary light).
  • Many students, having found photodiodes, could not accurately specify the sensitivity of the photodiode.  Most just reported a current, without specifying the irradiance that caused that current. We went over the notion of linearity and that what we were interested in was the slope of the line, and that units were µA/(mW/cm^2). I mentioned that some spec sheets specified responsivity in A/W, but that had to be divided by the sensor area to get the more useful unit. I then had them compute the current at the specified maximum irradiance and the resistance that would be needed to get that current with 5v across the resistor.  It took them a very long time (algebra skills are much lower than I would have expected for college freshmen—I have more sympathy now for the teachers of freshman physics), but they did eventually get the right answers for both the current and the resistance.
  • I spent a fair amount of time letting students know that units were their friends, and that they should carry the units throughout the computation.  I don’t know if the message got through, but I hope for their sakes that it will eventually.

Finally we could get to some new material. I asked them about monochromatic light sources for the colorimeter.  Some thought of LEDs, but one student mentioned that he had seen incandescent bulbs as much cheaper than LEDs. It took me a second to figure out where this confusion came from—at the power levels used for room lighting, incandescents are indeed cheap and LEDs expensive.  But we don’t need 5–20W of power—we’re not trying to cook what is in the cuvette.  I pointed out that the maximum light level expected for the phototransistor was only 20mW/cm^2, so we needed only mW of power from the light, and at that light level, LEDs were much cheaper than incandescent bulbs.

I showed them the data sheet for a red LED,  and explained some of the concepts. One concept was the difference between peak and dominant wavelength—the peak is where the light has the highest intensity, and the dominant is where it shifts to when multiplied by human visual sensitivity.  I also explained what the “spectral line half bandwidth” was, though I did not go into the difference between half amplitude and half power—it was not important at the moment.

I then went over the symbol for a diode, how I remember that electrons move from the cathode to the anode (bring up vacuum tubes and cathode rays), and showing them a rough sketch of a diode current-vs-voltage curve.  I showed them where various parameters were on the data sheet, though the particular LED data sheet I was using did not include the threshold voltage, just the forward voltage at high current.

The students brought up the notion of having multiple LEDs to get multiple colors, so I introduced them to  RGB LEDs, showing both the common-anode and common-cathode circuits. They figured out, with a lot of prompting, which way round power had to be connected (the mnemonic device I used was that producing light required power, and power is voltage times current, so there had to be current flowing through the diode).

It doesn’t help that photodiodes are used backwards—the photodiode is reverse biased, and current flows only when light produces electron-hole pairs at the back-biased junction.  I carefully did not talk about that while we were looking at the LEDs, as I’m sure it would have confused them.

By this point we were almost out of time, so I assigned a homework:

For Wed 2014 Feb 5, find a through-hole (not surface mount) RGB LED that is common-cathode, and design a circuit to power it from a +5V power supply. Make each color be as bright as possible without exceeding maximum current (you can leave a safety margin of up to 25%). Explain your design and how you sized the resistors for it.

I recommend using Digi-key’s search feature (looking for RGB LED) to see what parameters are usually most important to designers. I recommend using Digi-key’s free web tool SchemeIt for drawing a circuit diagram. They don’t have an RGB LED symbol, but you can make one out of 3 LED symbols (I’d use variant 1 for that).

Bonus: find an RGB LED that is common-anode, and do the same design exercise with it. (If Digi-Key’s search doesn’t turn up a part, try using Google.)

I did show them the prototype colorimeter I made over the weekend out of black foamcore, but did not have time to demo it. I was also going to demonstrate the use of vernier calipers to measure the cuvettes, but again ran out of time.  I’ll probably do a blog post about my first colorimeter prototype later this week, but I’ll need to get to bed early tonight, as I’m grading an elementary school science fair early tomorrow, and I’ve got a bad cold that is leaving me exhausted.  (I’ll have another science fair to judge Thursday morning, so this is not a good week for me to have a cold.)

Next Page »