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 analysis, Better 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, , 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:

The difference is just that I’m including the *j* inside the exponentiation, so that the “inductor-like” component is now in direction instead of —that is, the asymptotic phase angle is 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 , , and , with being the magnitude of the impedance at the top of the peak, located at frequency , with .

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

I then tweaked the fit by refitting the resonance peak, refitting and , and repeating the refits.

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.