Gas station without pumps

2014 June 4

Random topics in class today

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

Since students have started on their last lab, there is no more material that I have to cover, so I threw today’s lecture open for questions.  I had prepared some material on Wien-bridge oscillators, in case no one had any questions, but we filled the time with stuff they were confused about from earlier in the quarter.  In roughly the order I covered them, we talked about

  • FETs. I showed the cross-sections of nFETs and pFETs, explained the “back gate” or substrate connection and why it was tied to the source on the power FETs. I also talked about the flyback diodes and why they are needed when driving inductive loads.  This also gave me an opportunity to talk about how ignition coils on cars work.
  • PWM. I redid a lecture that had not gone over well the first time, talking about how the rectangular voltage pulses turn into up and down ramps for current in an inductive load, and how duty cycle gets converted to current level.  I still think I could do a better job of the PWM talk, but the students were feeling better about understanding how their class-D amplifiers worked.
  • I also introduced H-bridges for DC motor speed control, and showed how PWM could control the motor to turn forward or backward at different average current levels.
  • A student asked about how the gain in theirpreamp affected thefinal output loudness, so I redrew a part of the comparator function from their lab handout:
    Example of comparator output comparing a slow signal from a preamp and a fast triangle wave to get a pulse-width modulated wave.

    Example of comparator output comparing a slow signal from a preamp and a fast triangle wave to get a pulse-width modulated wave.

    I then showed how a small signal centered at the same voltage as the triangle wave would produce a 50% duty cycle, with only small fluctuations from 50% as the signal went up or down.

  • Finally, I reviewed sampling and aliasing, explaining where the beat patterns they saw in their lab came from.  I think I need to provide more on that earlier in the quarter, as they did not seem to get as much from the sampling and aliasing lab as I had hoped.

Tomorrow is the last lab (unless students request extra time in the lab to redo something next week), and I expect all the students to finish their EKG soldering.  I did remember to suggest that everyone solder a board, so that they could have one to demo to people, but we’ll see how many takers there are tomorrow.

On Friday, I’ll once again take questions, but I’ll still have the Wien-bridge oscillator to present if they don’t have anything to ask.

 

2014 May 1

Sampling and aliasing lab

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 21:30
Tags: , , , , , ,

Yesterday, I only briefly mentioned sampling and aliasing, which was the subject of today’s lab.  I was hoping they would read the handout, as that has some of the explanation missing from the lecture. That, as usual, turned out to be a forlorn hope. Some of them did read the handout, but not in a way that gained them any comprehension, and no one had done the prelab exercises, so the first hour (or more) of lab time was spent with students trying to figure out how to do a high-pass filter that did level shifting, so that the output would be in the 0–3.3V range of the analog-to-digital converter.  They all got to reasonable designs eventually (with capacitor values in the range 4.7µF to 470µF—I really like that the answer is not dictated by having only a small selection of components!).  I did have to re-teach Thévenin equivalents to some of the teams, as they were not getting the RC time constants that they claimed.

The level-shifting high-pass filter design will be useful again next week, for connecting the microphone to an op-amp audio amplifier.

I did not bring the stroboscope into lab as a demo—the demo had not worked all that well last year, and the students have all seen stroboscopes before.

PteroDAQ worked well for doing downsampling, and students recorded several waveforms.  I’ll see whether anything sensible is said about them in this week’s lab reports.  At least they had fun looking at the weird beat patterns you get if the signal you are looking at is close to the Nyquist frequency.

I also got the data today from the students who had a loudspeaker that behaved differently from everyone else’s on Tuesday (they tested another loudspeaker with the identical setup and got normal results, and I checked a few of their measurements—I believe they did just have a weird speaker).  There was a little metadata missing (like exactly what their fixed resistor was for converting current to voltage), but I was able to fit their data with just two more parameters on the model, a resistor and capacitor in parallel with each other, in series with the rest of the model:

    The bad loudspeaker has a higher than expected resistance at low frequency, then a 1/f-sloped region after the resonance peak, then a return to normal behavior. I modeled this loudspeaker by adding an extra R||C in series with the model we used for good loudspeakers.

The bad loudspeaker has a higher than expected resistance at low frequency, then a 1/f-sloped region after the resonance peak, then a return to normal behavior. I modeled this loudspeaker by adding and extra R||C in series with the model we used for good loudspeakers.

I have no explanation for the physical or electrical causes of an extra R||C in the loudspeaker.

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.

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

Rload = 47.171
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)

2013 February 21

Sampling lab went ok

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 21:14
Tags: , , , , ,

Today’s sampling and aliasing lab was one I expected to go fairly quickly, but it took longer than I thought.  The students had two design tasks and then a bunch of observations. The design tasks were supposed to have been easy ones that they did as a prelab, but everyone took a bit longer than I thought, and some really struggled with them.

The first design task was to design a high-pass filter to do level shifting of a signal from a signal generator (the signal generator is capable of being set to center at a voltage other than 0v, but I needed students to practice level shifting before they do the class-D audio amplifier and the EKG labs).  I gave them a very low corner frequency (0.03Hz).  Students didn’t have trouble with the RC time constant (mostly), but they did have trouble with the notion of using a voltage divider as a Thévenin equivalent of a resistor to the desired center voltage, though we had just done that yesterday in class in analyzing the do-now problems.  I think that they all got it in the end, but I’ll definitely have to consider including some sort of level-shifting question on the quiz.

They looked at the signal output from the high-pass filter using the scope (to make sure that the voltage range was appropriate), then hooked it up to the Arduino and ran the DataLogger code.  I had them run the signal into two pins, with one sampling at 40Hz or 50Hz and the other at 1/5 that (8Hz or 10Hz), and then look at various frequencies.  I may have to specify some specific frequencies for them to look at next year, since they tended to pick simple multiples of 1Hz, which does not reveal some of the interesting beat patterns that you get at 4.9Hz and 5.1Hz.  The DataLogger code worked quite well for this application, though one student managed to tickle an error message by leaving the down-sampling field blank (it should probably default to 1 in that case, rather than reporting an error).  One could do all the visualization with a purely software simulation lab, but the students learned a fair amount by designing and wiring the RC filters, as well as getting more experience with the oscilloscopes and function generator.

The second design task was to design a low-pass filter with a corner frequency of 4Hz.  For this one, most of them chose to do a 2.5v virtual ground with an op-amp circuit, though there was no need, since the capacitor blocks any DC and so could have been connected directly to ground. Using a virtual ground actually makes it harder to use the electrolytic capacitors without reverse biasing them.  This may get to be important in the LC filter for the class-D amplifier, so I’ll probably have to talk about proper biasing of electrolytic capacitors in class.

I did do the strobe demo at the beginning of lab time, but it was not as good a demo as I had hoped to do.  I’ll have to think of ways to improve it for next year.  Problems included that the strobe light was not bright enough (you can’t turn off all the lights in the lab) and that the spinning paper propeller did not have an adjustable speed, so I couldn’t match the propeller to the strobe (just the strobe to the propeller).  Perhaps I need to choose a better moving object next year, where the strobe light will have a more obvious relationship to the sampling of sine waves in the rest of the lab.

Tomorrow I’ll need to start teaching about instrumentation amps, and get the students to choose lab partners to work with over the weekend, so that they can come in with questions on Monday, since the first instrumentation amp lab is likely to cause them problems.

 

 

2013 January 14

Weekend work

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

I just realized that I blogged about today’s class, but not about what I spent my entire weekend doing: writing up the lab handout for the hysteresis lab. I decided to swap the hysteresis lab (which had been in week 6, after the op amp lab) with the sampling and aliasing lab (which had been in week 4).  This isn’t because the hysteresis lab is simpler, but because I knew what I wanted students to do for it.

I spent the entire weekend redoing the lab, rewriting the software for the Arduino that converts the period of the hysteresis oscillator into an on/off decision, and writing up the tutorial on hysteresis along with the procedural instructions for the lab. I’m kind of pleased that I used hysteresis in the software as well, illustrating that the concept is a general one, not specific to the implementation with a Schmitt trigger. The software does an auto-detect of the pulse widths whenever the board is reset (since I don’t know what frequency the students will aim for), but that auto-detect is not as robust as I would like.  I decided not to mess with it, since I wanted code that was simple enough for students to read (and there is no programming prerequisite for this course).

Ah—I just figured out why the auto-detect is not robust!  The reset of the Arduino is slow, and the auto-detect adds another 1/3 of a second to that, so I was often not waiting long enough before touching the sensor, contaminating the auto-detect of the “untouched” frequency with some of the “touched” frequency.  I added a triple flash of the LED at the end of the autodetect, so that students can know not to touch the sensor after a reset until they see the triple flash.  I’ve updated the code and the lab handout on the web site to reflect this change.

I decided not to write up instructions on how to solder, as there are hundreds of perfectly good tutorials about soldering on the web, and students are unlikely to pick a bad tutorial by accident.  We now have soldering in labs 4, 9, and 10.

I tried soldering up one of the boards myself on Sunday, to make sure that they came out ok. They do, and the soldering is fairly easy.  There are a few places where beginners are likely to make solder bridges, but I did include solder suckers in the tool kits for them, so corrections should be easy.

The capacitive touch sensor, the hysteresis oscillator board, and an Arduino board. I included this picture (at higher resolution) in the lab handout, but carefully covered up the color codes on the resistor, as choosing the resistor and capacitor values is the main design challenge of the lab.

The capacitive touch sensor, the hysteresis oscillator board, and an Arduino board. I included this picture (at higher resolution) in the lab handout, but carefully covered up the color codes on the resistor, as choosing the resistor and capacitor values is the main design challenge of the lab.

The capacitance touch sensor in the picture is made out of aluminum foil and packing tape. One of the pre-lab exercises is to estimate finger-touch capacitance from the thickness of the tape, the dielectric constant of the polypropylene tape, and the contact area. One of the post-lab exercises is to estimate the capacitance from the frequency shift of the touch. I tried doing this and got reasonably similar results (given how much variation there is in the capacitance based on how firmly you press your finger against the sensor, increasing the area of the contact).

Panavise Jr.

Panavise Jr. that I started using this weekend—a much nicer board holder. I got this picture from one of the companies that sells it (I forget which one).

PCB holder from the web—the one I have is this model, but is rusty and has some dings in the ring that holds the lens. I got this picture off the web, but I forget from where (I carelessly copied it without citation).

PCB holder from the web—the one I used to use is this model, but is rusty and has some dings in the ring that holds the lens. I got this picture off the web, but I forget from where (I carelessly copied it without citation).

One thing we don’t have in the lab, though are board holders for soldering. I wonder whether we can borrow them from other labs for these three labs, or whether there are few enough around the labs that we couldn’t get enough anyway. I just bought myself a Panavise Jr., which is much easier to use than the old alligator-clip-and-swivels that I used to use.

The hysteresis oscillator board is easy enough to solder on the benchtop without a holder, but the more densely packed instrumentation-amp protoboards for weeks 9 and 10 will be much easier with a holder.

The next handout that needs to be written is for lab 5, the op-amp lab. That one should be fairly straightforward, and then I’ll have to get back to worrying about the sampling lab. I’m beginning to think that the sampling/aliasing lab should be a combination of the usual demo of aliasing (which students do need to play with) and the design of a simple RC-voltage divider as a low-pass filter. I think that with some small changes to the data logger (allowing down-sampling of some of the analog inputs), we can do the demo on the Arduinos using slow waveforms from the signal generator. I want to come up with some meaningful signals to use as inputs, though.

« Previous Page

%d bloggers like this: