Gas station without pumps

2015 April 23

Very long couple of days

Yesterday and today have been draining.

Yesterday, I had three classes each 70 minutes long: banana slug genomics, applied electronics for bioengineers, and a guest lecture for another class on protein structure.  I also had my usual 2 hours of office hours, delayed by half an hour because of the guest lecture.

The banana-slug-genomics class is going well.  My co-instructor (Ed Green) has done most of the organizing and has either arranged guest lectures or taught classes himself. This week and part of next we are getting preliminary reports from the 5 student groups on how the assemblies are coming.  No one has done an assembly yet, but there has been a fair amount of data cleanup and prep work (adapter removal, error correction, and estimates of what kmer sizes will work best in the de Bruijn graphs for assembly).  The data is quite clean, and we have about 23-fold coverage currently, which is just a little low for making good contigs.   (See https://banana-slug.soe.ucsc.edu/data_overview for more info about the data.) Most of the data is from a couple of lanes of HiSeq sequencing (2×100 bp) from 2 libraries (insert sizes around 370 and 600) , but some is from an early MySeq run (2×300bp), used to confirm that the libraries were good before the HiSeq run.  In class, we decided to seek a NextSeq run (2×250bp), either with the same libraries or with a new one, so that we could get more data quickly (we can get the data by next week, rather than waiting 2 or 3 weeks for a HiSeq run to piggyback on).  With the new data, we’ll have more than enough shotgun data for making the contigs.  The mate-pair libraries for scaffolding are still not ready (they’ve been failing quality checks and need to be redone), or we would run one of them on the NextSeq run.  We’ll probably also do a transcriptome library (in part to check quality of scaffolding, and in part to annotate the genome), and possibly a small-RNA library (a UCSC special interest).

The applied electronics lecture had a lot to cover, because the material on hysteresis that was not covered on Monday needed to be done before today’s lab, plus I had to show students how to interpret the 74HC15N datasheet for the Schmitt trigger, as we run them at 3.3V, but specs are only given for 2V, 4.5V, and 6V.  I also had to explain how the relaxation oscillator works (see last year’s blog post for the circuit they are using for the capacitance touch sensor).

Before getting to all the stuff on hysteresis, I had to finish up the data analysis for Tuesday’s lab, showing them how to fit models to the measured magnitude of impedance of the loudspeakers using gnuplot.  The fitting is fairly tricky, as the resistor has to be fit in one part of the curve, the inductor in another, and the RLC parameters for the resonance peak in yet another.  Furthermore, the radius of convergence is pretty small for the RLC parameters, so we had to do a lot of guessing reasonable values and seeing if we got convergence.  (See my post of 2 years ago for models that worked for measurements I made then.)

After the overstuffed electronics lecture, I had to move to the next classroom over and give a guest lecture on protein structure.  For this lecture I did some stuff on the chalk board, but mostly worked with 3D Darling models. When I did the guest lecture last year, I prepared a bunch of PDB files of protein structures to show the class, but I didn’t have the time or energy for that this year, so decided to do it all with the physical models.  I told students that the Darling models (which are the best kits I’ve seen for studying protein structure) are available for check out at the library, and that I had instructions for building protein chains with the Darling models plus homework in Spring 2011 with suggestions of things to build.  The protein structure lecture went fairly well, but I’m not sure how much students learned from it (as opposed to just being entertained).  The real learning comes from building the models oneself, but I did not have the luxury of making assignments for the course—nor would I have had time to grade them.

Speaking of grading, right after my 2 hours of office hours (full, as usual, with students wanting waivers for requirements that they had somehow neglected to fulfill), I had a stack of prelab assignments to grade for the hysteresis lab.  The results were not very encouraging, so I rewrote a section of my book to try to clarify the points that gave the students the most difficulty, adding in some scaffolding that I had thought would be unnecessary.  I’ve got too many students who can’t read something (like the derivation of the oscillation frequency for a relaxation oscillator on Wikipedia) and apply the same reasoning to their slightly different relaxation oscillator.  All they could do was copy the equations (which did not quite apply).  I put the updated book on the web site at about 11:30 p.m., emailed the students about it, ordered some more inductors for the power-amp lab, made my lunch for today, and crashed.

This morning, I got up around 6:30 a.m. (as I’ve been doing all quarter, though I am emphatically not a morning person), to make a thermos of tea, and process my half-day’s backlog of email (I get 50–100 messages a day, many of them needing immediate attention). I cycled up to work in time to open the lab at 10 a.m., then was there supervising students until after 7:30 pm. I had sort of expected that this time, as I knew that this lab was a long one (see Hysteresis lab too long from last year, and that was when the hysteresis lab was a two-day lab, not just one day).  Still, it made for a very long day.

I probably should be grading redone assignments today (I have a pile that were turned in Monday), but I don’t have the mental energy needed for grading tonight.  Tomorrow will be busy again, as I have banana-slug genomics, a visiting collaborator from UW, the electronics lecture (which needs to be about electrodes, and I’m not an expert on electrochemistry), and the grad research symposium all afternoon. I’ll also be getting another stack of design reports (14 of them, about 5 pages each) for this week’s lab, to fill up my weekend with grading. Plus I need to update a couple more chapters of the book before students get to them.

2015 April 21

Loudspeaker lab went well

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

I’m falling behind in my blogging about the applied electronics class, and so the notes on the lectures may be a bit skimpy.

Last Friday, I had several topics:

  • Some metacognition talk about answer-getting vs problem solving, with an emphasis on the descaffolding (removing the detailed what-to-do instructions and worksheets) that needed to happen as undergrads, and how too many of their classes had not been doing it, so I had to descaffold them faster than was really optimal.  I warned them that this would be uncomfortable.
  • Test equipment as part of the circuit. One of the main points of the lab they had just completed the day before was to make them aware that test equipment (like oscilloscopes) become part of the circuit that they are testing, and can affect that circuit. I’d not made that clear in the book (there is a chapter that needs a massive rewrite this summer), so I spent some time in class on the idea.
  • Inductors.  I didn’t do much with magnetic fields, but I did give them V= L \frac{dI}{dt} and derived the impedance j \omega L.  There was an unplanned digression about transformers, in response to a question. I did have students give me the impedance of a resistor in series with an inductor, which they had to plot vs. frequency as one of their pre-lab assignments over the weekend.
  • Loudspeakers. I showed them a labeled diagram of a loudspeaker, and the magnetic field near the voice coil. I reminded them of the EMF right-hand rule, and showed them how current through the voice coil would push the voice coil up or down (in the orientation of the pictures).
  • I then quickly went over measuring the magnitude of impedance with a frequency generator and a pair of  AC voltmeters. This is almost identical to the lab they just did for DC characterization of a microphone, but I would have liked to spend more time on it.

The students did a prelab exercise over the weekend, but I forgot to tell them to do the prelab exercise for Thursday’s lab as well as Tuesday’s, so I had to tell them that in class on Monday (assigning it for Wednesday).

Monday’s lecture was supposed to cover several topics, but I didn’t get to them all:

  • feedback on the previous week’s design report.  This took far too long, in part because I went over some fundamentals—I’m not sure, based on their writing, that all the class understands the difference between voltage and current. I introduced the hydraulic analogy (voltage=pressure difference and current=flow), but I’m sure that there are still several who think of both voltage and current as some incomprehensible measure of “electricity”.
  • Another fundamental that came up as a result of the report is what a “model” is.  Too many people had been trying to stick voltmeters into the middle of the model for the loudspeaker.  I think that the physics classes are doing a poor job of getting students to think in terms of models, but I’ll do what I can to remedy the deficit.
  • I also spent some time on writing fundamentals, like who the audience is for a design report, and that the document must be written for someone who does not have the book or the assignments.  Students are so used to fill-in-the-blank answers that they often don’t get the idea of a self-contained report—but that is what they will have to create as engineers, so they need to start learning how to do it. I had a full page of notes on feedback for the students, much of it specific to the writing assignment I was returning.
  • I went over how to determine the shunt resistor for the current measurements in the loudspeaker lab. I was surprised to find out that most had never heard of a geometric mean and had no idea that it was the appropriate way to average numbers when errors were measured by ratios not by differences. I’m not sure that the idea came across well, because I had not anticipated having to teach them that part of high school algebra (silly me—they’ve needed to be retaught everything else they should have learned in high-school algebra, so I should have known that they would never have heard of geometric means).
  • I never did get to the main topic for the day: hysteresis.  I’ll have to cover both model fitting and hysteresis on Wednesday, though I’d only originally planned to do model fitting.  Fitting the models for the loudspeaker is a bit tricky, since the main R and L values have to be fitted away from the resonance peak, then the resonance peak needs to be fitted on just that region. I hope that there is enough time on Wednesday to cover hysteresis and relaxation oscillators as well as the model fitting.

Lab today went fairly smoothly.  Everyone managed to get good data from 3Hz to 1MHz, with lots of data around the resonance peak, so they have good data for fitting models to.  There were three problem loudspeakers: Two had bad insulation-displacement connectors on the ends of cables to the loudspeakers.  They didn’t fail as open circuits, but as about 70Ω resistances that remained fairly stable until the wire was jostled.  This meant that the students had inconsistent results that were hard to debug. I think that the cheap connectors were slightly oversized for the wire, so that there was not a gas-tight connection and some corrosion had formed between the wire and the connector.  I finally managed to figure out what was going on for one of the groups, and a little while later applied the same thinking to another group.  Unfortunately, it was getting rather late by then, so that group only got one of their two loudspeakers characterized—they’ll probably try to finish up on Thursday, after doing the next lab.

The third problem loudspeaker behaved normally as far as resistance was concerned, but its resonant peak was nowhere near where it was supposed to be.  Instead of a resonance at 137Hz (as reported on the data sheet), it was out around 700Hz—way too high for a mid-range loudspeaker.

Incidentally, I was wrong about which loudspeakers the staff had bought this year—they got the 15W midrange speaker rather than the slightly cheaper 5W one, so we don’t need to worry about burning out loudspeakers on the power-amp lab.

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

« Previous PageNext Page »

%d bloggers like this: