Gas station without pumps

2015 April 16

Microphone labs went OK

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

The microphone labs this week went OK (much better in the afternoon session than the morning session).  On Tuesday the students collected data for an I-vs-V plot of the electret microphone, both using a power supply and a pair of voltmeters and using just the PteroDAQ system on the KL25Z board (see New modeling lab for electret microphone for the basics of the PteroDAQ portion of the lab).  Most groups got all the data they needed on Tuesday, but some were still struggling with it on Thursday.

On Wednesday, I went over the model fitting in gnuplot used to produce the fits for the 4 models I gave them: linear resistance, constant current, a “blended model” that is asymptotically the same but switches smoothly between them, and one that adds one more parameter to get a slope for the saturation region(again, see New modeling lab for electret microphone for the models) .  Some students in the class asked for a copy of the script I developed in class, but I turned them down—the goal is to get them to develop their own scripts, and they had examples of most of what I did from the previous week’s class, which included a worked example.

In previous years, I used to give out all the things developed in class as worked examples, but I’ve stopped doing that, because far too many students just blindly copied and ran scripts without understanding them (often not even changing the parameter values that were different between what I did in the example and the data they collected).  One point of this class is to get students to stop thinking of class work as ritual magic that just requires doing the right memorized or copied procedure, and to get them to think in terms of creating new stuff from building blocks that they understand. It is unfortunate that most of the chemistry and physics labs they have had are exactly that sort of ritual magic, with a worksheet telling them exactly what steps to perform and what results to fill in the blanks with.

They need to learn to generalize from worked examples, read documentation, and figure out how to make things work. I’m always happy to help them debug their efforts, but not to do the work for them.  I’m not in the class to get right answers from the students, but to get them to learn how to design and debug—to ask their own questions and figure out how to answer them. (See Answer getting for more on what change I’m trying to invoke.)  Some of the top students are already on board with the concept and are working hard to understand electronics, modeling, graphing, debugging, and so forth , but a number of the students are still stuck in the “tell me exactly what to memorize and what steps to do” state that seems characteristic of many high school students.  The biology classes they’ve had have not done much to move them away from that—there is far too much memorization without understanding going on in the bio courses.

In addition to the model fitting, I answered questions from the homework—mainly about the calculation of the output voltage from the mic for a given input sound level. I reviewed decibels again and went through the various scaling operations needed to get the output in µV RMS from sound pressure level.  I think that the top students got it, but I’m also pretty sure I lost the bottom ones—it’s a little hard to tell as they all work so hard on looking intelligent that I have a hard time telling when they are lost and when they are bored because I’m going too slow.

Today’s lab was a little bit of design (choosing a load resistor based on the I-vs-V curve, and designing a high-pass filter to block the DC) and practice using the oscilloscope. I did something different this year, having them design their high-pass filter with the input impedance of the oscilloscope as the “R” of the RC filter. In part this was to get them to realize that connecting a test instrument like an oscilloscope or voltmeter always changes the circuit that is being tested.  I even had them design around the 10MΩ input impedance of the 10× scope probe—so the 10MΩ impedance was not “almost infinite” the way many intro electronics courses teach it.  I don’t think I made a clear enough point of this message—neither in the book nor in the lab sections, so I’d better mention it in class tomorrow also.

Unfortunately, some of the material from the old lab (where they used bigger capacitors and smaller resistors for the high-pass filter) was not edited out in making the changes, so the lab chapter was rather confusing.  I’ve left some notes to myself to update the chapter, but I probably won’t have time until this summer.

2015 April 13

Too much prelab homework for microphone lab

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

In putting together the book for this quarter, I added exercises to some of the chapters, and I assigned a chunk of them due today as the pre-lab exercise for the microphone lab.  I just spent over 3 hours grading the set, just marking questions right or wrong. There were too many questions, and even the best in the class got only 8/11, with the bottom of the class getting 3/11. I think that the class is doing better this year than previous years’ classes, but some of them got discouraged by how much and how difficult the homework was.  The amount was certainly more than I had intended, but next week’s homework should be substantially less.  I’ll have to figure out how to distribute the load more evenly next year.

I spent most of today’s lecture going over two of the questions (in response to student request), and I’ll have to do some of the other ones on Wednesday, in addition to showing them how to model DC behavior of the FET in the electret microphone. I may also ask the group tutor for the class to have an extra help session this week.  The two questions that got asked about were the modeling of the oscilloscope probe and computing the sensitivity of the electret microphone circuit with a different load resistor.

Some of the problems students had were ones that can be easily fixed (like that 1/10000 is 0 in gnuplot, because it looks like integer arithmetic—1/10E3 does the right computation, as does 1./10000).  Other problems were fundamental misunderstandings of complex numbers or complex impedance, which may be harder to address.

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.

2015 April 9

Second half of temperature lab went well

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

I continue to be pleased with this Spring’s class.  It is taking up far too much of my time, but the students are doing well. Today they got their resistors (and ceramic capacitors), so they could select whatever resistor value they needed for the optimization problem.  I told them by e-mail last night to optimize for 12°C, which I estimated would require about a 12kΩ resistor.  I change the temperature point each year, so that students can’t just look up an answer—not that it would do them much good if they could, as the design report needs to contain the derivation of the result.  If they can copy the math correctly, then they can do it (especially since we did the derivation in class yesterday).

I put some reminders/instructions on the board at the beginning of lab, something like the following:

  • Optimize for max sensitivity @ 12°C
  • Measure your resistor
  • Measure Vin
  • Measure Vout at many temperatures
  • Plot Vout vs temp both from model (as curve) and as data points, to check calibration.
  • Plot temp vs time for 10 minutes of water warming up from low temperature (using PteroDAQ)

Everyone seemed to be getting good data in the lab.  What students seemed to need the most help with was the concept of putting the predicted behavior of the circuit on the same graph with the measured behavior. They had a formula for the voltage as a function of temperature with 4 parameters: B and R∞ from fitting Tuesday’s data, R that they chose and measured, and Vin that they measured though it was nominally 3.3V. But it was hard going trying to convince them to plot that curve on the same graph as the scatter diagram of today’s measurements.  It may be that they have never been asked to plot a predicted curve and measurements on the same plot before—as if they’ve never actually checked that a model is correct. I would have thought that physics classes would have done that sort of predictive modeling, but apparently not, as the concept seemed completely foreign to many of the students.

Those who did finally get the calibration plot done generally had very good agreement between their measurements and the predicted model.  I’m hoping the rest will get the plots done tonight.  There was at least one group that was seeing about a 0.5°C discrepancy, which could be due to different calibration of the thermometers used on Tuesday and today, or could be due to their using a wrong value for the °C to °K conversion.

The students also recorded a time course of a water bath warming up from about 3°C. I think that next year I might do a higher optimum temperature and ask students to record a water bath cooling down—the temperature change is faster that way (due to evaporation). I’ve asked them to plot this as temperature vs. time, not voltage vs. time, and several students seemed well on their way to doing that correctly—this year’s class seems much more adept at picking up gnuplot techniques than the last two years’ classes.  I don’t know whether that is because of a better ordering of the material this year, or some difference in the cohort.  I like to think it is an improvement in the way I present things, but it is more likely to be a difference in the students.

One pair of students surprised me in a good way—they had done the optimization last night, then tried out the design at home, using the PteroDAQ to read voltage.  Since they did not have the resistor kits yet, they had put the two 22kΩ resistors they did have in parallel to make an 11kΩ resistor.  They were worried I might be upset with them for jumping the gun on the lab—quite the contrary, I’m delighted that they’re preparing before class, and that they realized that a lot of the lab work doesn’t really require the fancy equipment in the lab. I’ve pitched the class as being suitable for creating electronics hobbyists, and if some of them get into that early in the course, then the course is being highly successful!

I’ve even considered rewriting a number of the labs to be doable completely at home, but right now too many would require about a $250 investment in a USB oscilloscope, which makes an all-at-home approach a bit too expensive for me to recommend.  It might be an interesting way to market the book though—as a complete electronics at home lab course for about $400.  I think that there is a substantial market for such a kit/course, but it would be a fair amount of work to get the book into shape for use without a lab mentor to guide the students through the rough spots.

I’m looking forward to this week’s reports (that’s right, for once I’m looking forward to the grading, rather than dreading it), as I think that a lot of the class actually got all the concepts that this week’s lab was about.

Tomorrow I’ll be introducing complex impedance (particularly Z_{C} = \frac{1}{j\omega C}) and RC filters as voltage dividers.  I’ll be doing most of the lecture as a chalk talk, but I’ll bring my laptop to show them how to create (amplitude) Bode plots with gnuplot.  We’ll be doing various things with model fitting, with variants on voltage dividers, and with complex impedance for the next 3 weeks, and then we’ll start on amplifiers.

 

 

2015 April 8

Optimization and model fitting went well today

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

Today’s lecture in BME 101 (the Applied Electronics for Bioengineers class) went very smoothly. I started with a little light entertainment: a video about blowing up capacitors, sent to me by Jameco: http://www.jameco.com/Jameco/content/incorrectly-using-capacitors.html This video reinforced the message that I had given them in lab last week about electrolytic capacitors.

I had two topics to cover: the optimization problem from last weekend’s homework, which only one student had managed to do, and model fitting to extract parameters for the thermistor model from the data collected in lab yesterday.

