Gas station without pumps

2015 May 15

Blood pressure lab part 2

Filed under: Circuits course — gasstationwithoutpumps @ 11:36
Tags: , ,

I spent long hours in the lab yesterday (10 a.m.–6:30 p.m.), because students were not as far along as I had thought by the end of Tuesday. I stay in the lab until all the students are finished, even if that is a couple of hours past when the lab should end. A lot of students were still debugging their breadboarded instrumentation-amp circuits 2 hours into the lab session, when I had thought that they would be soldering after at most an hour more breadboarding.

Debugging on both the breadboards and the soldered boards took a lot of time, but the problems were pretty much the standard ones:

  • power not connected
  • wire missing
  • wire to wrong location
  • power supply hooked up backwards to one of the chips
  • bent pin on chip not making contact with breadboard

A couple of groups asked me for debugging help but did not have a drawn schematic to work from.  As I had said earlier in the quarter, I would not help them debug unless they had a schematic to work from.  (I think in both cases the problem was that they had connected up one wire incorrectly, but without a correct schematic to work from, there was no way that they could detect the error.)  Some students have been a bit sloppy about trying to work out of their heads rather than putting things down on paper, and this sloppiness is beginning to be a problem for them.  It has mainly been the weaker students who have been being this sloppy, so perhaps it has been more the case that they have been trying to work out of other people’s heads—copying bits and pieces from other students rather than working things out themselves and then implementing it.

I won’t be helping students debug unless they have shown some effort at making their designs debuggable (like having a clean schematic before they wire things up).

I’m not 100% sure, but I think that all but one group got a soldered instrumentation amplifier working and a blood-pressure measurement run done with it.  The one group that didn’t get that far did have a breadboarded amplifier working.

There were some students missing due to illness, so I’ll probably have to arrange some time next week for make-up lab times.  I’m not sure when that can be.

2015 May 14

Blood pressure lab

Despite fairly poor prelab homework turned in, the first half of the blood pressure lab went well.  After seeing how poorly students were doing on breaking down the problem into pieces (perhaps the main transferable engineering skill I’m trying to get them to develop), I ended up giving them more explicit instructions on the board at the beginning of lab:

  1. calculate sensor voltage difference for 100mmHg with 3.3v power
  2. measure sensor voltage difference for 100mmHg with 3.3v power (also 0mmHg and -100mmHg)
  3. determine upper and lower inputs of voltage for instrumentation amp INA126P from the data sheet, using worst-case rather than typical specs (“worst-case” meaning the smallest remaining voltage range)
  4. use Vout-Vref = G(V+ – V) to determine maximum gain to avoid clipping if input swing is +-180mmHg (+-24kPa)
  5. compute needed gain resistor, wire it up (and virtual ground)
  6. measure voltage at output of instrumentation amp at 0, +100mmHg, -100mmHg
  7. compute gain needed in second stage to get maximum range (without clipping) at final output
  8. wire up op amp and measure final output voltage at 0, +100mmHg, -100mmHg
  9. What is Vout as function of pressure?
  10. record with the PteroDAQ a blood pressure measurement with pressure slowly decaying from 180mmHg down to 40mmHg (not too slowly, or your hand will get swollen).  Check for clipping at high end.  Check that you are using nearly the full range. Check that pulsations are visible when plotting the data.
  11. Use bandpass-filter.py to filter the first channel of the recording (later channels will be discarded)

I may have to put some version of these instructions in the book, though this sort of hand-holding is precisely what I’m trying to cut out in the “descaffolding”.  I’m afraid we’re training a generation of technicians rather than engineers—they’re good at following very explicit instructions, but not so good at breaking problems down into smaller problems.

With these explicit instructions, most of the students managed to get breadboard versions of the pressure sensor amplifiers working. I may have to help out bench 4, as it turned out that their pressure sensor seems to have a 0.7mV offset (which is pretty big—way out of spec).  They’ll have to decide whether to change benches to get a different sensor, compensate for the sensor offset electronically, or compensate for it in the post-processing of the data.  Any of these solutions would be acceptable, but they aren’t all equally easy.

The students needed less help than in previous years in the lab, so I think that having the students struggle with the prelabs, even if they don’t get the answers right, is helping make the lab time more efficient—they only have to get past a couple of misunderstandings, rather than trying to learn all the material for the first time in lab, as so many did the last couple of years.

In lecture on Wednesday, I went over blood pressure waveforms defining pulse rate, systolic pressure, and diastolic pressure, and talking about the frequency ranges of the pulse rate. I then explained to them how the filter program was run (many students still don’t know about the “<” and “>” conventions for standard in and standard out on command lines). I also showed the gnuplot trick that allows using standard out from a program in place of a file in a plot command:
plot '< python bandpass-filter.py < pressure.data' using 1:3 with lines

I did not explain how digital filters worked, but I did say why I chose Bessel filters (to preserve as much of the time-domain structure of the signal as possible).  In response to a question I also explained the effect that choosing 5th order filters had (the rolloff as f5 or f–5, rather than f1 or f–1 as with a first-order RC filter). I also explained that the computation required more and more precise numbers as the order got higher, and that 5th-order was a good tradeoff between needed precision and fast rolloff.

One thing that I didn’t get to was explaining that “filtfilt” does the filtering twice: once with time going forward and again with time running backwards. The time reversal cancels a lot of the distortion in the time domain (so the choice of Bessel filters is not crucial), but doing two passes also doubles the order of the filter, so that the rolloff is really f10 or f–10.

I did remember to tell students that they needed to have the scipy package installed in order to run the filter program, and that if their python was installed from python.org that they could probably just run “pip install scipy”. At least one student in the class is using the Anaconda installation of python, which already has scipy installed.

At the end of the lecture I had only 10 minutes left, so I did not get into the internals of instrumentation amplifiers (needed for the EKG lab at the end of the quarter) nor transimpedance amplifiers (needed for next week’s lab). Instead I covered the voltmeter impedance measurements I made last week, explaining how I did the measurements, how I did the fitting, and what the results were.  In particular, I mentioned that swapping the sets of leads changed the behavior, so the extra capacitance (beyond the 100pF of the meter itself) appears to be coming from the leads.  I sent the data files and gnuplot script to them via e-mail, after one student requested them.

2015 May 11

Lecture on pressure sensors

Today’s lecture was fairly straightforward:

  • Feedback on the audio-amplifier design report
  • Explanation of RMS vs. amplitude vs. peak-to-peak voltage measurements
  • How pressure sensor works
  • Wheatstone bridge, developed from voltage divider, with second fixed voltage divider to subtract off effect of supply voltage changes

I had wanted to get to the internals of how an instrumentation amplifier is built (the 3-op-amp and 2-op-amp designs), but that can wait until Wednesday.  I also wanted to do a demo of the pressure sensor with digital filtering, but that can wait until Wednesday also (and I forgot to bring in my KL25Z board today anyway).  Discussions of systolic and diastolic blood pressure will need to be done on Wednesday also—I’ll start with that, then move to the demo and show how to measure pulse rate and estimate the blood pressures from the recording.

The main feedback I gave on the design reports consisted of the following points:

  • A lot of students are still invoking V=IR without thinking about what the variables mean—they have to be talking about the voltage across and current through the same resistor, not some other random voltage in the system.  For the design they just did, it was impossible to know the voltage across the resistor until the power supply voltage was chosen, but the voltage across the resistor was not the power-supply voltage!
  • Many students did not justify their design choice for the power supply.  There were constraints on it (from the op-amp data sheet), and they should have chosen a voltage near the upper end, because they wanted as loud an output as possible, and the current limits increased with power-supply voltage.  One or two sentences that said those two things would have sufficed.
  • RC time constants have units (called “seconds”).  I showed the students that ΩF is seconds, by using the definition of Ω as V/A, A as C/s, and F as C/V.
  • Voltage gain, on the other hand, is unitless, being a ratio of two voltages.  I also explained the convention of showing what the ratios are of, express  gain in “units” of V/V.
  • The gain for their audio amplifiers needed to be designed (based on the current limits at the outputs and the loudspeaker impedance, divided by the calculated or measured input voltage to the amplifier).  Too many students got a hint from the group tutor for the class (that turned out to be wrong) and took it as a specification, rather than doing their own design.
  • Many students did not report their loudspeaker impedance, but it was essential for computing the voltage at which the amplifier would clip, and different students had different loudspeakers (some 6Ω and some 8Ω).
  • Paralleling op amps doesn’t increase the gain, merely the current limit for the amplifier.  So clipping happens at a higher voltage, but the gain for small signals remains unchanged.
  • Several students had misdrawn the gain control circuit, using the two ends of potentiometer symbol as if it were a variable resistor. I showed them both the standard symbol for a variable resistor and how to draw the potentiometer used as a variable resistor correctly.
  • Lots of students had very approximate gain measurements, because they had relied exclusively on the oscilloscope for measuring voltages.  I explained why the oscilloscope is inherently less accurate for measuring voltage than a voltmeter.
  • I explained that “surround sound” and “stereo” require different signals to the multiple loudspeakers—multiple speakers wired to the same signal don’t produce the aural position illusion that stereo and multi-channel sound does.
  • One of my pet writing peeves is the mixing up of prepositions in “substitute x for y” and “replace y with x”.  Note that what replaces what swaps positions in the two phrases.  When students mix and match to get “substitute x with y” or “replace y for x” I don’t know whether the verb or the preposition is dominating the meaning.  (In some dialects of English one or both of these phrases may be unambiguous, but they don’t seem to be consistently used in California, so I treat them as errors, rather than as dialect variations.)
  • Students are still starting numbers with periods.  I’ve told them repeatedly not to—numbers shouldn’t start with punctuation (other than a + or – sign), and there should always be a digit in front of any decimal point.
  • The triangle used as a ground symbol should always point down.

2015 March 18

Freshman design projects moderately successful

I just finished grading this year’s freshman design projects. I think that the projects were more successful this year than last year, in part because I kept the students focussed on electronics and programming (for which they had lab access and which I could help them debug), and in part because the projects were somewhat less ambitious.

There were two groups doing EKGs and 4 groups doing blood pressure meters.  Both EKG groups managed to demonstrate their projects working, as did one of the blood-pressure groups.  (I’m being fairly generous here about what “working” means—they had to get their electronics to work, capture the data, and plot the waveforms, but further interpretation or software was not required.)  The other three blood pressure groups did not manage to demonstrate their projects, but one of them managed to plot waveforms for the pressure measurements (without getting their high-pass filter and amplifier working for the pulse measurements).

Some things I learned for next year:

  • Tell the students what op amp to get.  A number of students picked op amps that turned out to be rather old-fashioned ones with very low input impedance (as low as 2MΩ), rather limited output ranges, and external nulling circuits. The cheap MCP6002 or MCP6004 chips would have worked better at lower cost.  In fact, I gave one group that seemed to have a good schematic (but couldn’t get their circuit to work) an MCP6002 chip, which they wired in place of the op amp they had been using, and their circuit worked immediately.  I would have done the same for other groups, but the others with poorly chosen op amps were about a week behind and did not have circuits that were that close to being functional.
  • Warn students sooner not to use FedEx.  My son’s and my experience with FedEx this year has been that they are ludicrously slow. At least one group was burned by a ridiculously long delivery time, having ordered with FedEx delivery just hours before I warned the class about them.  (The US Post Office is faster and cheaper for lightweight electronics orders from Digi-Key.)
  • Students who never ask questions in class probably don’t understand much that is going on—all the groups that successfully demonstrated their projects had at least one active participant in class.
  • Students who fail to turn in their progress report are almost certainly not going to complete the project on time—I need to be more assertive in getting them moving and demanding that they show me their schematics.  Almost everyone had errors in their schematics on their first design (and one of the successful groups went through 4 incorrect designs before getting to one that worked).  Students that are afraid to show me incorrect or incomplete work don’t get the feedback they need to correct the problems—I need to normalize errors more and insist on seeing stuff, even if it is wrong.
  • The MXP5050DP pressure sensors are very easy for students to use, though a bit pricey at $16 each.  The built-in amplifier makes doing pressure measurements with an Arduino fairly trivial (hook up the three wires of the sensor to A0, +5V, and GND).  They were a good choice for the freshman design seminar, though I’ll continue to use MPX2053DP sensors without an integrated amplifier for the applied circuits class—that assignment is intended to get students to design with an instrumentation amp and to understand a bit about strain gauges.
  • Get the students to plot stuff earlier in the quarter. One group tried installing gnuplot on a Mac in the lab in the last few hours, which did not go well for them.  They did eventually find a plotting program that they could install and run, but then did not have time to run the data they collected through the filtering program I’d written for the class.  Their signals were pretty clean, though, and the plots they produced were good even with just the RC high-pass filter in their amplifier, without digital filtering.
  • The students seemed (for the most part) pretty excited about the projects—even those whose projects didn’t quite work seem to have gotten a lot out of the lab times.  I should look in a couple of years to see how many have stuck with engineering majors (I suspect that some might switch to computer science or computer engineering, rather than sticking with bioengineering, but that’s ok).

2014 June 26

Instrumentation amp from op amps still fails

Filed under: Circuits course — gasstationwithoutpumps @ 17:02
Tags: , , , ,

I’ve been trying to decide whether to have students build an instrumentation amp out of op amps in the circuits course.  Currently the INA126P instrumentation amp chip that I have them use is a black box to them, even though I include an explanation on the lab handout showing how it is internally a pair of op amps and 4 resistors:

Internally, the INS126P instrumentation amp is two op amps and 4 resistors.

Internally, the INS126P instrumentation amp is two op amps and 4 resistors.

I won’t repeat that presentation here (there’s a condensed, early version of it in a previous blog post).  I’ve not actually lectured on the 2-op-amp design before the instrumentation-amp lab, in class, though I did manage to talk about the 3-op-amp instrumentation amp this year (a waste of time, since they did not really process the ideas).

What I was interested in today was whether the pressure-sensor lab could be done entirely with op amps, rather than with the more expensive INA126P chip.

I decided to design an amplifier with a gain of around 200 and an output reference voltage around 0.5 v (based on a 3.3v supply), using the 2-op-amp design and MCP6004 op amps. Here is what I came up with:

This is the design I came up with and built.  It works, sort of.

This is the design I came up with and built. It works, sort of.

The amplifier amplifies and seems to have about the right gain, but there is a large DC offset on the output: about 0.24V, which translates to an input offset of about 1.2mV. I checked with a multimeter, and the negative-feedback voltages are indeed about that far apart, while the inputs from the pressure-sensor bridge are less than 40µV apart. The pressure sensor sensitivity is about 80µV/kPa/V, or 264µV/kPa with a 3.3V supply. If I use the pressure sensor with a blood-pressure cuff, I’ll want to go up to about 180mmHg or 24kPa, so the sensor output should be in the range 0–6.3mV. An offset of 1.2mV is huge!

If I remove Rgain from the circuit, the output offset drops to 20.88mV, which is 1.1mV referenced to the input (close to the 1.22mV measured at the negative feedback inputs).  Further removing R2 or R4 does not change the voltage difference between the negative-feedback inputs.  In fact removing all three of Rgain, R2, and R4, so that we have two unity-gain buffers (with 180kΩ and 10kΩ feedback resistors), still leaves the negative feedback points 1.22mV apart.  Each seems to be about 0.6mV from the corresponding positive input.

The problem is that the input offset voltage of the MCP6004 op amps is only guaranteed to be between –4.5mV and +4.5mV:  I’m lucky that the input offset voltage is under 1mV!  Even the INA126P instrumentation amps that we’ve been using have an input voltage offset of up to 250µV (150µV typical). One can obviously get better instrumentation amps, but the selection in through-hole parts is limited, and I’d have to go to an instrumentation amp costing $4.25  (LT1167CN8#PBF) instead of $2.68 to get the input offset voltage down to 20µV.

I’m going to have to rewrite the section of the book on instrumentation amps, to discuss (at least briefly) offset voltages.  I had originally thought that that the signals we were looking at were big enough that the offset voltages didn’t matter. For the INA126P, a 150µV offset would be about 0.6kPa, while the 1.22mV offset I was seeing in my homemade instrumentation amp would be about 4.6kPa.

I wonder also whether I can make an EKG circuit using this 2-op-amp instrumentation amp circuit.  The EKG already has to deal with potentially large input voltage offsets due to differing electrode-skin contacts.  In fact those offsets may be over100mV, far larger than the 1.2mV from the amplifier.  I’ll have to add another stage of amplification (after a high-pass filter), but that shouldn’t be a problem. I looked at this problem a year ago in 2-op-amp instrumentation amp and Common-mode noise in EKG, and concluded then that common-mode noise would be too large, but I’m tempted to try again, using the design here with gain 19 and a second stage with a gain of around 80 (for a combined gain around 1520), as last year I rejected the idea before actually building the circuit.

 

Next Page »

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

Follow

Get every new post delivered to your Inbox.

Join 320 other followers

%d bloggers like this: