# Gas station without pumps

## 2014 April 30

### Loudspeaker analysis

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

In class today, we analyzed the data that the students collected yesterday in the loudspeaker lab.

I used gnuplot to work through several model fits to the magnitude of impedance as a function of frequency.  The first one was a simple L+R model (though later we got even simpler with just R=8Ω). I showed the difference between fitting Z and fitting $\log(Z)$.

The model clearly was a poor fit, though it has roughly the right shape, with a sort of constant region for a while, then rising impedance with frequency.

I next introduced $(L_{s}||C_{s}||R_{s})$ for the resonance peak, and showed how to fit those parameters without changing R or L for the main model, both by limiting the frequency range and by specifying only the parameters we wanted to optimize.  After fitting the resonance peak, I refit R and L over all the data.  This model did a decent job for lower frequencies, but still had problems at high frequencies.

I then mentioned one hack (that I have played with in the past) that is commonly used to model loudspeakers, of adding more “knees” to the curve to get a wobbly line that tracks the data a little closer.  I did not try to develop this in class, since we have no particular need to stick with standard linear components.

Instead I introduced them to a non-linear inductor, whose impedance is $j \omega^{\alpha} L$ instead of $j \omega L$, and fit that after fitting the resonance peak.  (This is the same model I developed in Better model for loudspeaker, though the parameterization may be slightly different.)

Here is the plot we produced (note that it was not properly labeled—I expect the students to be able to do that themselves by now):

Final fit developed in class today. I’m pretty happy with how close a fit we get with only 6 parameters.

I also mentioned the concept of a semi-inductor (the formula above with $\alpha=0.5$), and showed them how that fit (OK, but not as good as $\alpha=0.627$).

The model-fitting took a little longer than I had expected.  I’d wanted to spend 45 minutes on it, but spent more like 55.  I think that the lessons on how to fit parameters when they affect just part of the curve (as for the resonance peak), and the basic lesson that there are no true models, just more or less useful ones, were worth the time, though. We talked a little about when each of the models we used might be useful.

The R=8Ω model came up as being a useful one for signals between 200Hz and 10kHz—most of the audio range of interest for speech, but not so useful near the resonance peak or for high frequency.  I pointed out that we’d want to know the characteristics of the loudspeaker at high frequency later this quarter for the class-D power amp lab, which was why I went so far as to introduce non-textbook non-linear devices like the generalized inductor.

In the last 15 minutes of the class, I managed to talk a little about discrete values and discrete time, explaining what made a 16-bit ADC 16 bits, and emphasizing again the distinction between resolution, repeatability, and accuracy (resolution is 1LSB, repeatability for the ADC converters on the board we are using is about ±4LSB, and the accuracy is about ±3%, though the accuracy can be improved by external measurement of the reference voltage).

I only briefly mentioned sampling and aliasing, which they will be examining in tomorrow’s lab.  I’m hoping they read the handout, as that has some of the explanation missing from today’s lecture.  I’m still trying to decide whether to bring the stroboscope into lab as a demo.

Despite not covering aliasing and the Nyquist theorem today, I was pretty happy with how the class went.

Here is the gnuplot script developed in class today (it was all typed live in class without notes—hence the lack of comments and other niceties). Code was modified in place as we went through the different models, so many of the initial fits are not shown here.

j=sqrt(-1)

zc(f,c) = 1/(j*2*pi*f*c)
zl(f,l) = j*2*pi*f*l

zsemi(f,l,alpha) = j * (2*pi*f)**alpha *l

zpar(z1,z2) = z1*z2/(z1+z2)  # parallel impedances

rlrlc(f, R, L, rs, ls, cs) = abs(R + zl(f,L) + zpar(zl(f,ls), zpar(zc(f,cs), rs)))
rlarlc(f, R, L, alpha, rs, ls, cs) = abs(R + zsemi(f,L,alpha) + zpar(zl(f,ls), zpar(zc(f,cs), rs)))

set logscale xy

R=8
L=10e-3
alpha=0.5

rs=15
ls =1e-3
cs = 1e-3

fit [50:500] log(rlarlc(x,R,L,alpha,rs,ls,cs)) "10W-loudspeaker-47ohm-more.data" using 1:(log($3/$2 *Rload)) via rs,ls,cs

fit log(rlarlc(x,R,L,alpha,rs,ls,cs)) "10W-loudspeaker-47ohm-more.data" using 1:(log($3/$2 *Rload)) via R,L,alpha,rs

set samples 1000

plot "10W-loudspeaker-47ohm-more.data" using 1:($3/$2 *Rload) notitle, \
rlarlc(x,R,L,alpha,rs,ls,cs)  title sprintf("%.3f ohm + %.3eH (^%.3f) + (%.3fohm || %.2fmH || %.2fuF)", R, L, alpha, rs, ls*1e3,cs*1e6)


## 2014 April 29

### Loudspeaker lab

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

The loudspeaker lab was a new one this year, but I think it went fairly well.  Students set their measurements up quickly, because the ideas were essentially the same as for the electrode lab.  Because there are fewer measurements to make with the loudspeaker (only one loudspeaker to measure, not several different concentrations), this lab is actually quicker than the electrode lab.  I think that next year I should move the loudspeaker lab before the electrode lab.

I did make one mistake—I had included a bonus section to characterize some ferrite-core inductors, but I forgot that the students did not have the inductors in their parts kit—I had bought them myself last year, and just brought them in for the class-D power amp lab.  I left them at home today, so students could not do that bonus lab. I did remember to bring in my speaker, which was a good thing, because the student working without a partner this week also forgot to bring the parts kit.  I was able to lend out my speaker and another student loaned a breadboard, so the lab still got done.

All the students managed to complete their data measurement (most of them finishing early), and I managed to get all the students to plot their data as they collected it (or, at least, to alternate collecting a bunch of points then looking at them).  Looking at the data allowed them to get several data points right around the resonance peak, and to spot anomalies in the data right away, and go back and remeasure data points near the anomalies (many of which were transcription errors in recording the data by hand).  I’m hoping that students get into the habit of checking their data as they collect it, but that is probably too much to expect from students who were not doing even the most trivial of sanity checks in previous labs.

One pair of students got very weird data for their loudspeaker, but I could not find anything wrong with their test setup, and I confirmed the measurements using a different instrument ( a digital scope rather than the digital multimeters), so I suggested that they try again with a different loudspeaker.  They did that, and got the expected results with the other speaker.   The bad speaker had a normal DC resistance (around 7Ω) but had an impedance around 20 Ω at frequencies below the resonance. Above the resonance, instead of quickly leveling off at 8Ω, the impedance dropped slowly to 8Ω and immediately went back up, without the usual wide flat region. I have no idea what might cause this unusual behavior.

Tomorrow in class, I have two topics to cover:

• fitting the model L+R+(C2||L2||R2) to the data (and why we can’t really get it right—though I don’t have a good physics explanation for why the impedance goes up more slowly than the first power of frequency).  I asked the students to try to do the fitting before class, so that we can concentrate on the tricks for fitting the two regions separately before combining them.
• sampling and aliasing, which is Thursday’s lab.  There is not much to write up in Thursday’s lab, which should help compensate for the time they’ll be spending on redoing the quiz as homework.

### Inductors and loudspeakers

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

On Monday I gave a little pep talk about the quiz before returning them.  I also assigned the students to redo the entire quiz  as homework due Friday, saying that we’d already gone over most of the material in class, so there wasn’t much point in my showing them again—they needed to do it themselves.  (Engineering is not a spectator sport!)

After returning the stuff I’d graded over the weekend, I talked to them about inductors doing a rather hand-wavy derivation of $V = L \frac{dI}{dt}$.  There is much more detail in this week’s lab handout, but I’ve found that students in the circuits class do not seem to be able to absorb much information in written form—a shame really, since that is how most of their future learning is going to have to happen.  I fear that most of them are going stop learning the moment they leave college, and then they’ll be stuck with obsolete knowledge and no way to remedy the problem within five years.

I also talked about loudspeakers: how they work and what the impedance vs. frequency curves look like.  They’ll be gathering data for their own loudspeakers today, so I wanted them to be aware of the existence of the resonance peak and the need to gather a lot of data around the peak in order to model it.

I did talk to them about the basic $R+ j\omega L$ curve for any inductor (with R due to the resistance of the wire), and about the resonance peak from the mass+spring harmonic oscillator that is the voice coil, cone, and suspension.  I derived the frequency of an L||C resonant circuit (by computing the impedance and seeing where it went to infinity), and gave  a rather hand-wavy explanation of the effect of adding a resistor in parallel.

## 2014 April 27

### Ridiculous excuses for canceling show

Filed under: Uncategorized — gasstationwithoutpumps @ 09:09
Tags: , ,

One of the most ridiculous excuses from a school official I’ve ever seen was published this week in the Washington Post:

April 25, 2014

Dear Kindergarten Parents and Guardians,

We hope this letter serves to help you better understand how the demands of the 21st century are changing schools, and, more specifically, to clarify, misperceptions about the Kindergarten show. It is most important to keep in mind is [sic] that this issue is not unique to Elwood. Although the movement toward more rigorous learning standards has been in the national news for more than a decade, the changing face of education is beginning to feel unsettling for some people. What and how we teach is changing to meet the demands of a changing world.

The reason for eliminating the Kindergarten show is simple. We are responsible for preparing children for college and career with valuable lifelong skills and know that we can best do that by having them become strong readers, writers, coworkers and problem solvers. Please do not fault us for making professional decisions that we know will never be able to please everyone. But know that we are making these decisions with the interests of all children in mind.

It seems that the kindergarten teachers at Harley Avenue Primary School in Elwood, N.Y. did not want to do yet another kindergarten school play.  I can’t say I blame them—herding kindergartners and getting them to perform is a lot of work, and even kindergarten teachers can get burned out on it.  But the excuse they use, “preparing children for college and career,” is so ridiculous that it would be regarded as absurd if presented in a play or novel.

Kindergarteners are supposed to be being prepared for elementary school, not for college, and theater is excellent preparation for many careers (any that involve public presentations, for example), anyway.

My son started enjoying acting in preschool and has been on stage (or on film) in about 70 productions since then. The school plays were not as good, generally, as the ones he did in summer or after-school productions, but they were still highly valued parts of his education.  His senior year of high school alone has seen 10 different performances, and he still has another improv show and playing Don John in Much Ado to come—and that’s just during the school year, not summer theater.

Theater has gotten him through high-school English classes that he would otherwise had difficulty tolerating—about half his high school English has been dramatic literature classes.  Conventional literary analysis irritates him, triggering writer’s block, but he can work on fairly deep analysis to do character development for performance.

## 2014 April 26

### SIR!

Filed under: home school — gasstationwithoutpumps @ 22:33
Tags: , , , ,

Some readers of my blog and e-mail posts have been asking where my son will be going to college.

He filed his “Statement of Intent to Register” (SIR in UC jargon) and paid the deposit for University of California, Santa Barbara.

This post is a partial explanation of why he chose UCSB. I’m somewhat constrained, as I’ve been asked not to detail precisely where he did and did not get accepted. Suffice it to say that the number of acceptances was not different enough from the expected number to reject the null hypothesis that acceptances are random based on the probabilities inferred from the Common Data Set.  (Of course, with a sample size of one, that is not a very strong statement.)

As a family, we’re all pretty happy with UCSB as a choice, despite its reputation as a party school, the conservative community, and the difficulty of reaching it by air from northern California. What sold him on UCSB was the College of Creative Studies (CCS), which seems to be the best honors program in the UC system.

His major will be computer science, but it will be computer science in CCS, rather than computer science in engineering. What this means is that he basically crafts his own degree together with a faculty adviser. In his first quarter, he’ll take a special CCS freshman seminar with the other 10 or so CCS computer science freshmen, during which the instructor will try to assess the current level of expertise of each student and fill any holes they have in their prior learning, to place them in the right CS courses in future quarters.  The class is tiny (usually around 10 students) so the instructor doesn’t have to do one-size-fits-all teaching or advising. Because my son has already had UC-level applied discrete math (through concurrent enrollment at UCSC), he’ll be able to take upper-division courses like formal languages and automata theory right away. In fact, I suspect that he’ll end up skipping almost all the lower-division courses in CS.  He may end up opting to take some of them for review, or so that he’ll have an easy course on his schedule so that he has more time for research or acting, but he won’t be forced into huge lecture classes that have nothing new for him in them.

I looked over the lower-division (first two years) of CS at UCSB and it looks like my son has covered almost all of it already. He’s had several different programming languages (Scratch, C, Scheme, Python, Java, with bits of C++, JavaScript, Logo, assembly language), though he is most proficient now with object-oriented code in Python. One course (CMPSC 56) may have a little new material on exception handling and threading, and he might choose to take something like that to formalize his knowledge—when one learns a subject by reading reference manuals to do particular programming tasks there are sometimes unexpected holes in what you learn.  He’s done a fair amount with threading in Python, but not a lot with exception handling. CMPSC 64, on computer architecture and digital logic also has some new material for him.  The computer architecture will seem fairly simple to him after how deeply he’s been diving into the KL25 ARM Cortex M0+ architecture for programming both PteroDAQ and the light gloves, but some of the combinational and sequential hardware design will new.

One strong plus is that he’ll be able to join a research team his first year—CCS makes a concerted effort to get their students into research groups (in fact, one faculty member he met with when visiting UCSB has already tried to recruit him to a project). The UCSB computer science department is pretty good (their website claims top 10 for grad programs, but even allowing for hype they are probably in the top 20), and the department is fairly large with 32 tenure-track faculty, so there are a lot of different research projects he could join.  Computer engineering is lumped with EE in Electrical and Computer Engineering at UCSB, so there are more faculty and more research projects he could join there.

Another plus of the CCS program is a relaxing of the often bureaucratic nit-picking of general-education requirements. The CCS general-ed requirements are

1. two courses in fields related to the student’s major, as determined in consultation with a CCS advisor;
2. eight courses broadly distributed in fields unrelated to the student’s major, as determined in consultation with the advisor. These may be selected from courses offered by the College of Creative Studies, the College of Letters and Science, and the College of Engineering.

One of these courses must fulfill the Ethnicity Requirement: a course that concentrates on the intellectual, social and cultural experience, and history of one of the following groups: Native-Americans, African-Americans, Chicanos/Latinos, Asian-Americans. This course may be selected from a list of courses that fulfill the Ethnicity Requirement offered through the College of Letters and Science, or it may be a College of Creative Studies course that is classified as such.

Students also have to satisfy UC-wide requirements:

The reduction in bureaucratic bean counting means that he can probably satisfy all his general-ed requirements with fun courses in theater, linguistics, physics, math, and so forth.  The only rather arbitrary course is the Ethnicity Requirement, and he can satisfy that with any of several courses, including some theater ones.

One minor problem (shared by almost every college he applied to) is that he gets little relevant credit for his Advanced Placement exams. He’ll probably get 18 credits toward graduation (out of the 180 needed to graduate), but not all the units count towards his major requirements. He gets full credit for the calculus BC, but physics gives only useless non-STEM physics credit for the Physics C exams, the AP CS exam credit is pretty useless, and I’m not sure about chemistry (the page says “Natural Science 1B”, but there does not seem to be such a course—if they mean “CHEM 1B”, then it is useful credit towards his science requirements, assuming he does well enough on the exam in 2 weeks).  Because he is interested in taking some modern physics (quantum mechanics), he’ll probably end up either retaking calculus-based physics or talking his way into the more advanced courses and bypassing the huge lecture courses.

He should also get transfer credit for the community college Spanish courses and the UCSC math courses he has, which could mean another 16–18 credits.  These extra credits will not significantly speed his graduation, but they may give him the flexibility to avoid taking a heavy load some quarter, or to take an internship or study-abroad opportunity without falling behind. One normal benefit to having more credits is getting registration priority, but he already gets that as a CCS student, so that is less of a benefit for him than for others.

One little bonus for us as parents—UCSB is substantially cheaper than the private schools he also applied to, and we have saved enough in his 529 plan that we won’t need to take out any loans and he won’t have to work a meaningless job—he can spend his spare time doing research projects at the University or working on engineering projects for the startup company he and his friends are forming.

Next Page »

Blog at WordPress.com.