# Gas station without pumps

## 2017 June 28

### Changing the loudspeaker lab

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

I’ve started looking at how the loudspeaker lab in the applied-electronics course will change, given that we will have the Analog Discovery 2 USB oscilloscope in the labs.  There are two main changes in capabilities:

• hundreds of measurements can be made in a couple of minutes from 10Hz to 1MHz
• phase information is available, not just amplitude information.

The availability of phase information means that we can try fitting complex impedance, and not just the magnitude of impedance.  Unfortunately, the gnuplot curve fitting that we’ve been using is only set up for fitting real-valued functions, not complex-valued ones, and I don’t really want to switch to a more full-featured model fitting program, as they get hard to use.

Today I gathered data from two loudspeakers: the tiny 1cm one that I have posted about before (Ultrasonic rangefinder tests with tiny loudspeaker and Redoing impedance test for tiny loudspeaker) and an 8Ω oval loudspeaker that we used to use in the class until Parts Express sold out of them (Loudspeaker analysisBetter model for loudspeaker). I only collected data out to 1MHz, since my previous experience indicated that the network analyzer was not very useful past that frequency (Loudspeaker impedance with Analog Discovery 2). I put a 22Ω resistor in series with the loudspeaker and measured the voltage across it on channel 1, with the voltage across the loudspeaker on channel 2.  I recorded the “gain”, which is channel2/channel1, and the phase for channel 2 relative to channel 1.  The gain times 22Ω is the magnitude of the impedance of the loudspeaker.

The formula that I’ve been using for impedance modeling, $R + ja\omega^\beta + (R_m || Z_{L_m} || Z_{C_m})$, turned out not to be a good fit for the phase.  I played around for a couple of hours with different, more complicated models, before finally settling on a model that is as simple as the one I’ve been using, but that fits pretty well:

$R + a (j\omega)^\beta + (R_m || Z_{L_m} || Z_{C_m})$

The difference is just that I’m including the j inside the exponentiation, so that the “inductor-like” component is now in direction $j^\beta$ instead of $j$—that is, the asymptotic phase angle is $\sin^{-1}(\beta)$ instead of 90°.

To do the fitting, I alternated between fitting some of the parameters to the magnitude of the impedance and some to the phase. After I had layed around a bit and gotten ball-park estimates of the parameters, I did a more careful fitting. I started by fitting the series R to just the low-frequency end of the data, then fitting the resonance peak without the “inductor-like” component in the model with data collected in just a decade of frequency around the resonance peak (I used a separate data file that had 600 data points for just that decade).  I fit the three parallel parameters using the phase data, then refit the parallel resistance using the amplitude data.  To start in the right region, I set initial values $R_m = R_{peak}-R$, $C_m = 0.3/\omega$, and $L_m = 3.3/\omega$, with $R_{peak}$ being the magnitude of the impedance at the top of the peak, located at frequency $f$, with $\omega = 2 \pi f$.

With those parameters set, I fit $\beta$ with phase information for the high frequencies, and $a$ with amplitude information.

I then tweaked the fit by refitting the resonance peak, refitting $\beta$ and $a$, and repeating the refits.

The 6-parameter fit for the magnitude is pretty good.

The 6-parameter fit for the oval loudspeaker is not great for phase, but is not too bad.

The 6-parameter fit for the tiny loudspeaker is pretty good, though I did not attempt to model the two higher frequency resonances that are visible, despite knowing that the resonance around 9kHz rings seriously.

The resonances are somewhat more visible in the phase plot for the tiny loudspeaker than they are in the magnitude plot.

I’m going to have to write up a tutorial for the book on using a real-valued fitting method for fitting a complex-valued function.

## 2016 December 30

### Ultrasonic rangefinder with Analog Discovery 2

In Loudspeaker impedance with Analog Discovery 2, I looked at the impedance of  various loudspeakers including an ultrasonic transducer. Today I looked at shaping pulse bursts for driving an ultrasonic transmitter to get shorter received pulses with an ultrasonic receiver.  I’ve done this before using custom programs on a Teensy 3.1 board (see Ultrasonic rangefinders arrived), but I wanted to see what I could do using just the waveform generator on the Analog Discovery 2.

I measured the magnitude of the impedance of the transmitter (using either a 120kΩ resistor or a 1nF capacitor as a known impedance), then looked at the transmitter+receiver characteristics for frequencies around the resonances.  I’ve marked the peak received resonances on the impedance plot.

The impedance is approx 2.2nF, with 3 apparent resonances.

The primary resonance is around 40kHz, and is the frequency that the transmitter is designed to operate at.

There is a secondary resonance around 54kHz, though it is considerably weaker than the 40kHz resonance.

The third resonance, around 330kHz does not provide a very strong signal for the receiver.

I tried two tests using the 40.445kHz resonance. In one, I used the simple waveform generator to produce a 40445Hz square wave, then used an 8ms wait and a 148.3µs run time, to produce bursts of 6 square waves. I set the idle output to the offset (0v) and used a 5V amplitude.

In the other test, I used the same wait and run times, but used the “custom” waveform to set up a signal that inverted the last 3 of the 6 periods (so that the half periods were +-+-+--+-+-+. This was fairly easy to set up by generating the 6 periods, then altering them by multiplying by a single period of a square wave. I could have created much more complicated bursts, but this pattern was enough to see the capabilities of the scope.

By triggering the scope on the signal sent to the transmitter (using channel 1), I could average 1000 sweeps to get a very low-noise view of the signal. (I can trigger on the waveform generator itself, freeing up one of the scope channels, but then I can’t average—I think that the averaging relies on interpolating get precise timing of the trigger.)  For plotting, I subtracted off the DC bias (fitted before time 0), as 60Hz interference caused a moderate offset to the signal even after averaging.

The bursts start out the same, but the simple 6-cycle burst results in the received waveform growing for 14 or 15 cycles, while the 3+,3- burst grows for 6–7 cycles and decays very quickly.

I tried some longer and shorter bursts, with the expected result that longer bursts resulted in stronger signals with a longer received burst width. Doing 8 cycles followed by 8 cancelling cycles seemed to produce a reasonable length burst with a fairly strong signal, but I did not explore variants much.

I still think it might be possible to use the phase information to get higher resolution than the approx 7.9mm wavelength, but identifying which pulse of the return waveform is which remains a problem, particularly if there is a complicated reflecting surface that superimposes several differently delayed pulses.

## 2016 December 28

### Headphone impedance with Analog Discovery 2

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 22:41
Tags: , , ,

In Loudspeaker impedance with Analog Discovery 2, I described measuring the impedance of loudspeakers with the network analyzer function of the Analog Discovery 2. In this post, I looked at some new Panasonic headphones that I got myself for Christmas (Panasonic RP-HJE120-PPK In-Ear Headphone, the best-seller on Amazon and the same model my son has, though in a different color).

I have figured out how to use the Waveforms 2015 software a little better now, so I can compute the magnitude of impedance as an extra column in the output (using the “Custom One” optional calculated channel).  This cuts down slightly on the missing metadata from the data files, though I really wish that they would do a dump of the instrument settings as comments at the beginning of the file.

The headphones had essentially the same curves whether in the ear or not in the ear, so I am just plotting the in-ear electrical characteristics.

The headphones are fairly well fit by a simple model: a resistor in series with an inductor.

Zooming into the audio region shows surprisingly little variation in the impedance over the whole audio range. There is a small resonance peak around 2.6kHz, but it is small and broad, nothing like the resonance peaks of loudspeakers.

I had some problems with repeatability of measurements, with curves jumping 0.5Ω up or down, but preserving their shape. I think that the problem is with poor contacts in the breadboard I was using, as I had the same problems earlier characterizing nFETs. The resonance peak around 2.6kHz corresponds roughly with the peak of information content in speech, so slight enhancement there is probably perceived as improved audio quality over a completely flat spectrum. But the enhancement here is tiny, so it may just be the result of flattening the spectrum as much as feasible.

The noise in the measurements probably reflects the small signal levels—I had an 18Ω resistor in series with the 16Ω headphones, and an amplitude of only 25mV across the pair, which gives me only 8.3mV RMS at the headphones.  That means that only 4.2µW of power is being used to generate the sound.  Panasonic claims a sensitivity of 96dB/mW, so 4.2µW should be about 72dB SPL (remember that dB is $10 \log_{10}$ of a power ratio, and $10 \log_{10}$ of an amplitude ratio). The 72dB seems about right for the loudness.  The headphones can supposedly handle 200mW, which would be 119dB—easily loud enough to cause permanent hearing loss.  Perhaps I should have students test their preamplifiers with earbud headphones instead of loudspeakers—the 24mA limit would give 9mW, which would be quite loud in a headphone.

The R+L model does not fit at high frequencies all that well, and the phase relationships are not what one would expect of a pure R+L model:

The phase only gets to 60°, while a true inductor in series with a resistor would have reached 90° and done so somewhat sooner.

Overall, I’m impressed at how flat the impedance is over the audio range. I don’t know how good the headphones are acoustically (especially as my hearing seems to be really down in the 4kHz–8kHz range—signals seem louder to me at 9kHz than at 5kHz), but I’ve no complaints about them so far.

## 2016 December 13

### Loudspeaker impedance with Analog Discovery 2

Filed under: Data acquisition — gasstationwithoutpumps @ 23:12
Tags: , , , ,

One of the features of the Analog Discovery 2 that convinced me to buy it (rather than, say, a Rigol digital scope) was the ability to couple the waveform generator to the scope to do network analysis.  The basic idea of network analysis is to measure voltages at the output and the input of a 2-port network taking their ratio at different frequencies to get the response of the network.

Here is a generic 2-port network with a shared ground. If a sine wave is applied to the input, then the output will also be a sine wave (for a linear network) of the same frequency, but a different amplitude and phase.

If you model a linear system with complex numbers, then the output of any linear network driven by $e^{j \omega t}$ is $A e^{j \phi} e^{j \omega t}$, and the ratio of the output to the input is $A e^{j \phi}$. A network analyzer drives a network with a succession of different sine waves, recording the amplitude ratio $A$ and the phase shift $\phi$ for each frequency.

I haven’t often needed a network analyzer, but I have many times done something very similar: impedance spectroscopy, which looks at the ratio of the voltage to the current at different frequencies. The loudspeaker and electrode labs in the course both do this, but only recording the amplitude ratio, not the phase change, as hand measurements with voltmeters do not provide a way to determine the phase.

Because the network analyzer just takes the ratio of Channel 2 divided by Channel 1 and both are differential input channels, we can use it as an impedance spectrometer.  We just put the device under test (DUT) in series with a known impedance (comparable to the one to be measured), drive the series chain with the waveform generator, and measure the voltage across the two impedances.  We then have $Z_{DUT} = Z_{known} V_{DUT}/V_{known}$.

For example, here is the result of running the network analyzer for an 8Ω loudspeaker with a 33Ω known impedance:

At frequencies above about 1MHz, I don’t believe that the test setup is really measuring the behavior of the loudspeaker.

For impedance spectroscopy, the default display with the amplitude in dB is not particularly friendly, so I saved the data, fitted a model to it with gnuplot, and plotted it:

Loudspeaker model to fit.

Amplitude data and fitted model. Note that the impedance does not rise as fast as a simple inductor for L1 would imply.

Compare the plot above with the hand-measured ones at Better model for loudspeaker or Loudspeaker analysis.  We can see the limitations of the model even more clearly when we look at the phase change:

At low frequencies, the model and the measurements fit well, but at high frequencies, the phase only goes to 50°, not 90° as would be expected of an inductor.

I also measured a tiny 8Ω loudspeaker that I had bought to experiment with ultrasonics (see Redoing impedance test for tiny loudspeaker):

The main resonance around 1390Hz is clearly visible, but there appear to be some higher resonances as well.  We can do a more focussed sweep to see them clearer:

The secondary resonance peaks are clearly visible when we scan a narrower range.

The model for the tiny loudspeaker fits the phase measurements better than for the larger loudspeaker, but the phase still only gets to 66°, not 90°.

I also tried one of the ultrasonic transmitters (see Ultrasonic transmitter impedance again for hand measurements):

With a 33Ω current-sense resistor, the low frequency end of the impedance spectrum is just noise—there is almost no voltage drop across the 33Ω resistor.

Using 1nF capacitor as a reference impedance, rather than a resistor, results in much more comparable voltages across the whole frequency range, and a cleaner impedance spectrum. But at low frequencies, we’re really seeing the impedance of oscilloscope inputs, rather than the ultrasonic transmitter.

For the piezoelectric ultrasonic transducer, the phase spectrum is easier to see the resonances in.

There are some high frequency resonances as well as the main ones.

I also tried using the network analyzer as a proper network analyzer, where the network consisted of the tiny loudspeaker acoustically coupled to  an electret microphone which had a 10kΩ pullup to 5V:

The 9.5–10kHz peak was distinctly audible (even though I’m rather deaf in that range), so the resonance was in the loudspeaker not the microphone.

I get somewhat different results with the larger 8Ω loudspeaker:

I have a much more uniform response across frequencies, but it looks like I get a fairly strong response even at very high frequencies. I wonder if I’m seeing an electrical rather than acoustic coupling.

Finally, the ultrasonic transmitter:

With a 2V amplitude (instead of 500mV) I get a smaller signal from the ultrasonic transmitter. There does not seem to be a peak at 40kHz, where the transducer is normally used.

There is an antiresonance around 39kHz and a resonance around 54kHz. Perhaps it would be better to use the transmitter at 54kHz than at the normal 40kHz!

## 2016 August 19

### Redoing impedance test for tiny loudspeaker

Filed under: Data acquisition,freshman design seminar — gasstationwithoutpumps @ 18:21
Tags: , ,

In Ultrasonic rangefinder tests with tiny loudspeaker, I tested the 10mm CDM-10008 loudspeaker and found it ringing around 9.4kHz, but I reported

I don’t see any resonance around 9.4kHz in the impedance plot, though I admit not looking for narrow resonance peaks in that range.

Today I redid the impedance tests using a 10Ω sense resistor, so that I could use the same range for all voltage measurements, resulting in more correct impedance measurements.  I could definitely hear a resonance around 9.5kHz (and given my deafness at high frequencies, it must have been very loud indeed for me to hear it so clearly), so I looked for another peak in that neighborhood.  It is there and measurable, but not very prominent in the plot:

Because the second peak is on the sloping part of the plot and quite small, I had to model the loudspeaker with a j ωα L semi-inductor to get a good fit.

I have not attempted to fit the data points past 200kHz, because I don’t believe that the multimeter I was using is really good at those frequencies.  The “corner frequency” I’m reporting around 100kHz is where the DC resistance is equal in magnitude to the impedance of the semi-inductor.

Given how small the peak is on the |Z| graph, but how loud the sound is around 9.5kHz, I probably need a different way of looking for resonances beyond the main one. I can’t rely on my ears for loudness at high frequencies, but perhaps I could use a microphone and record the amplitude it sees as a function of frequency.

Next Page »

Blog at WordPress.com.