I gave the students the choice of order for the topics, and they wanted the optimization first.  The problem is fairly straightforward from an engineering standpoint: we want to maximize the sensitivity of the circuit that converts temperature to voltage at a specific operating temperature Topt. I first sketched very rough plots of what the voltage would look like as a function of temperature: monotone increasing but not particularly linear. I reminded them that sensitivity is the change in output that you get for a given change in input: dV/dT.  I coaxed out of the class the idea that to maximize the function dV/dT, we need to take its derivative and set it to 0: \frac{d^2 V }{d T^2} = 0.  We only have one free variable in our circuit to change (the load resistor R), so we need to take that equation and solve it for R, to get the value of R that maximizes sensitivity.

I reminded them of the simple model for the resistance of a thermistor that we’d had on Monday: R_{T} = R_{\infty} e^{B/T}, and they had no trouble coming up with the equation for the output voltage V = V_{in} \frac{R}{R+R_{\infty} e^{B/T}}.  I then suggested using Wolfram Alpha to solve the equation, and switched from the chalkboard to the screen to type

solve d^2 (R/(R+S e^(B/T)))/ dT^2 = 0 for R

(changing R to S, to avoid confusing Wolfram Alpha with subscripts).
Wolfram Alpha conveniently replied with two solutions: R=0 (which would result in a constant 0 output voltage, clearly a minimum sensitivity) and R= S e^{B/T} \frac{B-2 T}{B+ 2T}. I pointed out that the first part was just the resistance of the thermistor at the temperature we were optimizing for, and the second term scales that down a little.

We then moved on to fitting the model. I showed three data sets that students had sent me—one which was a little messy, but still quite usable, one that was a little better, and one that was really beautiful.  I continued with the really good data set.  I explained that gnuplot tries to minimize the error on the y-axis for a function of things on the x-axis, and the students decided that minimizing the temperature error for a given resistance was probably best here. (I suspect it doesn’t make much difference with this data, but it is good to get them to think about that as a decision that needs to be made for each modeling problem.)

On the board, I turned around the equation for the model, to get temperature in terms of R: T = \frac{B}{\ln R - \ln R_{\infty}}.

I then developed the gnuplot script for the problem live, debugging as I went.  Some of the errors to debug were ones I introduced deliberately, others were inadvertent, but all were good for teaching both the process of debugging and the notion of doing sanity checks.  My first mistake was an inadvertent one: I capitalized a variable differently in the parameter list and in the function body, and gnuplot is case-sensitive.  This was very easy to find and fix, and gave me an opportunity to tell students that gnuplot was sensitive to case, since that had not come up previously. My second mistake was a deliberate one: I typed in the model exactly as we had derived it on the board, knowing full well that the model was for °K, but the data was for °C.  I’d even reminded students of that earlier, when we were doing the optimization problem.

I then ran the fit in gnuplot and asked students if we were done, or if there was a sanity check we could do.  A couple of them asked if we could plot the model and the data on the same plot, so I did that. The fit was very obviously completely wrong. So I asked the students what was wrong and how we could fix it. I did dice-assisted cold calling to put 3 or 4 students on the spot, getting not very useful answers, then took answers from a couple of students who raised their hands. The second student pointed out the °C vs °K problem.

So I fixed the formula and ran the fit again, expecting everything to work fine.  It didn’t! So we went into debugging mode, trying to see if starting with better estimates of B and R would help. Nope. Then I realized that I had made a second inadvertent error: I’d put in 273.15 with the wrong sign! I fixed that, ran the fit again, and again things failed (producing negative values for R).  This time, though when I put in better initial estimates, everything converged to a very good fit, which gave me a teachable moment about the need to have decent estimates before fitting, so that the optimization algorithm that did the fitting could converge.

The final script was

temp(R,B,Rinf) = B / ( log(R) - log(Rinf)) - 273.15
B=3000; Rinf=1e-4
fit temp(x,B,Rinf) 'student-thermistor-data-3.txt' using 2:1 via Rinf,B
plot 'student-thermistor-data-3.txt' using 2:1, \
      temp(x,3435,10*exp(-3435/(25+273.15))), \
      temp(x,B,Rinf)

The second curve of the plot is using the data sheet values for the B value and for R25°C=10kΩ.
Here is the plot produced:

Notice that I did not have axis labels, title, nor echoing of the parameters in the key.  We covered that last week and I'm hoping that students can carry skills over from one week to the next.

Notice that I did not have axis labels, title, nor echoing of the parameters in the key. We covered that last week and I’m hoping that students can carry skills over from one week to the next.

The model fit is slightly better than the data sheet values, but the data sheet values were closer than I had expected based on previous years’ fits. I think that it may be that the students had a properly calibrated thermometer (I’d removed any digital thermometers that reported ice water as warmer than 0.5°C—about 1/3 of them were that far out of calibration), and that this particular pair of students had been very careful with their measurements.

Next Page »

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 309 other followers

%d bloggers like this: