# Gas station without pumps

## 2017 July 13

### Analog Discovery 2 oscilloscope input impedance fixed

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 23:25
Tags: , ,

This morning in Analog Discovery 2 oscilloscope input impedance, I wrote

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

This evening I figured out what I was missing. The model I was trying to fit was the following one for the oscilloscope, with a 2MΩ resistor in series as the reference impedance:

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

What I was missing was parasitic capacitance from the breadboard and scope wiring. If I model a capacitor (Cref) in parallel with the 2MΩ resistor and another capacitor (Cextra) in parallel with the scope, I can get a good fit.  I can leave all the internal resistors and capacitors at their nominal values, and fit for several different values for the trim capacitor C8:

I can get an excellent fit with Rref being only a little over 1% off and reasonable parasitic capacitance values.

### Analog Discovery 2 oscilloscope input impedance

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 11:43
Tags: ,

I have been blindly trusting the documentation for the Analog Discovery 2 that claims that the input impedance of the differential oscilloscope channels is 1MΩ || 24pF.  Yesterday, when my son was measuring the input impedance of the reference inputs of a sigma-delta ADC, we had reason for a while to doubt that claim, so I measured the input impedance in a simple way:  I put a 2MΩ 1% resistor in series with one input channel and used the other input channel to measure the voltage across the series pair. I swept the network analyzer from 10Hz to 1MHz, and recorded the voltage gain (and the phase).  The voltage gain is not well-fit by a simple (1MΩ || 24 pF) model, as the impedance does not keep decreasing.  It seems to be well modeled by a model with Rs+(Cp||Rp), though.

The reported voltage gain for Channel 2/Channel 1 is well fit by a voltage divider.

Because the Analog Discovery 2 reports gain for Channel 2/Channel 1, I had to invert the data to get it in the form I wanted for my model (I could, alternatively, have swapped the legs of the voltage divider in the model).

The phases were also well fit by the models, though I did not use the phase information in the fitting. (I tried refitting using just the phase information, but that did not change the parameters by much, nor did it visibly improve the fit of the measured phases, so I left the parameters with just the amplitude fit.)

The DC impedances are both 1.044MΩ, very close to the specified value, but the capacitor is over twice the specified value, and not directly in parallel with the resistance.  The reference resistor I used is supposed to be a 2MΩ±1% resistor, but it was part of a cheap assortment, and we’ve found these cheap assortments to often be slightly out of spec, so I’d not trust it to be better than ±2%.

The 200kΩ/800kΩ split is not very surprising, when we look at the circuit for the input divider of the oscilloscope (from the hardware reference manual):

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

The appearance of the 200kΩ/800kΩ split in the model for the input impedance suggests that the trimmer capacitor C8 is not properly adjusted.  If all capacitance and resistance values were nominal, then C8 should be set to 39.59pF, to provide a flat response from the voltage divider (at the high-gain setting), producing an input impedance of (1.04MΩ || 26pF).  But C8 only has a 5–20pF range, so perhaps there are some other, parasitic capacitances that change the desired trimming.

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

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

## 2017 April 10

### Electret microphone hysteresis

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 09:05
Tags: , , , ,

In attempting to determine the I-vs-V characteristics of an electret microphone, I stumbled across a phenomenon that I’m still having difficulty explaining.  What I was looking for was a plot like this one:

I-vs-V DC characteristics for an electret microphone. The linear and saturation regions are nicely distinguished and there is little noise.

In previous years I had collected the data with PteroDAQ, but this plot was done with my Analog Discovery 2, which combines both the function generator and the data acquisition. Because I was in a bit of a hurry, the first time I tried doing the characterization, I used a shorter period for the function generator, and got a somewhat different plot:

The hysteresis observed here was unexpected. The loop is traced clockwise, with the upper curve for increasing voltage and the lower curve for decreasing voltage.

At first I thought that the effect was a thermal one, like I saw when characterizing power MOSFETs, but a thermal phenomenon would get more pronounced at slower sweep rates (more time to heat up and cool down), while the hysteresis here could be reduced by sweeping very slowly. Also, the hysteresis did not rely on running large currents—the mic was dissipating less than 1mW at the most, and changing the voltage range did not change the hysteresis much.

My next conjecture was a capacitive effect, which I tentatively confirmed by either adding a capacitor in parallel with mic (increasing the hysteresis) or a capacitor in parallel with the 5.1kΩ sense resistor (which reduced the hysteresis or even reversed it).

I tried playing with the frequency of the excitation waveform, to see what happened to the hysteresis:

This pretty plot shows the transition from nearly DC (the curve that looks like the first one of the post) to something that looks almost like a resistor, with current going up linearly with voltage, as the frequency is increased.

Because the hysteresis did not seem to depend on the amount of the sweep, I picked a voltage well into the saturation region (4V), and tried doing a Bode plot of impedance for the mic for a relatively small signal (±1V). I then fit the Bode plot with an (R1+C)||R2 model:

The parallel resistor corresponds to the slope of the DC I-vs-V curve around a bias of 4V. The model fits the data so well that the curve for the data is hidden by the model curve.

I also tried a Bode plot for a DC offset of 2V and an amplitude of ±300mV:

Like with the 4V DC bias, I got an extremely good fit with the (R1+C)||R2 model. The parallel resistance is different, because the slope of the I-vs-V plot is a little higher (so smaller resistance) at 2V than at 4V.

Because the network tool in WaveForms 2015 provides phase information as well as magnitude information, I did my fit first on magnitude, then on phase. The phase fitting was also extremely good:

I show only the 2V phase plot here—the 4V one is similar, though the biggest phase shift is -56.5° at 3.5V, rather than -45.1° at 4.6 Hz.

So I have an excellent electrical model of the behavior of the electret mic at a couple of different bias voltages, with a simple explanation for one of the parameters of the model. I’m still mystified where the capacitance (about 1.7µF) and the other resistance (about 8kΩ) come from. I suppose, theoretically, that they could be tiny surface mount components inside the can of the mic, but I see no reason for the manufacturer to go to the trouble and expense of doing that. The pictures of a disassembled mic at http://www.openmusiclabs.com/learning/sensors/electret-microphones/ suggest a rather low-tech, price-sensitive manufacturing process.

Incidentally, until I looked at those pictures, I had a rather different mental model of how the electret mic was assembled, envisioning one with a simple membrane and the electret on the gate of a MOSFET. It seems that the electret is put on the surface of the membrane and a jFET is used rather than a MOSFET. After thinking about it for a while, I believe that a jFET is used in order to take advantage of the slight leakage current to the gate—the gate will be properly biased as a result of the leakage. The OpenMusicLabs post showed a 2SK596 jFET (an obsolete part), which has an input resistance of only 25—35MΩ, easily low enough to provide bias due to leakage currents. If the gate is biased to be about 0V relative to the source, then the jFET is on by default,

The 1.7µF capacitance is huge—many orders of magnitude larger than I could explain by a Miller effect (unless I’ve screwed up my computations totally) as all the capacitances for the jFET are in the pF range, and the multiplier for the Miller effect should only be around 5–50 (1–10mS times the 5.1kΩ load), so I’m still at a loss to explain the hysteresis. I checked to see whether the effect was something in my test setup, by replacing the mic with a 10kΩ resistor, but it behaved like a 10kΩ resistor across the full range of frequencies that I used for testing the mic—this is not some weird artifact of the test setup, but a phenomenon of the microphone (and probably just of the jFET in the mic).

I suppose I should buy a jFET (maybe a J113, that has a 2mA saturation current with a 0V Vgs) to see if other jFETS have similar properties, connecting the gate to the source with a small capacitor to imitate the electret biasing.

Incidentally, while doing this experimenting, I found a bug in the Waveforms 2015 code: if you sweep the frequencies downward in the network analyzer (which works), on output to a file the frequencies are misreported (as if they had been swept upward). I reported this on the Digilent Forum, and they claim it will be fixed in the next release. The time between the report and the acknowledgement was only a few hours, which is one of the fastest responses I’ve seen for a software bug report. (They didn’t say when the next release will be, but they’ve had several since I bought my Analog Discovery 2 four months ago, so they seem to be releasing bug fix versions rapidly.)

## 2017 February 6

### Hysteresis oscillator is voltage-dependent

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 20:42
Tags: , , ,

Today in class I did a demo where I tested the dependence of the frequency of my relaxation oscillator board on the power supply voltage.

The demo I did in class had to be debugged on the fly (it turns out that if you configure the power supplies of the Analog Discovery 2 to be low-speed waveform channels, then you can’t set them with the “Supplies” tool, but there is no warning that you can’t when you do the setting), but otherwise went well.

One surprising result (i.e., something else that hadn’t happened when I tested the demo at home on Sunday) was that the frequency appeared to go up instead of down when I touched the capacitive touch sensor.  This I managed to quickly debug by changing my sampling rate to 600Hz, and observing that the 60Hz frequency modulation was extreme at the podium, taking the oscillation frequency from 0Hz to 3MHz on each cycle.  Grounding myself against the laptop removed this interference and produced the smooth expected signal.

Anyway, when I got home I was much too tired to grade the lab reports turned in today (I’ve got a cold that is wiping me out), so after a nap and dinner, I decided to make a clean plot of frequency vs. power-supply voltage for my relaxation oscillator.  I stuck the board into a breadboard, with no touch sensor, so that the capacitance would be fairly stable and not too much 60Hz interference would be picked up.  I powered the board from the Analog Discovery 2 power supply, sweeping the voltage from 0V to 5V (triangle wave, 50mHz, for a 20-second period).

I used the Teensy LC board with PteroDAQ to record both the frequency of the output and the voltage of the power supply.  To protect the Teensy board inputs, I used a 74AC04 inverter with 3.3V power to buffer the output of the hysteresis board, and I used a voltage divider made of two 180kΩ resistors to divide the power-supply voltage in half.

When I recorded a few cycles of the triangle waveform, using 1/60-second counting times for the frequency measurements, I got a clean plot:

At low voltages, the oscillator doesn’t oscillate. The frequency then goes up with voltage, but peaks around 4.2V, then drops again at higher voltages.

I expected the loss of oscillation at low voltage, but I did not expect the oscillator to be so sensitive to power-supply voltage, and I certainly did not expect it to be non-monotone.  I need to heed my class motto (“Try it and see!”) more often.

Sampling at a higher frequency reveals that the hysteresis oscillator is far from holding a steady frequency:

Using 1/600 second counting intervals for the frequency counter reveals substantial modulation of the frequency.

This plot of frequency vs. time shows the pattern of frequency modulation, which varies substantially as the voltage changes, but seems to be repeatable for a given voltage. (One period of the triangle wave is shown.)

Zooming in on a region where the frequency modulation is large, we can see that there are components of both 60Hz and 120Hz.

I could reduce the 60Hz interference a lot by using a larger C and smaller R for the RC time constant. That would make the touch sensor less sensitive (since the change in capacitance due to touching would be the same, but would be a much smaller fraction of the total capacitance). The sensor is currently excessively sensitive, though, so this might be a good idea anyway.

Next Page »

Create a free website or blog at WordPress.com.