# Gas station without pumps

## 2013 July 31

### Microphone sensitivity exercise

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

I’ve been thinking a bit about improving the microphone lab for the Applied Circuits course.  Last year, I had the students measure DC current vs. voltage for an electret microphone and then look at the microphone outputs on the oscilloscope (see Mic modeling lab rethought).  I still want to do those parts, but I’d like to add some more reading of the datasheet, so that students have a better understanding of how they will compute gain later in the quarter.

The idea for the change in this lab occurred to me after discussing the loudness detector that my son wanted for his summer engineering project.  He needed to determine what gain to use to connect a silicon MEMS microphone (SPQ2410HR5H-PD) to an analog input pin of a KL25 chip.  He wanted to use the full 16-bit range of the A-to-D, without much clipping at the highest sound levels. Each bit provides an extra 6.021dB of range, so the 16-bit ADC should have a 96.3dB dynamic range.  The sound levels he is interested in are about 24dB to 120dB, so the gain needs to be set so that a 120dB sound pressure level corresponds to a full-scale signal.

He is running a 3.3v board, so his full-scale is 3.3v peak-to-peak, or 1.17v RMS (for a sine wave).  That conversion relies on understanding the difference between RMS voltage and amplitude of a sine wave, and between amplitude and peak-to-peak voltage. The full-scale voltage is 20 log10(1.17), or about 1.3dB(V).

Microphone sensitivity is usually specified in dB (V/Pa), which is 20 log10 (RMS voltage) with a 1 pascal RMS pressure wave (usually at 1kHz).  The microphone he plans to use is specified at –42±3dB (V/Pa), which is fairly typical of both silicon MEMS and electret microphones.The conversion between sound pressure levels and pascals is fairly simple: at 1kHz a 1Pa RMS pressure wave is a sound pressure level of about 94dB.

Scaling amplitude is equivalent to adding in the logarithmic scale of decibels, so for a sound pressure level of 120dB, the microphone output would be about 120–94–42±3=–16±3dB(V), but we want 1.3dB, so we need a gain of about 17.3dB, which would be about 7.4×. Using 10× (20dB gain) would limit his top sound pressure level to 117dB, and using 5× would allow him to go to 123dB.

One can do similar analysis to figure out how big a signal to expect at ordinary conversational sound pressure levels (around 60dB):  60–94–42=–76db(V).  That corresponds to about a 160µV RMS or 450µV peak-to-peak signal.

I tried checking this with my electret mic, which is spec’ed at –44±2dB, so I should expect 60–94–44±2=–78±2dB, or 125µV RMS and 350µV peak-to-peak. Note that the spec sheet measures the sensitivity with a 2.2kΩ load and 3v power supply, but we can increase the sensitivity by increasing the load resistance.  I’m seeing about a 1mV signal on my scope, so (given that I’m not measuring the loudness of my voice), that seems about right.

I’ll have to have students read about sound pressure level, loudness, and decibels for them to be able to understand how to read the spec sheet, so these calculations should be put between the microphone lab and the first amplifier lab.  I’ll have them measure peak-to-peak amplitude for speech, and we’ll compare it (after the lab) with the spec sheet.  This could be introduced as part of a bigger lesson on reading spec sheets—particularly how reading and understanding specs can save a lot of empirical testing.

## 2013 July 10

### FFT on ATMega and BitScope

Yesterday, my son was thinking of adding a microphone to the design he is working on, and was considering adding a fast Fourier transform (FFT) to detect pitch.

He spent a few hours after his 10 a.m.–5 p.m. theater class reading about the FFT algorithm. He found an implementation of the FFT for an Arduino, which he tried reading along with the FFT explanations he found on the web.  I’m actually surprised the the Arduino was capable of doing an FFT, given the slowness of the processor.  It is true that the example code only does a 64-sample FFT with a sampling rate of 1kHz, using 8-bit samples and 16-bit integer arithmetic, but it is reported to do it at better than 10 FFTs per second.

I also pointed him to the Discrete Cosine Transform (DCT), which has somewhat smaller boundary artifacts, and can be computed about twice as fast, but he hasn’t had time to read that yet.  Somewhat surprisingly the DCT article in Wikipedia much better written than the general one on Fourier Transforms, which uses awkward notation and a rather dry, formal factoid dump.

I wanted to show him that FFT did not make pitch extraction trivial (at least not in real musical contexts), so I wired up a microphone and amplifier to my BitScope Pocket Analyzer and we turned on some Internet radio (our local public radio station, KUSP).  The complex mass of rapidly shifting peaks in the FFT made it clear that tracking a pitch would not be easy.  (I think that there are some useful pitch-extraction algorithms that are based on FFT, but they are not trivial.) I think I convinced him that he is better off trying to extract loudness than pitch, if he wants a useful control parameter for his device.

Incidentally, he spent some time yesterday looking for cheap electret microphones. There are quite a few on the market, but many of them say “hand solder only” on the datasheets—even some of the ones with just solder pads! There are mics that can be reflow soldered, but finding prices for them in the 100s is difficult—they mostly seem to be quotes from the manufacturers only. One promising one is the SiSonic SPQ2410HR5H-PD, which is only  3.76mm by 2.24mm and uses a ball grid array (it costs 92¢ in 100s, substantially more than 57¢ for the cheapest through-hole mic (though that needs to be hand soldered). CORRECTION 2013 July 10—that’s a MEMS silicon mic, not an electret.

We looked at digital mics that do the A-to-D conversion already, but the only one with a useful output format was the ADMP441, which costs $4.52 in 100s (way too expensive). The cheaper (down to about$1.02) digital mics all use PDM (pulse-density modulation), but to get that into a usable form inside the ATMega, he’d have to low-pass filter it and pass it through the A/D converter. Still, that may not be any more expensive than an analog mic, DC-blocking high-pass filter, and amplifier, though using a separate amplifier would let him design for the proper microphone sensitivity.  He’s going to have to figure out whether the board area and parts cost are worth the extra functionality of the microphone.  If the board area is not a problem, he could design the mic in, but then have the devices only partially populated to save parts costs, if necessary.

We also noticed that we could tell the bandwidth of the radio station we were listening to, because there was a very clear drop in the spectrum at 10kHz.  I tried capturing that this afternoon, but the station we listened to had a talk program rather than a music program, and I never captured a moment when they were using the full bandwidth.  I tried a different Internet music source, and got the following plot, which seemed to indicate a 12kHz bandwidth, but that may have been limited by the music recording they were playing, rather than the codec used for transmission over the internet.

Snapshot of FFT showing a bandwidth of about 12kHz. The grid for the spectrum is 10dB per division vertically and 6kHz per division horizontally.

Before we’d played with sound input, we’d looked at sine waves generated by the BitScope, by connecting a wire from the GEN output to the CHA input. I don’t think I was able to explain to him why the windowing function used for removing boundary artifacts in the FFT results in spreading the single-frequency spikes into wider peaks. It was too late at night to go into the theory of transforms and how multiplication in the time domain turns into convolution in the frequency domain, and vice versa. For that matter, he hasn’t even had convolution yet, so some of the fundamentals needed for the explanation were missing.

At one point I thought that the FFT on the Bitscope was a crude rectangular window, but I was informed by the Bitscope people that they use a Kaiser window. I should have been able to tell that they were doing some sort of windowing by seeing the spread of the spikes for sine waves, but I wouldn’t have been able to guess which window. (It may be buried in the documentation somewhere.) Actually, now that I look at the spikes, they seem too wide for a Kaiser window, unless they set the α parameter much too large.  They only need the sidelobes to be about 60dB down, which should be a much narrower main lobe—not the 18-bin width I think I’m seeing. Perhaps there is something else spreading the peaks, not just the Kaiser window.

Sine wave and FFT analysis of it (Click on image for larger, clearer picture). Note the harmonic distortion (2nd, 3rd, and 4th harmonic at about –40dB, –45dB, and —53dB).
Good luck figuring out the settings of the Bitscope from the information they show on the display!  TB is the time per division on the x-axis of the plot, while BW=120kHz is the full width of the spectrum (so 12kHz per division), and the sine wave is at about 3kHz.

It is interesting to look a a sine wave that is an exact submultiple of the sampling frequency:

Here is a 2975Hz sine wave, where each period should be 8 samples long. Note the appearance of side bands to either side of the main peak. These artifacts are much smaller if we move to a frequency that does not fit so neatly into the FFT buffer.
Note that the time base is different for this screenshot (20ms/division).

We also looked at the spectra of triangle waves and square waves (since the BitScope waveform generator can do those also). Playing with the duty cycle was fun also. I had not been aware that a duty cycle of 1/n on a square wave or triangle wave suppressed the nth, 2nth, 3nth, … harmonics. I had known that a 50% duty cycle square wave or triangle wave suppressed the even harmonics, but I had never thought about other duty cycles.

Triangle wave with 25% duty cycle, showing suppression of the 4th, 8th, 12th, and 16th harmonics.

## 2013 April 10

### Supplemental sheets, draft 3

This post updates and replaces the Supplemental sheets, draft 2. It reflects the redesign of the course based on running a prototype version of the course in as a group tutorial in Winter 2013.

### Lecture Course

Information to accompany Request for Course Approval
Course #:
101
Catalog Title: Applied Circuits for Bioengineers

1. Are you proposing a revision to an existing course? If so give the name, number, and GE designations (if applicable) currently held.

This is not a revision to any existing course.A prototype version of the course was run as BME 194 Group Tutorial in Winter 2013. Notes on the design and daily running of that prototype can be found at https://gasstationwithoutpumps.wordpress.com/circuits-course-table-of-contents

2. In concrete, substantive terms explain how the course will proceed. List the major topics to be covered, preferably by week.

The Applied Circuits course is centered around the labs in the accompanying lab course.  Concepts are taught as needed for the labs, with design and analysis exercises in the lecture course cementing the understanding. The recurring theme throughout the course is voltage dividers: for change of voltage, for current-to-voltage conversion, for high-pass and low-pass RC filters, in Wheatstone bridges, and as feedback circuits in op amp circuits.  The intent of this course is to provide substantial design experience for bioengineering students early in their studies, and to serve both as as bridge course to entice students into the bioelectronics concentration and as a terminal electronics course for those students focussing on other areas.

1. Basic DC circuit concept review: voltage current, resistance, Kirchhoff’s Laws, Ohm’s Law, voltage divider, notion of a transducer.
The first week should cover all the concepts needed to do the thermistor lab successfully.
2. Models of thermistor resistance as a function of temperature. Voltage and current sources, AC vs DC, DC blocking by capacitors, RC time constant, complex numbers, sine waves, RMS voltage, phasors. The second week should cover all the concepts needed to do the electret microphone lab successfully.
3. Low-pass and high-pass RC filters as voltage dividers, Bode plots. Concepts necessary for properly understanding digitized signals: quantized time, quantized voltage, sampling frequency, Nyquist frequency, aliasing.
4. Amplifier basics: op amps, AC coupling, gain computation, DC bias for single-power-supply offsets, bias source with unity-gain amplifier.  In the lab, students will design, build, and test a low-gain amplifier (around 5–10 V/V) for audio signals from an electret microphone. We’ll also include a simple current-amplifier model of a bipolar transistor, so that they can increase the current capability of their amplfier.
5. Op amps with feedback that has complex impedance (frequency-dependent feedback), RC time constants, parallel capacitors, hysteresis, square-wave oscillator using Schmitt triggers, capacitance-output sensors, capacitance-to-frequency conversion.   Topics are selected to support students designing a capacitive touch sensor in the accompanying lab.
6. Phototransistors and FETs for the tinkering lab and for the class-D amplifier lab. In preparation for the lab in which students model a pair of electrodes as R+(C||R), we will need a variety of both electronics and electrochemistry concepts: variation of parameters with frequency, impedance of capacitors, magnitude of impedance, series and parallel circuits, limitations of R+(C||R) model, and at least a vague understanding of half-cell potentials for the electrode reactions: Ag → Ag+ + e-, Ag+ + Cl- → AgCl, Fe + 2 Cl-→ FeCl2 + 2 e-.
7. Differential signals, twisted-pair wiring to reduce noise, strain gauge bridges, instrumentation amplifier, DC coupling, multi-stage amplifiers.
Topics are selected to support the design of a 2-stage amplifier for a piezoresistive pressure sensor in the lab.
8. System design, comparators, more on FETs. Students will design a class-D power amplifier to implement in the lab.
9. A little electrophysiology: action potentials, electromyograms, electrocardiograms. Topics are chosen so that students can design a simple 3-wire electrocardiogram (EKG) in the lab.There will also be a bit more development of simple (single-pole) filters.
10. The last week will be review and special topics requested by the students.

3. Systemwide Senate Regulation 760 specifies that 1 academic credit corresponds to 3 hours of work per week for the student in a 10-week quarter. Please briefly explain how the course will lead to sufficient work with reference to e.g., lectures, sections, amount of homework, field trips, etc. [Please note that if significant changes are proposed to the format of the course after its initial approval, you will need to submit new course approval paperwork to answer this question in light of the new course format.]

The combination of BME101 and BME101L is 7 units (21 hours per week).  The time will be spent approximately as follows:

• 3.5 hours lecture/discussion
• 3.5 hours reading background and circuits text
• 3 hours read lab handouts and doing pre-lab design activities
• 6 hours lab
• 5 hours writing design reports for lab

4. Include a complete reading list or its equivalent in other media.

No existing book covers all the material.  For the prototype run of the course, we relied heavily on Wikipedia articles, which turned out to be too dense for many of the students.  Other alternatives (such as Op amps for everyone by Ron Mancini http://www.e-booksdirectory.com/details.php?ebook=1469 Chapters 1–6 and Op Amp Applications Handbook by Analog Devices http://www.analog.com/library/analogDialogue/archives/39-05/op_amp_applications_handbook.html Sections 1-1 and 1-4) were also much too advanced.

In future we will most likely use the free on-line text All about Circuits as the primary text, with material not covered there (such as the various sensors) coming mainly from Wikipedia and the datasheets for the components.

5. State the basis on which evaluation of individual students’ achievements in this course will be made by the instructor (e.g., class participation, examinations, papers, projects).

Students will be evaluated primarily on design reports with some in-class or take-home quizzes to ensure that they do the needed reading on theoretical concepts.

6. List other UCSC courses covering similar material, if known.

EE 101 covers some of the same circuit material, but without the focus on sensors and without instrumentation amps.  It covers linear circuit theory in much more depth and focuses on mathematical analysis of complicated linear circuits, rather than on design with simple circuits.  The expectation for bioengineering students is that those in the bioelectronics track would take BME 101 before taking EE101, and that those in other tracks would take BME 101 as a terminal electronics course providing substantial engineering design.  The extra material in BME 101 would prepare the bioengineering students better for EE 101.

Physics 160 offers a similar level of practical electronics, but focuses on physics applications, rather than on bioengineering applications, and is only offered in alternate years.

7. List expected resource requirements including course support and specialized facilities or equipment for divisional review. (This information must also be reported to the scheduling office each quarter the course is offered.)

The lecture part of the course needs no special equipment—a standard media-equipped classroom with a whiteboard, screen, and data projector should suffice. Having a portable laptop-connected oscilloscope would make demos much easier to do, but is not essential.

The lecture course is not really separable from the associated lab course,whose equipment needs are described on the supplemental sheet for that course.

The course requires a faculty member (simultaneously teaching the co-requisite Applied Circuits lab course) and a teaching assistant or undergraduate group tutor for discussion sections and assistance in grading.  The same TA/group tutor should be used for both the lecture and the lab courses.

8. If applicable, justify any pre-requisites or enrollment restrictions proposed for this course. For pre-requisites sponsored by other departments/programs, please provide evidence of consultation.

Students will be required to have single-variable calculus and a physics electricity and magnetism course. Both are standard prerequisites for any circuits course. Although DC circuits can be analyzed without calculus, differentiation and integration are fundamental to AC analysis. Students should have already been introduced to the ideas of capacitors and inductors and to serial and parallel circuits.

The prerequisite courses are already required courses for biology majors and bioengineering majors, so no additional impact on the courses is expected.

9. Proposals for new or revised Disciplinary Communication courses will be considered within the context of the approved DC plan for the relevant major(s). If applicable, please complete and submit the new proposal form (http://reg.ucsc.edu/forms/DC_statement_form.doc or http://reg.ucsc.edu/forms/DC_statement_form.pdf) or the revisions to approved plans form (http://reg.ucsc.edu/forms/DC_approval_revision.doc or http://reg.ucsc.edu/forms/DC_approval_revision.pdf).

This course is not expected to contribute to any major’s disciplinary communication requirement, though students will get extensive writing practice in the design reports (writing between 50 and 100 pages during the quarter).

10. If you are requesting a GE designation for the proposed course, please justify your request making reference to the attached guidelines.

No General Education code is proposed for this course, as all relevant codes will have already been satisfied by the prerequisites.

11. If this is a new course and you requesting a new GE, do you think an old GE designation(s) is also appropriate? (CEP would like to maintain as many old GE offerings as is possible for the time being.)

No General Education code is proposed for this course, as all relevant codes (old or new) will have already been satisfied by the prerequisites.

### Lab course

Information to accompany Request for Course Approval
Course #
101L
Catalog Title
Applied Circuits Lab

1. Are you proposing a revision to an existing course? If so give the name, number, and GE designations (if applicable) currently held.

This is not a revision to any existing course. A prototype version of the course was run as BME 194F Group Tutorial in Winter 2013. Notes on the design and daily running of that prototype can be found at https://gasstationwithoutpumps.wordpress.com/circuits-course-table-of-contents

2. In concrete, substantive terms explain how the course will proceed. List the major topics to be covered, preferably by week.

The course is a lab course paired with BME 101, Applied Circuits for Bioengineers.  The labs have been designed to be relevant to bioengineers and to have as much design as is feasible in a first circuits course.  The labs are the core of the course, with lecture/discussion classes to support them. There will be six hours of lab a week, split into 2 3-hour sessions. Lab assignments will generally take two lab sessions, with data collection in the first lab session, and data analysis and design between lab sessions.   Some of the more straightforward labs will need only a single session.  Except for the first intro lab, these labs have been used in the prototype run of the class as 3-hour labs.  Most did not fit in one 3-hour lab session and would benefit from being split into two separate lab sessions with data analysis and design between the sessions.

1. Intro to parts, tools, and lab equipment (single session)
2. Thermistor
3. Microphone
4. Sampling and aliasing (single session)
5. Audio amp
6. Hysteresis oscillator and soldering lab
7. FET and phototransistor
8. Electrode modeling
9. Pressure sensor and instrumentation amp (soldered)
10. Class-D power amplifier
11. EKG (instrumentation amp with filters, soldered)
1. Intro to parts, tools, and lab equipment
Students will learn about the test equipment by having them use the multimeters to measure other multimeters. What is the resistance of a multimeter that is measuring voltage? of one that is measuring current? what current or voltage is used for the resistance measurement? Students will be  issued their parts and tool kits, learn to use the wire strippers and make twisted-wire cables for the power supplies to use all quarter.  They will learn to set the current limits on the power supplies and  measure voltages and currents for resistor loads around 500Ω.  This lab will not require a written lab report.
Lab skills developed: wire strippers, multimeter for measuring voltage and current, setting bench power supply
Equipment needed: multimeter, power supply
2. Thermistor lab
The thermistor lab will have two lab sessions involving the use of a Vishay BC Components NTCLE413E2103F520L thermistor or equivalent. For the first lab session, the students will use a bench multimeter to measure the resistance of the thermistor, dunking it in various water baths (with thermometers in them to measure the temperature). They should fit a simple curve to this data based on standard thermistor models. A class period will be spent on learning both the model and how to do model fitting with gnuplot, and there will be a between-lab exercise where they derive the formula for maximizing | dV/dT | in a voltage divider that converts the resistance to a voltage.
For the scond lab session, they will add a series resistor to make a voltage divider. They have to choose a value to get as large and linear a voltage response as possible at some specified “most-interesting” temperature (perhaps body temperature, perhaps room temperature, perhaps DNA melting temperature).  They will then measure and plot the voltage output for another set of water baths. If they do it right, they should get a much more linear response than for their resistance measurements.  Finally, they will hook up the voltage divider to an Arduino analog input and record a time series of a water bath cooling off (perhaps adding an ice cube to warm water to get a fast temperature change), and plot temperature as a function of time.
Lab skills developed: use of multimeter for measuring resistance and voltage, use of Arduino with data-acquisition program to record a time series, fitting a model to data points, simple breadboarding.Equipment needed: multimeter, power supply, thermistor, selection of various resistors, breadboard, clip leads, thermoses for water baths, secondary containment tubs to avoid water spills in the electronics lab. Arduino boards will be part of the student-purchased lab kit. All uses of the Arduino board assume connection via USB cable to a desktop or laptop computer that has the data logger software that we will provide.
3. Electret microphone
First, we will have the students measure and plot the DC current vs. voltage for the microphone. The microphone is normally operated with a 3V drop across it, but can stand up to 10V, so they should be able to set the Agilent E3631A  bench power supply to various values from 0V to 10V and get the voltage and current readings directly from the bench supply, which has 4-place accuracy for both voltage and current. Ideally, they should see that the current is nearly constant as voltage is varied—nothing like a resistor.  They will follow up the hand measurements with automated measurements using the Arduino to measure the voltage across the mic and current through it for voltages up to about 4v.  The FET in the microphone shows a typical exponential I vs. V characteristic below threshold, and a gradually increasing current as voltage increases in the saturation region.  We’ll do plotting and model fitting in the data analysis class between the two labs.
Second, we will have them do current-to-voltage conversion with a 5v power supply and a resistor to get a 1.5v DC output from the microphone and hook up the output of the microphone to the input of the oscilloscope. Input can be whistling, talking, iPod earpiece, … . They should learn the difference between AC-coupled and DC-coupled inputs to the scope, and how to set the horizontal and vertical scales of the scope. They will also design and wire their own DC blocking RC filter (going down to about 1Hz), and confirm that it has a similar effect to the AC coupling on the scope. Fourth, they will play sine waves from the function generator through a loudspeaker next to the mic, observe the voltage output with the scope, and measure the AC voltage with a multimeter, perhaps plotting output voltage as a function of frequency. Note: the specs for the electret mic show a fairly flat response from 50Hz to 3kHz, so most of what the students will see here is the poor response of a cheap speaker at low frequencies.
EE concepts: current sources, AC vs DC, DC blocking by capacitors, RC time constant, sine waves, RMS voltage, properties varying with frequency.Lab skills: power supply, oscilloscope, function generator, RMS AC voltage measurement.Equipment needed: multimeter, oscilloscope, function generator, power supply, electret microphone, small loudspeaker, selection of various resistors, breadboard, clip leads.
4. Sampling and Aliasing
Students will use the data logger software on the Arduino to sample sine waves from a function generator at different sampling rates.  They will need to design a high-pass RC filter to shift the DC voltage from centered at 0 to centered at 2.5v in the middle of the Arduino A-to-D converter range.  They will also design a low-pass filter (with corner frequency below the Nyquist frequency) to see the effect of filtering on the aliasing.
EE concepts: quantized time, quantized voltage, sampling frequency, Nyquist frequency, aliasing, RC filters.
Equipment needed:  function generator, Arduino board, computer.
5. Audio amplifier
Students will use an op amp to build a simple non-inverting audio amplifier for an electret microphone, setting the gain to around 6 or 7. The amplifier will need a a high-pass filter to provide DC level shifting at the input to the amplifier. Note that we are using single-power-supply op amps, so they will have to design a bias voltage supply as well. The output of the amplifier will be recorded on the Arduino (providing another example of signal aliasing).
The second half of the lab will add a single bipolar transistor to increase the current and make a class A output stage for the amplifier, as the op amp does not provide enough current to drive the 8Ω loudspeaker loudly.
EE concepts: op amp, DC bias, bias source with unity-gain amplifier, AC coupling, gain computation.
Lab skills: complicated breadboarding (enough wires to have problems with messy wiring). If we add the Arduino recording, we could get into interesting problems with buffer overrun if their sampling rate is higher than the Arduino’s USB link can handle.
Equipment needed: breadboard, op amp chip, assorted resistors and capacitors, electret microphone, Arduino board, optional loudspeaker.
6. Hysteresis and capacitive touch sensor
For the first half of the lab, students will characterize a Schmitt trigger chip, determining VIL, VIH, VOL, and VOH. Using these properties, they will design an RC oscillator circuit with a specified period or pulse width (say 10μs), and measure the frequency and pulse width of the oscillator.
For the second half of the lab, the students will build a relaxation oscillator whose frequency is dependent on the parasitic capacitance of a touch plate, which the students can make from Al foil and plastic food wrap. In addition to breadboarding, students will wire this circuit by soldering wires and components on a PC board designed for the oscillator circuit. Students will have to measure the frequency of the oscillator with and without the plate being touched. We will provide a simple Arduino program that is sensitive to changes in the pulse width of the oscillator and that turns an LED on or off, to turn the frequency change into an on/off switch.  Students will treat the oscillator board as a 4-terminal component, and examine the effect of adding resistors or capacitors between different terminals.
EE concepts: frequency-dependent feedback, oscillator, RC time constants, parallel capacitors.
Lab skills: soldering, frequency measurement with digital scope.
Equipment needed: Power supply, multimeter, Arduino, clip leads, amplifier prototyping board, oscilloscope.
7. Phototransistor and FET
First half: characterize phototransistor in ambient light and shaded.  Characterize nFET and pFET.
Second half: students will “tinker” with the components they have to produce a light-sensitive, noise-making toy.
EE concepts: phototransistors, FETs.
Equipment needed: breadboard, phototransistor, power FETs, loudspeaker, hysteresis oscillator from previous lab, oscilloscope.
8. Electrode measurements
First, we will have the students attempt to measure the resistance of a saline solution using a pair of stainless steel electrodes and a multimeter. This should fail, as the multimeter gradually charges the capacitance of the electrode/electrolyte interface.Second, the students will use a function generator driving a voltage divider with a load resistor in the range 10–100Ω. The students will measure the RMS voltage across the resistor and across the electrodes for different frequencies from 3Hz to 300kHz (the range of the AC measurements for the Agilent 34401A Multimeter). They will plot the magnitude of the impedance of the electrodes as a function of frequency and fit an R2+(R1||C1) model to the data, most likely using gnuplot. There will be a prelab exercise to set up plotting of the model and do a little hand tweaking of parameters to help them understand what each parameter changes about the curve.Third, the students will repeat the measurements and fits for different concentrations of NaCl, from 0.01M to 1M. Seeing what parameters change a lot and what parameters change only slightly should help them understand the physical basis for the electrical model.Fourth, students will make Ag/AgCl electrodes from fine silver wire. The two standard methods for this involve either soaking in chlorine bleach or electroplating. To reduce chemical hazards, we will use the electroplating method. As a prelab exercise, students will calculate the area of their electrodes and the recommended electroplating current.  In the lab, they will adjust the voltage on the bench supplies until they get the desired plating current.Fifth, the students will measure and plot the resistance of a pair of Ag/AgCl electrodes as a function of frequency (as with the stainless steel electrodes).Sixth, if there is time, students will measure the potential between a stainless steel electrode and an Ag/AgCl electrode.EE concepts: magnitude of impedance, series and parallel circuits, variation of parameters with frequency, limitations of R+(C||R) model.Electrochemistry concepts: At least a vague understanding of half-cell potentials, current density, Ag → Ag+ + e-, Ag+ + Cl- → AgCl, Fe + 2 Cl-→ FeCl2 + 2 e-.Lab skills: bench power supply, function generator, multimeter, fitting functions of complex numbers, handling liquids in proximity of electronic equipment.Equipment needed: multimeter, function generator, power supply, stainless steel electrode pairs, silver wires, frame for mounting silver wire, resistors, breadboard, clip leads, NaCl solutions in different concentrations, beakers for salt water, secondary containment tubs to avoid salt water spills in the electronics lab.
9. Pressure sensor and instrumentation amplifier
Students will design an instrumentation amplifier with a gain of 300 or 500 to amplify the differential strain-gauge signal from a medical-grade pressure sensor (the Freescale MPX2300DT1), to make a signal large enough to be read with the Arduino A/D converter. The circuit will be soldered on the instrumentation amp/op amp protoboard. The sensor calibration will be checked with water depth in a small reservoir. Note: the pressure sensor comes in a package that exposes the wire bonds and is too delicate for student assembly by novice solderers. We will make a sensor module that protects the sensor and mounts the sensor side to a 3/4″ PVC male-threaded plug, so that it can be easily incorporated into a reservoir, and mounts the electronic side on a PC board with screw terminals for connecting to student circuits.  This sensor is currently being prototyped, and if it turns out to be too fragile, we will use a Freescale MPX2050GP, which has a sturdier package, but is slightly less sensitive and more expensive. (It also isn’t made of medical-grade plastics, but that is not important for this lab.) Note that we are deliberately notusing pressure sensors with integrated amplifiers, as the pedagogical point of this lab is to learn about instrumentation amplifiers.EE concepts: differential signals, twisted-pair wiring, strain gauge bridges, instrumentation amplifier, DC coupling, gain.Equipment needed: Power supply, amplifier prototyping board, oscilloscope, pressure sensor mounted in PVC plug with breakout board for easy connection, water reservoir made of PVC pipe, secondary containment tub to avoid water spills in electronics lab.
10. Class-D power amplifier
11. Electrocardiogram (EKG)
Students will design and solder an instrumentation amplifier with a gain of 2000 and bandpass of about 0.1Hz to 100Hz. The amplifier will be used with 3 disposable EKG electrodes to display EKG signals on the oscilloscope and record them on the Arduino.Equipment needed: Instrumentation amplifier protoboard, EKG electrodes, alligator clips, Arduino, oscilloscope.

3. Systemwide Senate Regulation 760 specifies that 1 academic credit corresponds to 3 hours of work per week for the student in a 10-week quarter. Please briefly explain how the course will lead to sufficient work with reference to e.g., lectures, sections, amount of homework, field trips, etc. [Please note that if significant changes are proposed to the format of the course after its initial approval, you will need to submit new course approval paperwork to answer this question in light of the new course format.]

The combination of BME101 and BME101L is 7 units (21 hours per week).  The time will be spent approximately as follows:

• 3.5 hours lecture/discussion
• 3.5 hours reading background and circuits text
• 3 hours read lab handouts and doing pre-lab design activities
• 6 hours lab
• 5 hours writing design reports for lab

4. Include a complete reading list or its equivalent in other media.

Lab handouts: there is a 5- to 10-page handout for each week’s labs, giving background material and design goals for the lab, usually with a pre-lab design exercise.  The handouts from the prototype run of the course can be found at http://users.soe.ucsc.edu/~karplus/bme194/w13/#labs
Data sheets: Students will be required to find and read data sheets for each of the components that they use in the lab.  All components are current commodity components, and so have data sheets easily found on the web.  Other readings are associated with the lecture course.

5. State the basis on which evaluation of individual students’ achievements in this course will be made by the instructor (e.g., class participation, examinations, papers, projects).

Students will be evaluated on in-lab demonstrations of skills (including functional designs) and on the weekly lab write-ups.

6. List other UCSC courses covering similar material, if known.

CMPE 167/L (sensors and sensing technologies) covers some of the same sensors and design methods, but at a more advanced level.  BME 101L would be excellent preparation for the CMPE 167/L course.

Physics 160 offers a similar level of practical electronics, but focuses on physics applications, rather than on bioengineering applications, and is only offered in alternate years.

7. List expected resource requirements including course support and specialized facilities or equipment for divisional review. (This information must also be reported to the scheduling office each quarter the course is offered.)

The course will need the equipment of a standard analog electronics teaching lab: power supply, multimeter, function generator,  oscilloscope,  computer, and soldering irons. The equipment in Baskin Engineering 150 (commonly used for EE 101L) is ideally suited for this lab. There are 12 stations in the lab, providing a capacity of 24 students since they work in pairs rather than as individuals.  The only things missing from the lab stations are soldering irons and circuit board holders (such as the Panavise Jr.), a cost of about $45 per station. Given that a cohort of bioengineering students is currently about 35–40 students, two lab sections would have to be offered each year. In addition, a few special-purpose setups will be needed for some of the labs, but all this equipment has already been constructed for the prototype run of the course. There are a number of consumable parts used for the labs (integrated circuits, resistors, capacitors, PC boards, wire, and so forth), but these are easily covered by standard School of Engineering lab fees. The currently approved lab fee is about$131, but may need some adjustment to change exactly what tools and parts are included, particularly if the students are required to buy their own soldering irons (a \$20 increase).

The course requires a faculty member (simultaneously teaching the co-requisite Applied Circuits course) and a teaching assistant (for providing help in the labs and for evaluating student lab demonstrations). Because the lab is such a core part of the combined course, it requires faculty presence in the lab, not just coverage by TAs or group tutors.

8. If applicable, justify any pre-requisites or enrollment restrictions proposed for this course. For pre-requisites sponsored by other departments/programs, please provide evidence of consultation.

Students will be required to have single-variable calculus and a physics electricity and magnetism course. Both are standard prerequisites for any circuits course. Most of the labs can be done without calculus, but it is essential for the accompanying lecture course.

9. Proposals for new or revised Disciplinary Communication courses will be considered within the context of the approved DC plan for the relevant major(s). If applicable, please complete and submit the new proposal form (http://reg.ucsc.edu/forms/DC_statement_form.doc or http://reg.ucsc.edu/forms/DC_statement_form.pdf) or the revisions to approved plans form (http://reg.ucsc.edu/forms/DC_approval_revision.doc or http://reg.ucsc.edu/forms/DC_approval_revision.pdf).

This course is not expected to contribute to any major’s disciplinary communication requirement, though students will get extensive writing practice in the design reports (writing between 50 and 100 pages during the quarter).

10. If you are requesting a GE designation for the proposed course, please justify your request making reference to the attached guidelines.

No General Education code is proposed for this course, as all relevant codes will have already been satisfied by the prerequisites.

11. If this is a new course and you requesting a new GE, do you think an old GE designation(s) is also appropriate? (CEP would like to maintain as many old GE offerings as is possible for the time being.)

No General Education code is proposed for this course, as all relevant codes (old or new) will have already been satisfied by the prerequisites.

## 2012 December 30

### Mic modeling lab rethought

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

In Mic modeling lab too complicated, I complained about the following graph being too complicated for the 2nd week lab for the circuits for bioengineers course:

Current vs. voltage curve for the electret mic The magenta curve (with the log dependence on voltage across the mic) was my previous model, based on data from 1v to 10v.  I don’t know what theory gives the appropriate slope to the saturation current—most of the models I’ve seen make that region constant current.

I spent all day yesterday rethinking this lab and trying a number of different approaches.  (Well, not quite all day—I spent some time in the morning testing all 12 pressure sensor boards I’d soldered up the day before.)

What I decided to do was to embrace the non-linearity and have students characterize the part, but I’ll give them some simple models to fit.  I also decided to have the students use the Arduino to automate the data measurement—I didn’t have enough use of the Arduino in the course, and automating tedious measurements is precisely why we decided to include the use of the Arduino in the course.

Of course, there are some limitations of the Arduino analog-to-digital converter that are important for this lab:

• The highest voltage allowed is 5v and the lowest is 0v.
• The resolution is only 10 bits (1024 steps).
• The steps seem to be more uniformly spaced at the low end of the range than the high end (so differences at the high end are less accurate than differences at the low end).
• The external reference voltage AREF must be at least 0.5v (this is not in the data sheet, but when I tried lower AREF voltages, the reading was always 1023.

I think I’ll have the students start with using the multimeter and the bench power supply to measure voltage and current pairs for 1V to 10v in steps of 1v.  Then I’ll have them wire up a simple circuit on the breadboard:

Circuit for measuring DC characteristics of an electret microphone. The four labeled nodes are connected to the Arduino.

The idea is simple: the bench power supply will provide a known voltage (between 0.5v and 5.0v) to the external reference AREF, and the data logger code will measure the voltage across the load resistor and across the load resistor every 100msec. The students will adjust the trimpot (they have 18-turn 10kΩ trimpots in their parts kits), while the Arduino measures the voltages. They’ll  then use gnuplot to plot the i-vs.-v and r-vs.-v curves for the device. They’ll probably have to collect two or three files of data, with different AREF voltages (0.55v, 2v, 5V, for example) in order to cover the full range of values with adequate precision.

I put the load resistor on the lower leg, so that I could get more accurate readings of low currents. I had tried it on the upper-leg first, but the results were not as consistent with different AREF voltages.

I’ll give them four models to fit and some hints on how to fit multi-variable models with gnuplot, here expressed as resistances:

• constant resistance $r$
• constant saturation current $v/i_{sat}$
• blend of resistance and saturation current $\sqrt{r^2 + (v/i_{sat})^2}$
• power-law slope for resistance in saturation region $\sqrt{r^2 + (v^{v_exp}/i_{sat})^2}$

The first two models are the ones most often used as rules of thumb when designing.  The third one provides a decent blending between them, though it is purely an empirical fit—there is no theory that says this is the right model in the sublinear region (though the usual model for pinch-off current seems just as arbitrary to me).  The last model has no theoretical justification at all, it just provides a good way to match the empirically observed dependence of the “saturation” current on voltage.  I played with lots of models before deciding on these four.

Here are some plots of how well they fit the data I measured:

On a log-log scale, both the blended models look pretty good.

Changing the current to a linear scale makes the problems with the constant saturation current model clearer.
The multimeter measurements are almost certainly better than the measurements with the Arduino, but the sheer number of measurements with the Arduino (about 1200, once duplicates are removed) makes those measurements dominate the fitting.

It was actually from looking at the equivalent resistance of the microphone that I saw a simple way to produce the blended model without having to introduce new parameters (like saturation voltage).  On this plot, the improved fit in the sublinear region for my model is clearer.

I think that the “linear” region may actually be better modeled with a resistance that varies with voltage, rather than a constant resistance, but the data I have at the low voltage end is rather bad: the quantization errors are extreme and I don’t really trust the numbers.  Trying to add more complexity for the linear region did not seem to improve the fit, and we never use the mic in the linear region anyway, so I decided to keep the models simple.

So the microphone lab will have two major components:

• DC characterization of the microphone, using the Arduino to automate measurements.
• Visualization of AC waveforms using the oscilloscope.

I just hope that there is enough time in the 3-hour lab for the students to do both.

## 2012 December 26

### Mic modeling lab too complicated

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

My son and I cycled up to campus today to turn off the computers in my office and in the lab (since the campus has a 2-day power shutdown starting tomorrow morning).

While we were on campus we checked out the latest version of his data logger code on the Windows machines there.  We found that the installation was incomplete, and my son fixed the driver installation (testing with both an Arduino Uno and an Arduino Duemilanove, as they need different Windows drivers), Timer1 library renaming, and the Path variable on 6 of the machines (benches 7–12).  These six are now all usable, except that the computer on bench 11 has only one USB port (the left port seems to be damaged). We did not update benches 1–6, but might go in next week to do it.

While my son was making sure that the drivers were installed and the other installation fixes, I checked out the function generator.  This was a bit hard, as the output is from a BNC connector, and I had to hunt through the whole lab to find one cable with BNC connector on one end and clip leads on the other.  I’m hoping that the cables are just in storage during break, because we need the function generator for the second lab.  There was no problem driving a loudspeaker from the function generator, and the sine waves are clearly picked up by the microphone.

I also did a bunch more measurements of the I-vs-V DC characteristics of the electret mic, for lower voltages.  This really changes my picture of the DC characteristics of the electret mic. Looking on a log-log plot, I now think we’ll need to piece together two very different models, a linear model for low drain-to-source voltages and a power-law fit for large drain-to-source voltages.  The two-part fit is a common modeling trick for FETs (the linear region and the saturation region), but the saturation region is usually modeled as constant current.

Current vs. voltage curve for the electret mic with more data points than my previous plot, showing that just making measurements from 1v to 10v was a bad idea. The magenta curve (with the log dependence on voltage across the mic) was my previous model, based on data from 1v to 10v.  I don’t know what theory gives the appropriate slope to the saturation current—most of the models I’ve seen make that region constant current.

Unfortunately, I think that this 2-part modeling is too complicated for the bioengineering students to discover on their own and we don’t want to go into such complicated models for FETs, so part of the microphone lab is now too messy for students to do. I mean, I can have them make the measurements, and see that it is a mess, and they can certainly figure out what size bias resistor to use to get a given DC output voltage given their measurements, but I don’t think I can have them do the more complicated fitting and they won’t come away from the lab with a simple model of the mic that they can use for design.

The usual operating conditions for the mic (with 3V across it) are well into the saturation region—I wonder how the mic behaves if the FET is operated in the linear region instead.  Does this introduce a lot of distortion?  If we want to keep the mic in the saturation region (and not linear or sublinear), we have to have at least 0.4V across it, which does put some constraints on the load resistor for converting the current to a voltage.

I’ll have to give some thought to how I’ll modify this lab to make it useful without being overwhelming.

Next Page »