Gas station without pumps

2015 April 10

Sinusoids and impedance lecture

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

Today’s lecture in BME 101 (the Applied Electronics for Bioengineers class) was again pretty much just as I had planned.  I covered three topics:

• Sinusoids
• Capacitors
• Complex impedance (of capacitors)

The sinusoids section was a brief intro to Euler’s Formula: $e^{j \theta} = \cos(\theta) + j \sin(\theta)$, expanding to the general sinusoid we’ll use all quarter: $A e^{j \omega t + \phi}$.  I showed them what phase meant on both a time-domain sine wave and as a rotation of the unit circle.  I suspect that those who already knew Euler’s Formula had their memory refreshed, and those unfamiliar with it will either look up info about complex numbers or give up because they are math-phobic.  This year’s class doesn’t seem particularly math-phobic (so far), so I’m hopeful that they’ll refresh their memories of complex numbers, because we’ll be using sinusoids in this form a lot.

I did a lot of cold-call questioning in the capacitor section, getting students to give me the charge formula Q=CV and some descriptions of  the structure of a capacitor fairly quickly. I also mentioned the dependency of capacitance on area, insulator thickness, and dielectric constant.  I gave the relative dielectric constant of air as about 1 (I looked it up now as 1.0006), plastics as 2–4, and ceramic capacitors as around 10,000. I was wrong about the ceramics:  the class 2 Barium titanate ceramics (what we have in our cheap ceramics) have a relative dielectric constant in the range 3000–8000, and the class 1 paraelectric ceramics only 5–90.  I claimed that electrolytic capacitors relied on the thinness of the oxide and large plate area, rather than high dielectric constants, but didn’t give a value (Kemet, who makes capacitors, claims 8.5, so a little more than plastics, but nowhere near the ceramics [http://www.kemet.com/Lists/TechnicalArticles/Attachments/6/What%20is%20a%20Capacitor.pdf]).

I then got from the students that $I = dQ/dt$, and thus that $I = C dV/dt + V dC/dt$ (getting the class to apply the chain product rule took a while).  I pointed out that we would usually use examples in which C was constant, so the formula simplified to $I = C dV/dt$, but that some of our circuits would have changing capacitance (like the electret microphones that they’ll use next week and the capacitive touch sensor that they’ll design later).

I then put the two previous parts together, defining impedance as a generalization of  resistance, for sinusoidal signals: $Z = V/I$.  We then made the voltage by an arbitrary sinusoid, $V(t) = A e^{j \omega t + \phi}$, and figured out the impedance of a capacitor $Z_C = \frac{1}{j \omega C}$.  I had them give me the impedance of a resistor and capacitor in series (a couple of false starts, but quickly converging to the right answer: $R + \frac{1}{j \omega C}$). Finally, I had them give me the formulas for a couple of voltage dividers: a high-pass RC filter and a low-pass RC filter, and we simplified the formulas by multiplying top and bottom by ${j \omega C}$.

I then switched to gnuplot and showed them how to plot the magnitude of the impedance of a circuit as a function of frequency, and the gain of a high-pass filter:

j = sqrt(-1)
Z_C(w,C) = 1/ (j * w *C)
set xrange [1:10000]
plot abs(Z_C(2*pi*x, 1e-6))

set logscale xy
plot abs(Z_C(2*pi*x, 1e-6))

divider(zup,zdown) = zdown/(zup+zdown)
R=4700
plot abs(divider(Z_C(2*pi*x, 1e-6)  , R))


The gnuplot stuff was a little hurried, so I’ll spend the first part of Monday on Bode plots, corner frequencies, and the design of RC filters. They have a homework (prelab) exercise due on Monday, so they should be primed for understanding the material.

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.
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.

2014 April 11

Impedance, finally

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

I finally got a chance to cover impedance in class today.

I started with complex numbers and Euler’s formula ($e^{j\theta} = \cos(\theta) + j \sin(\theta)$), showed them how the amplitude and phase terms could easily be factored out to make a phasor, then had them develop the formulas for impedance of resistors and capacitors.  For capacitors, I had to guide them a bit, but they came up with $Q=CV$, $i = dQ/dt$, and taking the derivative of the voltage.  That actually went a bit smoother than I expected, and almost everyone in the class was participating.

I then had them come up with the circuit for an RC filter (they only know one circuit, the voltage divider, so this was pretty easy). They used the voltage divider formula to get the gain of the filter, and I showed them how to plot it by hand (a Bode plot).  The filter we started with was a low-pass filter, so I challenged them to design a high-pass filter.  This is an easy task, and they almost instantly suggested swapping the resistor and capacitor.  They derived the formula for the gain of that filter, and I showed them the how to draw the Bode plot for it also.

Note: we only do amplitude Bode plots in this class, not phase.  For what they are doing, the phase response is not very important.  I did let them know that there were more advanced classes where the phase response was carefully determined, and that filter design got a lot more complicated than simple RC filters.

I covered in class almost exactly what I set out to do, and the students came up with most of what I wrote on the board, so I felt that the Socratic questioning I used to guide them worked fairly well.  I’ll probably have to give them some design exercises soon, to see if they actually understand the material or were just nodding along with their classmates.

This weekend I’ll grade their second design reports (for the microphone lab), and try to rewrite the week-4 labs, which will be characterizing polarizing and non-polarizing electrodes.  I have a bunch of other stuff to do this weekend also (mow lawn, do state taxes, read a thesis proposal, read a chapter of a thesis, replace the rear wheel on my bike, rewrite the designing courses to tech design talk, write a letter of recommendation for a former student trying to get a green card, feed the cats and the fish, … ). I may have a bit less time than usual this weekend, because I’m cooking for myself—my wife and my son have gone to an admitted-students weekend at UCSB.