Gas station without pumps

2019 January 6

OpenScope MZ review: Bode plot

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

Continuing the review in OpenScope MZ review, I investigated using the OpenScope MZ for impedance analysis (used in both the loudspeaker lab and the electrode lab).

Waveforms Live does not have the nice Impedance Analyzer instrument that Waveforms 3 has, so impedance analysis is more complicated on the OpenScope MZ than on the Analog Discovery 2.  It can be done well enough for the labs of my course, but only with a fair amount of extra trouble.

There is a “Bode Plot” button in Waveforms Live, which performs something similar to the “Network Analyzer” in Waveforms, but it uses only a single oscilloscope channel, so the setup is a little different. I think I know why the Bode plot option uses only one channel, rather than two channels—the microcontroller gets 6.25Msamples/s total throughput, which would only be 3.125Msamples/s per channel if two channels were used. In contrast, the AD2 gets a full 100Msamples/s on each channel, whether one or two is used, so is effectively 32 times faster than the OpenScope MZ.

We still make a voltage divider with the device under test (DUT) and a known reference resistor, and connect the waveform generator across the whole series chain.  Because there is only one oscilloscope channel, we have to do two sweeps: first one with the oscilloscope measuring the input to the series chain (using the “calibrate” button on the Bode panel), then another sweep measuring just across the DUT.  The sweeps are rather slow, taking about a second per data point, so one would probably want to collect fewer data points than with the AD2.  Also there is no short or open compensation for the test fixture, and the frequency range is more limited (max 625kHz).

The resulting data only contains magnitude information, not phase, and can only be downloaded in CSV format with a dB scale.  It is possible to fit a model of the voltage divider to the data, but the gnuplot script is more awkward than fitting the data from the impedance analyzer:

load '../definitions.gnuplot'
set datafile separator comma


undb(db) = 10**(db*0.05)
model(f,R,C) = Zpar(R, Zc(f,C))
div(f,R,C) = divider(Rref, model(f,R,C))

R= 1e3
C= 1e-9
fit log(abs(div(x,R,C))) '1kohm-Ax-Bode.csv' skip 1 u 1:(log(undb($2))) via R,C

set xrange [100:1e6]
set ylabel 'Voltage divider ratio'
plot '1kohm-Ax-Bode.csv' skip 1 u 1:(undb($2)) title 'data', \
      abs(div(x,R,C)) title sprintf("R=%.2fkohm, C=%.2fnF", R*1e-3, C*1e9)

The fitting here results in essentially the same results as the fitting done with the Analog Discovery 2.

Although the Bode plot option makes the OpenScope MZ usable for the course, it is rather awkward and limited—the Analog Discovery 2 is still a much better deal.

2019 January 5

Series-parallel and parallel-series indistinguishable

Filed under: Circuits course — gasstationwithoutpumps @ 00:52
Tags: ,

I was looking at 3-component circuits for the impedance tokens, to make more challenging targets for students to identify than the 2-component RC ones.  Here are two of the circuits I was looking at:

Series-parallel : R1+(R2||C2) and Parallel-series: R4||(R3+C3)

I realized over the past couple of days that these two circuits are indistinguishable with an impedance spectrum, if you don’t know any of the R or C values.

The series-parallel circuit has impedance R_1 + \frac{R_2}{1+j\omega R_2 C2}, which can also be written as \frac{R_1+R_2 + j\omega R_1 R_2 C_2}{1+ j\omega R_2 C_2}.

The parallel-series circuit has impedance \frac{R_4 \left(R_3 + 1/(j \omega C_3)\right)}{R_4 + R_3 + 1/(j \omega C_3)} which can be written as \frac{R_4 + j \omega R_3 R_4 C_3}{1 + j \omega (R_3+R_4) C_3}.

If we are given R1, R2, and C2, we can set R_4 = R_1+R_2 and R_3 = R_4 \frac{R_1}{R_2} to get the same impedances for both circuits at DC and infinite frequency. If we set C_3 = C_2 \frac{R_1 R_2}{R_3 R_4}, then the impedances are identical for the two circuits at all frequencies.

There is one way that we can distinguish between the circuits, but it is pretty subtle, relying on thermal effects. The overall power dissipation is the same for both circuits with any given input voltage waveform, but the heat will be distributed differently. At high frequencies, the energy is dissipated in R1 and in both R3 and R4, but at low frequencies the energy is dissipated in both R1 and R2 or in R4. The thermal masses will be different in the two cases, and so the temperature rise will be different, which can theoretically be detected by differences in the noise spectra of the thermal noise from the resistors.

If the resistors were mounted on a sufficiently thermally conductive substrate, so that the temperature rise was the same for both resistors in each circuit, then even this subtle detection would not be possible.

A similar analysis of the impedances can be made if R1 and R4 are replaced by capacitors C1 and C4, so there are really only two distinguishable 3-component RC circuits: R1+ (R2||C2) and C1 + (R2||C2). Others either reduce to one of these or reduce even further to 2-component or 1-component circuits.

2019 January 1

Impedance tokens

Filed under: Circuits course — gasstationwithoutpumps @ 13:42
Tags: ,

I have been planning to add a little to the loudspeaker-impedance lab in BME 51B for the spring—a simpler measurement and modeling warmup using series or parallel RC circuits.  The idea is to give each group a different unknown impedance, which consists of a resistor and capacitor in series or in parallel, then have them measure the impedance with the Impedance Analyzer function of the Analog Discovery 2, and fit a model (R+C or R||C as appropriate).

The idea is to give the students a simpler warmup exercise for collecting and fitting data, before they tackle the more complicated loudspeaker model.

To make the unknown impedances, my son and I designed small printed-circuit boards that could take up to 6 SMD components (1206—or 3216 if you prefer the metric designation).  The components are fairly large, and so not too difficult to hand solder, and I bought an assortment of resistors and an assortment of capacitors from AliExpress to populate with.

The schematic for the impedance token is designed to allow several different RC circuits—both as single impedances or as voltage dividers.

All possible 2-port, series-parallel circuits of 3 components can be wired between two adjacent pins, though three components in parallel requires adding an extra 0Ω component to get Z2||Z3||Z4 (shorting Z1). Of the 10 possible 4-component, 2-port parallel circuits, 6 can be made between adjacent pins, 2 only between pins A and C, and 2 are not achievable on the board.

With B as the center pin of a voltage divider, we can get several useful configurations:

  • Z2 paired with Z3||Z4
  • Z5+Z6 paired with Z3
  • Z5+Z6 paired with Z3||Z4
  • Z2||Z5 paired with Z3||Z4 (shorting Z6)

The board designs are available at

The top shows a panel of 10 boards as delivered by Seeedstudio. The middle row has the boards after breaking apart and sanding the edges. The bottom row shows the boards populated, with heat-shrink tubing to hide the components and label the board.

I had the boards made by Seeedstudio this time (rather than SmartPrototyping), because I had a coupon code for a discount and because Seeedstudio did not charge extra for fancy colors of soldermask.  Seeedstudio had to email me to ask if I was willing to accept panelizing, while SmartProtoyping puts that question on their web form when the job is submitted.

The hole at the top of each board is for hanging the boards from hooks or putting them on a keychain—I’m going to have to do something to make sure that I get all the tokens back after each lab that uses them.

I wrote a program to generate random series or parallel RC circuits based on the components in the assortments and constraints on the range of impedance and the RC time constant. The programs are available at

I’ve populated 10 of the boards so far, and they all seem to be ok, except for one whose 100nF capacitor seems to be 160nF instead of 100nF. I think that this may be a labeling error on the assortment of capacitors I bought. If the others from the same strip also come out to 160nF, I’ll relabel the strip. (The capacitors themselves are not labeled, though the resistors are.)

One problem I’ve found in characterizing the boards is that the screwless terminal on the adapter board for the Analog Discovery 2 impedance analyzer has its contacts recessed too deep—the header pins can’t reach the contacts.  I’ve found the screwless terminal to be more of a nuisance than timesaver, both because the contacts are recessed so deep and because the release buttons are difficult to press. I’m considering buying a 0.1″-pitch, 2-contact screw terminal to replace the screwless terminal with.

When I tried adding wires from the adapter board to a breadboard, I got inconsistent readings with about 10Ω–20Ω resistance in series with what I was measuring—I think this may have been bad contacts in either the screwless terminal or in the breadboard.  I switched to using the breadboard directly with my own reference resistor rather than using the impedance analyzer adapter board and had no further problems.


2017 September 7

Ultrasonic transmitter and receiver impedance measurement

Filed under: Data acquisition — gasstationwithoutpumps @ 18:53
Tags: , , ,

In Ultrasonic rangefinder with Analog Discovery 2, I looked at the impedance of  an ultrasonic transmitter with the Analog Discovery 2, but I only modeled the transmitter as a capacitor, not modeling the resonances.

So today I collected new data, both for a transmitter and a receiver, using a 1nF C0G (1%) capacitor as the reference impedance, so that I could have clean data from a known pair.  I also looked at the transmitter+receiver as a network, and located the peaks of the signal transmission.  I was curious whether they corresponded more to transmitter or receiver resonances.

I could model the transmitter quite effectively as a capacitor with 4 LCR resonators in parallel.

I could model the receiver quite effectively as a capacitor with three LCR resonators in parallel.

The fitting was done with gnuplot, fitting one resonance at a time starting with the lowest frequency one, then refitting the previously fit parameters to tweak the fit. The radius of convergence for the fitting is pretty small—I needed to get the LC resonant frequency pretty close to correct before the fitting would converge. Increasing L makes the down-spike and up-spike closer together, and R controls how low the minimum gets, so I could get reasonable initial values (good enough to get convergence) without too much guessing, by plotting using the initial values, adjusting L to get the spacing between the spikes about right, adjusting C to get the resonant frequency right, and doing a rough guess that R is about the minimum value.

The peaks of the transmitter+receiver characteristic seem to correspond most closely to the minimum impedance points of the transmitter, which is reasonable when you consider that I’m driving the transmitter from a fixed voltage—the power is going to be V2/R, so power out is maximized when the impedance is lowest.  The one exception is the 331kHz peak, which seems to fall on the higher frequency of the two closely spaced transmitter resonances, and near the peak of receiver impedance. (Of course, only the 40kHz resonance of the transmitter or receiver actually gets used—the other resonances don’t provide nearly as much response in the transmitter+receiver pairing.)

Zooming in on the transmitter impedance for the high-frequency resonances, we can see that there are minor resonances that have not been modeled, but that the model does a good job of capturing the shape of the peaks. The peak of the transmitter+receiver response here falls on the higher-frequency resonance.

I did all my modeling with just the magnitudes of the signals, so it is interesting to see how well the model fits the phase response.

I got excellent matches to the phase response (even when I zoomed in on each peak), except for the low-frequency region, where the impedance seems to have a negative real part (phase < -90°).

I do have models for no resonance, single resonance, two resonances, and three resonances for the transmitter, as well as the four-resonance model. If a simplified model is needed, then it is better to take one of those fits, rather than omitting parts of the more complicated model, as each resonance affects the other parameters somewhat.
As a simple example, the receiver can be modeled as just a 739pF capacitor, but the LCR circuits contribute some of the capacitance, so 708pF gets used for the base capacitor of the model with the 3 resonances.

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.

Next Page »

%d bloggers like this: