Gas station without pumps

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 29

Soldered EKG from op amps

Filed under: Circuits course — gasstationwithoutpumps @ 20:34
Tags: , , , , , ,

Today I decided to solder the EKG design from Instrumentation amp from op amps fine for EKG onto one of my instrumentation amp protoboards, leaving out the instrumentation amp chip—I wanted to see how much trouble it would be.  As it turned out, the build was fairly straightforward, but a little tedious. There are only dedicated spaces for 8 resistors on the board, but there are 9 resistors in the design I used, so one had to go elsewhere on the board.  I deliberately left out the low-pass filter on this implementation (eliminating one capacitor), which did not make a huge difference—I ended up with about 58µV peak-to-peak of 60Hz noise on my input signal (compared to about 40µV in the previous design with a capacitor for low-pass filtering), which is fairly small compared to the 870µV R spike or the 220µV T wave.  The 60Hz interference was large enough to interfere with the P wave and make it difficult to see whether or not there was a U wave.  Of course, these measurements were made in my bedroom/lab, which has a lot less 60Hz interference than the lab the students work in.  I’ll have to take the board into work and see how bad the interference is in that space.

Using a digital filter to remove the 60Hz noise reduced the 60Hz interference to under 100nV peak-to-peak (way lower than other noise components), producing very nice waveforms, even when sampling at 360 Hz.  I’ll probably want to include a digital filter Python script in the book so that people can see the cleaned up signals, even if there isn’t room in the course to design digital filters.

I still have to decide whether to have students do the EKG amplifier without the INA126P chip, using only op amps. Wiring up the bigger circuit takes time, and I’m not sure that 6 hours of lab will be enough time for students to debug their design and get it soldered—it took them long enough to solder the EKG with the INA126P chip, which has fewer components and fewer wires to route.  It took me quite a while to solder up the board, so it would probably take the students far too long.  Is the pedagogic value of designing and building a 2-op-amp instrumentation amp worth the time? I do want the students to end up with an EKG to take home, as it is a tangible artifact that can demo the function of.  I’m thinking that I could even drop the soldering of the pressure-sensor amp (since they don’t take home pressure sensors), and add soldering of the microphone pre-amp.  If I do that, I’ll probably want to redesign the protoboard again, making it an op-amp protoboard with no instrumentation amp slot, but with more resistor spaces.

Cutting one part that costs about $2.70 and the $1.90 thermometer might justify my switching back to the resistor assortment I used in Winter 2013:  1120 piece resistor assortment for $17.39 instead of 1280 piece resistor assortment (currently $10.65) without raising the lab fee.  Why would I want fewer resistors at a higher price? The 1120-piece assortment is 10 each of 112 values, while the 1280-piece assortment is 20 each of 64 values.  Also the 64 values don’t seem to be very repeatable from set to set, and some sets has duplicates (so only 62 or 63 different values).  The 112-value sets seem more reliably useful.  A hobbyist might be better off going one step further to the 3700-piece resistor assortment (25 each of 148 values), but I can’t justify the $31.48 price for my class. (The extra $14 would probably raise the lab fee.)

 

2014 June 26

Instrumentation amp from op amps fine for EKG

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

As I mentioned in Instrumentation amp from op amps still fails, I’ve been trying to decide whether to have students build an instrumentation amp out of op amps in the circuits course.  I decided that it wouldn’t work for the pressure-sensor lab, because of the large DC offset.  One could calibrate each amplifier, either in software (by recording a a few seconds of 0 pressure difference, and subtracting a constant fit to that region from the data) or in hardware, but I’d rather they had a more straightforward experience where the DC offset was small enough to be ignored.

I conjectured that instrumentation amp built from discrete op amps would work ok for the EKG lab, though, as the EKG already has to deal with much larger input voltage offsets due to differing electrode-skin contact.  So I added a second stage  with a gain of 81 to the instrumentation amp in the previous post with a gain of 19, to get a combined gain of 1539.  I put in the high-pass filter needed to eliminate the DC offset, and a low-pass filter to reduce noise slightly (and make aliasing less of a problem).  The corner frequency is a bit high (60Hz noise is not going to be reduced much), but that may allow a better view of the fast R spike in the EKG waveform.

    The EKG circuit has four modules: a virtual ground (here set to 0.5v), an instrumentation amp, a high-pass filter to eliminate DC bias, and a second-stage non-inverting amplifier with some low-pass filtering.

The EKG circuit has four modules: a virtual ground (here set to 0.5v), an instrumentation amp, a high-pass filter to eliminate DC bias, and a second-stage non-inverting amplifier with some low-pass filtering.

The amplifier worked surprisingly well. I did sometimes have trouble with 60Hz noise, but it did not seem to be any worse than the amplifier based on the INA126P. I can remove the noise by digital filtering, though I’ve only played with that by post-processing the data files, not by designing a notch filter to run in realtime on the KL25Z (something to do when I have more time).

Here are a few traces made with EKG circuit above, feeding into the PTE20-PTE21 differential input on the KL25Z board, recorded using PteroDAQ.

This is lead I, without filtering, showing a rather disturbingly large 60Hz noise signal.

This is lead I (LA–RA), without filtering, showing a rather disturbingly large 60Hz noise signal.

This is lead I (LA-RA), showing how the digital filter cleans up the signal. This was Bessel bandpass filtered to 0.3Hz to 100Hz, followed by notch 57Hz–63Hz, followed by notch 117Hz–123Hz. Each filter was a 5th-order Bessel filter, applied first forward in time then backward in time (using scipy's filtfilt function).

This is lead I (LA–RA), showing how the digital filter cleans up the signal. This was Bessel bandpass filtered to 0.3Hz to 100Hz, followed by notch 57Hz–63Hz, followed by notch 117Hz–123Hz. Each filter was a 5th-order Bessel filter, applied first forward in time then backward in time (using scipy’s filtfilt function).

This is lead II (LL-RA), which for some reason had rather low noise even without filtering.

This is lead II (LL–RA), which for some reason had rather low noise even without filtering.

I noticed that sampling at 360Hz allowed me to see a bit more of the structure of the S and T complex than I’ve seen previously, particularly in lead II, and I can even make out a little bump of a U wave just after the T wave.

I now have to decide whether to have students do the EKG amplifier without an INA126P chip, using only op amps. The design will be fairly heavily constrained, as they’ll need to get it all working on a single MCP6004 chip, but it will justify my spending a bit more time on how instrumentation amps work.

I may redesign the blinky EKG to use a single MCP6004 chip also, which would reduce the price of that substantially.

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.

 

2014 May 14

Mixed topics in lecture

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

Today’s lecture was a mish-mash of different topics.

Pre-lab assignments not getting done.
I asked the students for advice on how to get them (or next year’s class) to do the pre-lab assignments before coming to lab, rather than wasting lab hours doing homework that doesn’t need the fancy lab equipment. I told them some ideas I had had, and how everything I’d tried so far had not worked. The only idea they thought might work was requiring that pre-lab assignments be turned in the day before the lab, so that they would prioritize the work. I’ll have to look to see if that is feasible for any of the labs left this year.
Answer getting
I talked again about the “answer-getting” mindset, and how it wasn’t an appropriate one for engineers. The problems they’ll face in industry are open-ended ones, where there isn’t a single unique answer—no one is going to be giving them multiple-choice tests. They’ll have to come up with designs, justify their design choices, and document them well enough that someone else can maintain things after they get hit by a beer truck.
Subdividing problems
I told them that I was deliberately giving them long multi-step design problems so that they could get used to subdividing problems and tackling them a little a time. I had noticed that some of them were stopping as soon as they got to a subproblem they didn’t know how to handle, rather than leaving a symbolic value for the result and solving the other subproblems. It is a lot easier to fill in one hole in a long computation than to have to do the whole thing from scratch each time.
Engineering by design or by tinkering
There are two different styles of engineering: one which uses careful modeling and calculation to try to get a design that works correctly first time, and one that consists of making quick reasonable guesses, trying them out, and adjusting the design to correct problems. I confessed that as a hobbyist, I generally prefer design by tinkering, but most modern electronics does not lend itself to tinkering, because the parts are too small for hand soldering, so one needs to go through a more expensive PC board design and pick-and-place assembly to build a prototype. I did, accidentally, tell them a lie—I said that the MCP6004 quad op-amp chip they are using is available in a 2mm by 3mm package, but that package is for the 8-pin MCP6002 dual op-amp chip, and the smallest for the MCP6004 is 4mm by 6.4mm (substantially larger than 2 MCP6002 chips!). This week’s lab was intended to be a compromise between the two design styles, with Tuesday being engineering by design for the first stage and today and Thursday being tinkering to correct the problems of the first stage, but only one group got to the point on Tuesday of having a partly functional design that could be tweaked.
Results from stage 1
I had a student whose group had gotten stage 1 working in lab yesterday talk about what he and his partner had seen on the scope. He mentioned the voltage going very high when there was no finger blocking the light (and we talked a bit about saturation, pointing out the similarity to the loudspeaker lab, where they observed clipping from either voltage or current saturation—I even managed to tie in the chemical concept of saturated solutions). He talked about how the voltage dropped to Vref+100mV with a finger blocking the light. He mentioned the large 60Hz noise on top of this DC signal, and the tiny voltage that may have been from the pulse. I gave the students some ballpark figures for the sorts of currents that they might see from their phototransistor (based on both what the first group saw and what I had seen at home): about 90–150nA DC and about 2–10nA for the pulse.
Gain of first stage
We talked about ways to increase the gain of the first stage and the desirability of making it as big as possible without saturating at the top rail. One subject that came up (in response to a student question) was increasing the headroom by dropping the reference voltage for the transimpedance amplifier. That brought up the other constraint on that voltage—biasing the phototransistor. The spec sheet gave a VCE saturation voltage of 0.8v, and I suggested that they stay above that voltage (though I suspect that the design might work down to 0.7v since their currents are so small—something I should probably experiment with).
Need for filtering
I asked the students how to get rid of the DC bias, and by this point they all know that a high-pass filter was needed. We then discussed what sort of frequency range a heart rate might be (several were pretty clueless about this), but we eventually got to 30bm–240pbm, or 0.5Hz to 4Hz. I suggested that they might want a wider bandwidth, particularly on high end, to see the shape of the pulse as well. I talked about the need for a low-pass filter to reduce the 60Hz signal.
Synchronous sampling
With a little too much prompting, I managed to get them to come up with the idea of sampling at 60Hz, so that the 60Hz noise would be sampled at the same point on the waveform on each cycle and so be less of a problem. I also showed them that 30Hz or 20Hz would work just as well.
Active filters
Finally we got to what I had intended as today’s topic: modifying the transimpedance amplifier to include a low-pass filter. I showed them the transimpedance amplifier circuit again, and reminded them that the feedback did not need to be a simple resistor but could be a complex impedance. We drew the Bode plot for the desired gain of the amplifier using a 1/f (6dB/octave) rolloff, and I asked them how to design a complex impedance with that magnitude. They fairly quickly came up with the idea of using a resistor and capacitor, but at first they wanted to put them in series. We computed what the plot for that would be, and they decided to try parallel instead. Success! But almost out of time for the day, without talking about multi-stage filters or putting complex impedance in both arms of a voltage divider in the feedback loop for a bandpass filter.
Gnuplot boilerplate
I did give them a quick look at the boilerplate gnuplot script I wrote for them, that allows them to create models and test them out quickly with gnuplot, but I did not have time to work through an extended example of modifying the script for more complicated circuits, and I doubt that any of them will take the trouble to try it on their own.

I did not get a chance to tell them about the pressure on the finger being optimally between the systolic and diastolic blood pressure, but there should be time in lab for that tomorrow. By grasping the edge of a table lightly and gradually increasing the grip force, one can slowly increase the pressure until the finger throbs with the pulse—that is the amount of pressure you want to put on the fingertip.

I expect that I’ll be in the lab quite late with the students tomorrow, getting them to build their stage 1, tweak the feedback resistor (and capacitor) until the circuit has reasonable gain, then design and build their second stage. I’m betting that no one will have thought about what they need for the second stage, and most still won’t have a schematic even for the first stage.

On Friday, I’ll introduce instrumentation amps and strain gauges, for next week’s instrumentation amp lab. Monday will have to be class D amplifier design concepts, because Wed will be the quiz, and there is no Monday the week after next (Memorial Day), so we’ll have to develop class-D block diagram on Friday next week.

Next Page »

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

Follow

Get every new post delivered to your Inbox.

Join 309 other followers

%d bloggers like this: