Vector measurements with the rtl-sdr

21.06.2020 11:41

Previously I was writing about some experiments with reflection measurements using an rtl-sdr receiver. I used the rtl-sdr as a simple power meter together with an RF bridge to measure VSWR. This was a scalar measurement. All the phase information from the signal was lost and with it also the angle information about the complex impedance of the load I was measuring. Since I was happy with how the method performed in that experiment I was wondering if I could adapt the setup to measure the phase information as well.

With a vector measurement I need a reference signal to compare the phase of the measured signal to. This is a problem, since the rtl-sdr only has one input and can only sample a single signal at a time. My idea was that perhaps I could multiplex the reference and the measured signal onto the single input. Both time and frequency multiplex seemed doable, but time multiplex seemed by far simpler to implement in hardware. Integrated microwave switches with usable characteristics, such as Renesas F2976, are reasonably cheap these days.

Previously I recorded a 2 second array of digital samples of the measured signal for each scalar measurement point. With the time multiplex setup, I could record similar 2 seconds of input, but that input would now contain both the reference and the measured signal. I could then de-multiplex and process it in software. The new setup would look something like the following. The device under test could again be a bridge, or something else:

Block diagram of the vector measurement setup.

The time multiplex board contains two SPDT switches. In one position, the switches direct the reference signal to the rtl-sdr. In the other position the signal passes through the device under test and then back to the rtl-sdr. The switch frequency I'm thinking about is somewhere around 100 Hz. A complex baseband signal recorded by the rtl-sdr would then look something like this:

Plot of the simulated complex baseband signal.

Most of the complexity in this setup would be in software. The software would need to find out which parts of the recording is the reference and which part is the measured signal. This is similar to clock recovery in a receiver. It would then compare the two signals and do some filtering. This is a rough block diagram of the processing pipeline:

Block diagram of the signal processing setup.

The reality is a bit more complicated though. Especially clock recovery seems tricky. My original intention was to use auto-correlation of the signal but it turned out much too slow. Right now I'm just using simple amplitude thresholding, which works as long as DUT is attenuating the signal enough compared to the reference. There's also some additional processing required to account for the fact that my delay is an integer number of samples, which introduces an additional random phase shift that needs to be accounted for.

So far I've only performed some proof-of-concept simulations of this setup using the performance of the rtl-sdr I've seen in my scalar measurements and the properties of the switches from the datasheet. It does seem feasible. Here are simulated vector measurements of three points on the complex plane. For example, these might be complex reflection coefficient measurements on the Smith chart. The gray dots show the true value and the blue dots show the simulated measurements:

Simulated vector measurements of three points on the complex plane.

There is some angle and amplitude error, but otherwise the principle seems to work fine. These are the histograms of the errors over a large number of simulated measurements of random points on the complex plane, where the measured signal was well above the receiver noise floor:

Histogram of the amplitude measurement errors.

Histogram of the angle measurement errors.

I'm not sure yet what part contributes the most to these errors. I'm simulating several hardware imperfections, such as switch cross-talk, frequency and phase inaccuracies and receiver noise. The most complicated part here is the clock recovery and I suspect that has the largest effect on the accuracy of the output. The problems with clock recovery actually made me think that having a four-state "off-dut-off-ref" cycle instead of a two-state "dut-ref" for the switches would be better since that would gave a much stronger pattern to match against. Another idea would be to lock the multiplex clock to the actual signal. ERASynth Micro does provide a 10 MHz reference clock out, but dividing it down to 100 Hz would need a huge divider.

Anyway, the simulations so far seem encouraging and I probably can't get much further on paper. I'm sure other factors I haven't thought of will become evident in practice. I plan to make the time multiplexing board in the future and try to do some actual experiments with such a setup.

Posted by Tomaž | Categories: Analog | Comments »

Resistor tolerance and bridge directivity

13.06.2020 14:20

Another short note related to the RF bridge I was writing about previously. The PCB has four resistors soldered on. Two pairs of 100 Ω in parallel. Each pair forms one of the two fixed impedances in the two branches of the bridge circuit. The two variable impedances in the bridge are the device under test (left) and the termination on the REF terminal (right). The black component on the bottom is the RF transformer of the balun circuit.

Four 100 Ω resistors on the RF bridge PCB.

My father pointed out the fact that these resistors don't look particularly high precision. The "101" marking (10 times 101 ohms) is typical of 5% tolerance resistors. 1% parts more often have "1001" or the EIA-96 character code. Unfortunately I can't simply measure them in circuit with a multimeter, because the balun forms a DC short circuit across them. I don't want to desolder them. Still, I was wondering how much variances in these resistors would affect the bridge directivity.

Following is the result of a Monte Carlo simulation showing three histograms for bridge directivity. Each was calculated for one possible tolerance class of the 4 resistors used. The assumption was that individual resistor values are uniformly distributed between their maximum tolerances. The effect of two parallel resistors on the final distribution was included. The peak on each histogram shows the value for directivity that is most likely for a bridge constructed out of such resistors.

Directivity histogram calculated using a Monte Carlo method.

Each tolerance class defines the lowest possible directivity (where the two resistors are most mismatched). On the high end the histogram isn't limited. In any tolerance class there exist some small possibility that the resistors end up being perfectly matched, however the more you move away from the average directivity the less likely that is, as the probability asymptotically approaches zero.

Cumulative distribution function of bridge directivity.

This is the same data shown as an estimate of the cumulative distribution function. The annotations on the graphs show the 90% point. For example, for 5% resistors, 90% of the bridges would have higher than 32.1 dB directivity. You gain approximately 20 dB in directivity each time you reduce the resistor tolerance by a factor of 10.

It's important to note that this was calculated using a low-frequency bridge model. In other words, none of the high-frequency effects that cause the real-life directivity to fall as you go towards higher frequencies are counted. Any effects of the balun circuit and the quality of the REF termination were ignored as well. So the directivity numbers here should be taken as the best possible low-frequency case.

Anyway, I thought this was interesting. Similar results apply to other devices that use a resistor bridge circuit as a directional coupler, such as the NanoVNA and its various variants. Also somewhat related and worth pointing out is this video by W0QE where he talks about resistor matching for calibration loads and how different SMT resistors behave at high frequencies.

Posted by Tomaž | Categories: Analog | Comments »

Experiments with the "Transverters Store" RF bridge

07.06.2020 17:54

The "Transverters Store" RF bridge, for a lack of a better name, is a low-cost bridge circuit that can be used to measure reflection loss or voltage standing wave ratio (VSWR) at radio frequencies. It claims to be usable from 0.1 MHz to 3 GHz. Basic design and operating principle of a similar device is described in "A Simple Wideband Return Loss Bridge Revisited", an article by Paul McMahon from 2005. In it he also gives measurements of its performance up to 500 MHz. The exact device I have seems to be very much related to Paul McMahon's design. It came from a web page called Transverters-Store and shipped from Ukraine. Very similar looking products with more or less exact copies of the PCB layout are available from various other sources. Since there's no product number or a clear name associated with it, most often people refer to these as simply "that cheap bridge from eBay".

The "Transverters Store" RF bridge.

In short, the bridge operates similarly to the typical resistor bridge networks, like the Wheatstone bridge. The network is composed of two 50 Ω resistors on the PCB itself (each made out of two parallel 100 Ω resistors), the reference load on the REF port and the device under test on the DUT port. The biggest difference is the addition of a balun circuit. This makes the detector output referenced to ground, instead of floating between the two bridge branches like in a low-frequency bridge. The balun is implemented here as a high-frequency transformer made out of a row of black ferrite beads and two lengths of coax.

The bridge can in principle be thought of as a directional coupler. The signal power on the OUT port only corresponds to the reflected power coming back in to the DUT port, but (ideally) not the forward power going out of that port to the device under test. Compared to a true directional coupler however the bridge can't be operated in the reverse. You can't measure forward power by connecting a signal source on the OUT port and a detector on the IN port.

Ideal bridge output versus return loss.

This is how the bridge would behave if everything was ideal. The vertical axis shows the power on the OUT port relative to the power on the IN port. The horizontal axis shows return loss of the device under test. Using directional coupler terminology, the bridge has a coupling factor of 16 dB if used with a 50 Ω detector. It's also interesting to see that if using such a detector on the OUT port, the output of the bridge is slightly non-linear in respect to return loss. The difference is small - an open circuit will measure around 1.5 dB too high and a short will measure around 1.5 dB too low. Considering other inaccuracies, this detail probably isn't significant in practice.

Below you can see the setup I used for the experiments. Signal source on the top left is an ERASynth Micro. The detector on top right is an Ezcap DVB-T dongle (using Elonics E4000 tuner) and rtl-power-fftw. Both the source and the detector are controlled from a PC through a USB connection. Above the bridge you can see the terminations I used in the experiments: A borrowed professional Narda Micro-Pad 30 dB attenuator (DC - 18 GHz) which I used as a terminator, a couple of home-made 50 Ω SMA terminators (using two parallel 100 Ω 0603 resistors in a SMA connector), a home-made short and a no-name terminator that has a through-hole metal-film 51 Ω resistor inside.

The setup for experiments with the RF bridge.

Using this setup I tried to measure the directivity of the bridge. Directivity is the measure of how well the bridge selects between the forward and reflected power. The higher directivity, the lower return loss and VSWR you can reliably measure with it. Anritsu has a good application note that describes how directivity affects measurement error. I measured directivity by measuring OUT port power twice: once with a short on the DUT port and once with my home-made terminator. Dividing these two values gave an estimate of bridge directivity. I performed two measurements: once with the Narda attenuator on the REF port and once with my home-made terminator using two 0603 SMT resistors.

There is an approximately 200 MHz wide gap in my measurements at around 1.1 GHz because the DVB-T receiver cannot tune on those frequencies.

Measured directivity of the RF bridge.

You can see that my two measurements differ somewhat. In both, the bridge shows good directivity up to around 1 GHz. Above that, it's below 20 dB which introduces a large error in measured VSWR as you'll see below. The DVB-T receiver I used also shows a decrease in sensitivity above 1 GHz, however I've repeated this measurement using different input power levels (from -10 dBm to -30 dBm on ERASynth micro) and they all show similar results, hence I believe the measured decrease in directivity is not due to the limited dynamic range of my measurement setup.

In general, I think the biggest source of errors during these experiments are the terminators I've used. The directivity measurement assumes that the bridge can be measured with perfect termination on both the DUT and REF ports. By testing various combinations of terminators I had at hand I've seen significant differences in output port power, which suggest they are all slightly imperfect in different ways.

My measurements of directivity compared to seller's.

This is how my measurements compare with the measurements published on the Transverters Store website. The blue and orange plots are same results as above, only rescaled. Red plot is the Transverters' result. Again, my results differ from theirs. Below 500 MHz mine show a bit better directivity. Above 500 MHz mine are worse. Both show a slow decrease and then a sharp fall at around 1 GHz. I'm not claiming their measurements are wrong. My setup is very much improvised and can't compare to professional equipment. It's also very likely that different devices differ due to manufacturing tolerances.

Measured VSWR of the cheap SMA terminator.

Finally, here's an example of a VSWR measurement using this setup. I've measured the bad attenuator I've mentioned in my previous blog post that's made using a standard through-hole resistor. Again, the blue and orange plots show measurements using the two different references on the REF port of the bridge. The shaded areas show the error interval of the VSWR measurement due to bridge directivity I measured earlier. The VSWR of the device under test can be anywhere inside the area.

Interestingly, the terminator itself doesn't seem that bad based on this measurement. Both of my measurements show that the upper bound of the VSWR is below 1.5 up to 1 GHz. Of course, it all depends on the application whether that is good enough. You can also see that above 1 GHz the error intervals increase dramatically due to low bridge directivity. The lower bounds do carry some information (e.g. the terminator can't have VSWR below 1.5 at 2 GHz), but the results aren't really useful for anything else that a rough qualitative estimate.

In the end, this seems to be useful method of measuring return loss and VSWR below 1 GHz. Using it at higher frequencies however doesn't look too promising. 3 GHz upper limit seems to me like a stretch at this point. The largest practical problem is finding a good 50 Ω load to use on the REF port, a problem which was also identified by others (see for example a comment by James Eagleson below his video here). Such precision loads are expensive to buy and seem hard to build at home.

I was also surprised how well using the DVB-T tuner as a power meter turned out in this case. I was first planning to use a real power meter with this setup, but the device I ordered seemingly got lost in the mail. I didn't see any indication that the dynamic range of the tuner was limiting the the accuracy of the measurement. Since all measurements here use only ratios of power, absolute calibration of the detector isn't necessary. With the rtl-sdr device you only need to make sure the automatic gain control is turned off.

Posted by Tomaž | Categories: Analog | Comments »

What's inside cheap SMA terminators

29.05.2020 14:16

I've recently ordered a bag of "YWBL-WH" 50 Ω SMA terminators off Amazon along with some other stuff. Considering they were about 3 EUR per piece and I was paying for shipment anyway, they seemed like a good deal. Unsurprisingly, they turned out less than stellar in practice.

50 Ω SMA terminators I bought off Amazon.

At the time when I bought them, the seller's page listed these specifications, claiming to be usable up to 6 GHz and 2 W of power dissipation. There's no real brand listed and identical-looking ones can be found from other sellers:

Specifications for 50 ohm SMA terminators.

Their DC resistances all measured very close to 51 Ω, which is good enough. However when I tried using them for some RF measurements around 1 GHz I got some unusual results. I thought the terminators could be to blame even though I don't currently have equipment to measure their return loss. If I had bothered to scroll down on that Amazon page, I might have seen a review from Dominique saying that they have only 14 dB return loss at 750 MHz and are hence useless at higher frequencies.

I suspected what's going on because I've seen this before in cheap BNC terminators sold for old Ethernet networks, but I still took one apart.

Cheap SMA terminator taken apart.

Indeed they simply have a standard through-hole axial resistor inside. The center SMA pin is soldered to the lead of the resistor, but ground lead was just pressed against the inside of the case. According to the resistor's color bands it's rated at 51 Ω, 5% tolerance and 100 ppm/K. I suspect it's a metal film resistor based on the blue casing and low thermal coefficient (if that's what the fifth color band stands for). It might be rated for 2 W, although judging by the size it looks more like 1/2 W to me. In any case, this kind of resistor is useless at RF frequencies because of its helical structure that acts like an inductor.

Again it turned out that cheaping out on lab tooling was just a waste of money.

Posted by Tomaž | Categories: Analog | Comments »

Simple method of measuring small capacitances.

22.05.2020 18:17

I stumbled upon this article on Analog Devices' website while looking for something else. It looks like instructions for a student lab session. What I found interesting about it is that it describes a way of measuring small capacitances (around 1 pF) with only a sine-wave generator and an oscilloscope. I don't remember seeing this method before and it seems useful in other situations as well, so I thought I might write a short note about it. I tried it out and indeed it gives reasonable results.

Breadboard capacitance measurement schematic.

Image by Analog Devices, Inc.

I won't go into details - see original article for a complete explanation and a step-by-step guide. In short, what you're doing is using a standard 10x oscilloscope probe and an unknown, small capacitance (Crow in the schematic above) as an AC voltage divider. From the attenuation of the divider and estimated values of other components it's possible to derive the unknown. Since the capacitance of the probe is usually only around 10 pF, this works reasonably well when the unknown is similarly small. The tricky part is calibrating this measurement, by estimating stray capacitances of wires and more accurately characterizing the resistance and capacitance of the probe. This is done by measuring both gain of the divider and its 3 dB corner frequency.

Note that the article is talking about using some kind of an instrument that has a network analyzer mode and can directly show a gain vs. frequency plot. This is not necessary and it's perfectly possible to do this measurement with a separate signal generator and a digital oscilloscope. For measuring capacitances of around 1 pF using a 10 pF/10 MΩ probe a signal generator capable of about 100 kHz sine-wave is sufficient. Determining when the amplitude of the signal displayed on the scope falls by 3 dB probably isn't very accurate, but for a rough measurement it seems to suffice.

The measurement depends on the probe having a DC resistance to ground as well as capacitance. I found that on my TDS 2002B scope you need to set the channel to DC coupled, otherwise there is no DC path to ground from the probe tip. It seems obvious in retrospect, but it did confuse me for a moment why I wasn't getting good results.

I also found that my measured signal was being overwhelmed by the 50 Hz mains noise. The solution was to use external synchronization on the oscilloscope and then use the averaging function. This cancels out the noise and gives much better measurements of the signal amplitude at the frequency that the signal generator is set to. You just need to be careful with the attenuator setting so that noise + signal amplitude still falls inside the scope's ADC range.

Posted by Tomaž | Categories: Analog | Comments »

Measuring some Zener diodes

19.04.2020 12:05

I've been stuck working on a problem for the past few days. I need to protect an analog switch in a circuit from expected over-voltage conditions. Zener diodes seemed like a natural solution, but the border between normal operation and over-voltage is very thin in this particular case. I couldn't find components with a characteristic that would fit based solely on the specifications given in the datasheets. I've been burned before by overestimating the performance of Zener diodes so I decided to do some measurements and get some better feel for how they behave. The results were pretty interesting and I thought they might be useful to share.

The following measurements have all been done with my tiny home-brew curve tracer connected to a Tektronix TDS 2002B oscilloscope. Unfortunately this model only has 8-bit vertical resolution. This caused some visible stair-stepping on the vertical parts of the traces below. Nevertheless the measurements should give a pretty good picture of what's going on. Before doing the measurements I've also checked the DC calibration of the whole setup against my new Keysight U1241C multimeter. The error in measured voltage and current values should not be more than ±3%. Measurements were done roughly at room temperature and at a low frequency (100 Hz).

First measurement is with SZMMBZ5230BLT11G, a 4.7 V Zener diode from ON Semi in a SOT-23 SMT package. I've only measured a single one of these, since soldering leads to the SMT package was time consuming. The figure shows current vs. voltage characteristic in the reverse direction. The narrow, dark blue graph shows the actual measured values. The black dashed line shows the maximum power dissipation limit from the datasheet. I also made a model for the diode based on the minimum and maximum values for VZ and the single ZZT value given in the datasheet. The light blue area is the range of characteristics I predicted with that model.

Voltage vs. current graph for SZMMBZ5230BLT11G

The relevant part of the datasheet for this diode:

Excerpt from the MMBZ52xxBLT1G datasheet.

Image by ON Semiconductor

This is the same measurement repeated for BZX79C4V7, also a 4.7 V Zener diode from ON Semi, but this time in a sealed glass THT package. I've measured 10 of these. All came shipped in the same bag, which might mean they're from the same production batch, but I can't be sure. All 10 measurements are shown overlapped on the same graph.

Voltage vs. current graph for BZX79C4V7.

The relevant part of the datasheet:

Excerpt from the BZX79Cxx datasheet.

Image by ON Semiconductor

It's interesting to see that both of these parts performed significantly better than what their datasheets suggest. They were both in the allowed voltage range at the specified current (note that one is specified at 20 mA and the other at 5 mA). The differential impedance was much lower however. SZMMBZ5230BLT11G is specified at 19 Ω at 20 mA and I measured around 1 Ω. BZX79C4V7 is specified at 80 Ω at 5 mA and I measured 11 Ω. The datasheet for BZX79C4V7 does say that 80 Ω is the maximum, but SZMMBZ5230BLT11G isn't clear on whether that is a typical or the maximum value. It's was also surprising to me how the results I got for all 10 BZX79C4V7 measurements were practically indistinguishable from each other.

A note regarding the models. I used the classic diode equation where I calculated the parameters a and b to fit VZ and ZZ (or ZZT) values from the datasheets.

I = a ( e^\frac{U}{b} - 1)

As far as I know, a and b don't have any physical meaning here. This is in contrast to the forward characteristic, where they represent saturation current and thermal voltage. I wasn't able to find any reference that would explain the physics behind this characteristic and most people just seem to use such empirical models. The Art of Electronics does say that the Zener impedance is roughly inversely proportional to the current, which implies an exponential I-U characteristic.

From my rusty understanding of breakdown physics I was expecting that a junction after breakdown wouldn't have much of a non-linear resistance at all. I was expecting that a good enough model would just be a voltage source (representing the junction in breakdown) and a series resistance (representing ohmic contacts and bulk semiconductor). It seems this is not so, at least for the relatively low current conditions I've measured here. The purely exponential model also fits my measurements perfectly, which seems to confirm that this was a correct choice for the model.

Update: I found Zener and avalanche breakdown in silicon alloyed p-n junctions—I: Analysis of reverse characteristics (unfortunately pay-walled). It contains an overview of the various mechanisms behind junction breakdown. In contrast to all other references I've looked at it actually goes into mathematical models and doesn't just stop at hand-waving qualitative descriptions. The mechanisms are complicated and the exponential characteristic I've used is indeed just an empirical approximation.

Finally, it's interesting to also look at how the forward characteristics compare. Here they are plotted against a common signal diode 1N4148. Both Zener diodes are very similar in this plot, despite a different Zener impedance and a differently specified forward voltage in the datasheet. Compared to the signal diode they have the knee at a slightly higher voltage, but also steeper slopes after the knee:

Comparison of forward characteristics.

In conclusion, it's interesting to see how these things look like in practice, beyond just looking at their specifications. Perhaps the largest take away for me was the fact that a purely resistive model obviously isn't a good way of thinking about Zener diodes in relation to large signals. Of course, it's dangerous to base a design around such limited measurements. Another batch might be completely different in terms of ZZ and I've only measured a single instance of the SOT-23 diode. Devices might change after aging and so on. After all, the manufacturer only guarantees what's stated in the datasheet. Still, seeing these measurements was useful for correcting my feel for how these parts are behaving.

Posted by Tomaž | Categories: Analog | Comments »

How a multimeter measures capacitance

13.03.2020 10:57

I've recently bought a Keysight U1241C multimeter. One of the features it has is a capacitance measurement. Since this is my first multimeter that can do that I was curious what method it uses. I was also wondering what voltage is applied to the capacitor under test and whether the probe polarity matters (for example, when measuring electrolytic capacitors).

The Figure 2-16 in the User's Guide seems to imply that polarity is important. The red probe (V terminal) is marked as positive and the black probe (COM terminal) is marked as negative:

Figure 2-16: Measuring capacitance from the U1241C User's Guide.

Image by Keysight Technologies

The description of the measurement method is limited to this note and doesn't say what voltages or frequencies are involved, but does give a rough idea of what is going on:

Note about capacitance measurement from the U1241C User's Guide.

Image by Keysight Technologies

Connecting an oscilloscope to a capacitor while it is being measured by the multimeter reveals a triangle waveform. I made the following screenshot with a 47 μF electrolytic capacitor connected to the multimeter set to the 100 μF range. The oscilloscope was set to DC coupling, so the DC level is correctly shown as 0 V at the center of the screen:

Voltage on the 47 μF capacitor during measurement.

Since current into a capacitor is proportional to the time derivative of the voltage, a triangle-shaped voltage means that there is a constant current flowing alternatively in and out of the capacitor. Connecting different capacitors revealed that the current and the amplitude of the voltage stay constant for each measurement range, while the period of the signal changes. So the multimeter applies a known current source I to the probes and measures time t it takes for the voltage to rise (or fall) for a present difference Upk-pk. From the measured rise (or fall) time it then calculates capacitance:

C = \frac{I\cdot t}{U_{pk-pk}}

These are the approximate current and voltages used by the multimeter for each range:

Range [μF] I [μA] Upk-pk [mV]
1 1.5 800
10 15 800
100 150 800
1000 340 200
10000 340 200

Note that 1000 μF and 10000 μF ranges seem identical in this respect. I'm guessing the only change is how the time is measured internally. Perhaps a different clock is used for the counter.

If a high range is selected while a small capacitor is connected, the voltage on the capacitor can reach much higher amplitudes. The highest I saw was about 2 V peak-to-peak when I had a 4.7 nF capacitor connected while the instrument was set to 100 μF range.

Voltage on the 4.7 nF capacitor during measurement.

In conclusion, the polarity of the probes isn't important. The applied signal to the capacitor is symmetrical and the capacitor will be alternatively polarized in the positive and negative direction regardless of how it is connected to the multimeter. The voltages do seem low enough that they probably don't damage polarized electrolytic capacitors.

Posted by Tomaž | Categories: Analog | Comments »

The tiny curve tracer project

08.03.2020 10:14

About a year ago I got interested in some unusual transistor characteristics. Since I didn't have any suitable instruments at hand I first measured things with an oscilloscope and some improvised circuits on a protoboard. These setups gradually became more elaborate and for some time now I had a dusty rat's nest of wires on my desk that more or less implemented a simple curve tracer. It soon turned out to be useful in other cases as well, so I thought it would be worth moving the circuit from the protoboard to an actual printed circuit board.

The tiny curve tracer circuit board.

The construction is through-hole on a single layer PCB. I've decided on this slightly vintage style because I could just move the components from the protoboard to the PCB without having to buy their surface-mount equivalents. My Dad offered to etch the board for me using the toner transfer method and it turned out very nice with 20 mil design rules. He made the overlay print on the component side for me as well. I've not etched a board at home in years, ever since cheap on-line prototyping services became available.

It took me quite a while to decide on what kind of contacts to use for connecting the device-under-test (DUT). I've considered a transistor socket (too limited in the pin diameters), a Textool-type ZIF socket (seemed wasteful to use a 16-pin socket when I only needed 6 pins) and just ordinary screw terminals (inconvenient to use). In the end, I went with a WAGO push-button style, 3.5 mm pitch terminal block (type 250-206 to be exact).

This seems to work really well and the only slight problem I have with that is that when inserting a transistor you need to push three buttons at the same time. Since the springs are quite stiff, this requires a fair amount of force. If I would be doing a second revision of the board I would make some provisions for better supporting the PCB around the terminal since it tends to flex quite a lot.

The tiny curve tracer block diagram

My circuit obviously isn't on the level of something like a Tektronix 575. The signal that will be applied to the DUT, usually a sine or a triangle wave, comes from a signal generator via a BNC connector, shown on the left of the block diagram. I'm using my GW Instek AFG-2005. After the input there are two amplifier stages and a power transistor in an emitter-follower configuration. Total voltage gain from input to DUT terminal is 5. The actual current and voltage on the DUT are amplified and passed to the BNC outputs. I use two 50 Ω coaxial cables to connect the outputs to an oscilloscope in XY mode.

A switch allows the input to be either AC or DC coupled. AC coupling allows me to quickly change the amplitude on the signal generator without having to simultaneously also adjust the offset voltage. In this case the circuit clamps the lowest voltage to 0 V. On the other hand, DC coupling allows me to put the DUT under some DC bias and only measure some small signal characteristic.

The curve tracer is powered by a bench power supply with around 30 V and doesn't need a negative supply. It is capable of providing up to about 25 V of voltage to the DUT and around 200 mA of current. 25 V isn't enough to reach collector-emitter breakdown voltages of common transistors, but it is plenty to investigate knee regions of diodes or breakdown in low-voltage Zener and TVS diodes. For example, this is the forward characteristic of a 1N4148 diode I measured:

Measured I-V curve for the 1N4148 diode.

It's also possible to measure base-emitter junction characteristic in bipolar transistors. Here is a BC546, a common small-signal NPN transistor, in forward and reverse directions. Breakdown in the junction is visible in the reverse direction at around 11 V:

Base-emitter junction measurements for BC546 transistor.

There's a protection circuit that turns off the voltage to the DUT, and lights up a warning LED, if DUT current exceeds 200 mA. The protection gets automatically reset when the input voltage goes to 0, which usually means on the next period of the signal generator. This protection is more about saving the curve tracer than the DUT. It's still perfectly possible to obliterate a small transistor that can't handle 5 W of dissipation.

The power to the DUT however can be limited by connecting a load resistor in series, which is similar to how the old Tektronix instruments did it (they came with this nice resistor selection graph). I've left two contacts on the DUT terminal for the load resistor connection. On the photo above they are shorted with a wire jumper.

Curve traces for a 100 ohm resistor.

One of the things I aimed for was also support for high frequency signals since I wanted to observe some dynamic effects. Traditional curve tracers only use 100 Hz or 120 Hz. Above you can see some reference measurements of a 100 ohm carbon-film resistor I did at different frequencies. Ideally, all plots should show a line with a 10 mA/V slope and the same length. However at around 100 kHz the amplitudes start falling and voltage and current are no longer in sync, which causes the curve to open up into an ellipse.

The performance is mostly limited by the slew rate of the amplifiers, especially when observing fast edges, like in an avalanche breakdown. I'm currently using the excellent 4.5 MHz Renesas CA3240, which are one of the fastest operational amplifiers I could get in a DIP package. There's also a limitation on the DUT capacitance. Since I'm using an emitter-follower and not a push-pull output stage, my curve tracer can only tolerate about 150 pF of DUT capacitance at 100 kHz.

Tweaking the high frequency performance was the most challenging part of designing this. Matching the delay between voltage and current outputs involved a lot of experimenting by adding small capacitances into the feedback networks. Despite this effort however each measurement still involves some double-checking to be sure that I'm seeing a real effect and not an artifact of the instrument.

Curve tracer on the desk with other instruments.

In conclusion, I'm reasonably happy how this turned out. Obviously, there are some limitations and in a second iteration of the design I would do some things differently. For example the decision to go with 10 mA/V current output wasn't the best. Decreasing the gain would reduce the slew-rate requirements without losing much precision. The clamp circuit also doesn't work very well at high frequencies due to the opamp going into saturation and could do with a redesign. In the end, it was a useful refresh of my knowledge about various details of imperfect amplifiers.

I've also found out that the XY mode on my Tektronix TDS2002B seem to be a bit crude. You can't have cursors and for some reason it's also impossible to save a screenshot. Also, while the scope does support current probes, the 10 mA/V range is missing so I can't have the proper scale displayed on screen. While it's a bit annoying, it's not too much extra work to save individual traces to CSV in YT mode and then re-plot them with matplotlib or something when I have a measurement I want to save.

Another thing is that there's currently no step generator or any other provision for setting the base current (or FET gate voltage). However I did reserve a contact on the DUT terminal for the base/gate pin and there's a header already wired for a possible future expansion board with that capability. I might make that add-on at one point in the future but currently I'm not missing it too much since I've mostly been using the curve tracer with two-terminal devices.

Finally, if you're interested in this sort of things and maybe designing or building your own curve tracer, I can recommend reading Paul's Building Another Curve Tracer post. He goes into much more detail about the design of his own instrument. Another very useful resource I found is the TekWiki which contains a staggering amount of information about old Tektronix instruments, including manuals and often also full schematics.

Posted by Tomaž | Categories: Analog | Comments »

More about pogo pins, and a note about beryllium

20.12.2019 12:42

Back in November I wrote about reliability problems with a bed-of-nails test fixture I've made for an electronic circuit. The fixture with 21 pogo pins only had around 60% long-term probability that all pins would contact their test pads correctly, leading to a very high false alarm rate. I did a quick review of blog posts about similar setups and scientific literature I've found on the subject. Based on what I've read it seemed that such severe problems were rare. From my own analysis I concluded that likely causes were either dirty test pads or bad contacts inside the pogo pins themselves, between the plunger and the body of the pin. The pogo pins I was using were on the cheaper end of the spectrum, so the latter explanation seemed likely.

Recently I got hold of a set of more expensive pins and, as it happened, also a new digital microscope. I was wondering how the mechanical design of the new pins compared to the old ones, so I looked at them under the microscope. This lead to some new clues about the cause of the problems I was investigating:

Pogo pin tip comparison under a microscope.

Pogo pin tips pictured above from left to right:

a) Harwin P19-0121, new (23.00 € for 10 pieces). Tip material is gold-plated steel.

b) P75-B1 type of uncertain origin, new (4.46 € for 10 pieces).

c) and d) two examples of P75-B1 removed from the test fixture after approximately 1500 mating cycles.

The more expensive Harwin pins show a significantly sharper point than the ones sold by Adafruit. Even when new, the cheaper pins have a slightly rounded tip. Over many mating cycles with a test pad the tips end up being even more flattened. The c) and d) pins above have been used with a flat test point surface on a lead-free HASL-finish PCB (the test setup described in my previous post). I couldn't find any specification of the longevity of the P75-series of pins. Harwin P19 are specified for 100k cycles, so it seems surprising that P75 would wear down so much after less than 2% of that amount. This evaluation by OKI shows that contact resistance of probes for wafer testing starts to rise somewhere after 10k cycles.

These flattened tips do explain somewhat the problem I'm seeing. Compared to sharp ones, dull or rounded contacts have a worse chance of piercing surface contamination on a PCB, like oxide or flux residue. Hence why my analysis showed that the failure rate was related to each production batch. Each batch had a slightly different amount of residue left on the boards and none was perfectly clean. First results show that replacing the pins did have a positive effect on the test reliability (I imagine it's hard to get any worse than that 40% fail rate), but I'll have to wait to get some statistically significant numbers.

In the context of using more expensive pogo pins, another issue came up. Some of the more expensive pogo pins use heads made from beryllium-copper alloy. None of the pins pictured above do, but other head shapes from the same Harwin P19 product line do in fact use beryllium according to their datasheets. Beryllium has some health risks associated with it, especially when it's in particulate form. I was wondering, if I switch the test setup to such pins, how much beryllium would be released into the environment due to parts wearing down in the way I've seen?

First paragraph from the Exposure Assessment Guide.

Image by Beryllium Science & Technology Association

From the microscope photographs above, I'm estimating that approximately 140000 μm3 of material was lost from one pin after 1500 cycles. This value is based on the volume of a cone that's missing above the flattened tips of pins c) and d) and probably overestimates the true amount. Given a BeCu alloy density of 8.25 g/cm3 and assuming beryllium content of 3% by mass, this comes out as approximately 0.04 μg of pure beryllium released into the environment. One figure I found for the recommended beryllium exposure per inhalable volume of air is 0.6 μg/m3.

This means that all accumulated dust from the wear of 15 pins would need to be distributed in a single cubic meter of air to reach the maximum recommended density for breathable air. Considering that the amount of wear shown above happened during a time span of months it seems unlikely that all of it would instantaneously end up gathered in a small volume. I don't know if the missing material would end up in the form of dust around the pins, or would be slowly carried away, smeared little by little on test pads. In any case, based on this back-of-the-envelope calculation beryllium contacts seem reasonably safe to use, even if the amount of beryllium lost isn't completely negligible compared to published exposure limits (but of course, I'm not any kind of a workplace safety expert).

I don't think this result is surprising. Finished products using beryllium are generally considered safe. BeCu alloys have been used for mundane things like golf clubs and musical instruments. Harwin doesn't publish any MSDS documents for their products. Also as far as I'm aware, beryllium use isn't covered by RoHS, REACH and other such regulations. But in any case, it can't hurt following some basic precautions when working with electronic components that incorporate this kind of materials.

Posted by Tomaž | Categories: Analog | Comments »

On reliability of pogo pins

26.11.2019 20:42

A bit over a year ago I designed and built a device for testing assembled printed circuit boards as they come off the assembly line. While I'm not new to electronic test fixtures, this was the first time I've used the bed-of-nails approach: the test jig has a number of spring-loaded pogo pins that make contact with various test pads on the device-under-test (DUT). This setup has now made thousands of cycles and the device proved itself to be capable of detecting a large variety of defects, without doubt preventing many expensive debugging sessions.

However one problem that has been constantly troubling this setup since the beginning is its unreliability. Even after a lot of fussing around with various adjustments, the procedure still has an abysmal false error rate compared to the actual rate of manufacturing defects. In many cases, the operator must remove, re-seat the DUT and restart the test several times before the test will signal a pass. Such test repetitions obviously cause a lot of frustration, decrease the confidence in the testing procedure and significantly lengthen a test that would otherwise take only a few moments. All evidence, like the fact that detected defect types appear completely random and that most test failures disappear when re-seating the DUT, firmly points towards the pogo pins as the cause.

I was surprised at this outcome, since I've never heard about bad contacts being such a problem with pogo pins. There are quite a few blog posts and basic tutorials around about the pogo pin test jigs. Hacker Noon mentions that getting the fine mechanical details correct can be tricky. The Big Mess o' Wires blog says that their test board only worked reliably after three iterations of the design. Thom wrote that they didn't have many issues with contacts on their test jig. It seems that reliability is not a common problem people have with pogo pins, once initial mechanical problems have been ironed out.

Pogo pins mounted on a test fixture.

My bed of nails setup is shown above. It uses P75-type pogo pins - a widely available, cheap variant of uncertain origin. For example, they are sold by Adafruit. The whole bed has 21 pins and uses a combination of needle heads (P75-B1) and cupped heads (P75-A1). There was not enough PCB space on the DUT for all the required test pads so I used cupped head pins to mate with the underside of THT connector pins. P75 pogo pins seem to use exposed steel for the head and plunger (they are slightly magnetic) and only have the gold plating on the bottom body part. I'm not using the mounting sleeves. The pin bodies are directly soldered to the test jig PCB.

The mechanical parts have been removed in the photograph above, but you can get an idea of how they look from the CAD render below. During the test the DUT is securely fixed onto the pins using a clamp, centering pins and a frame. This setup is similar to the one described by Hacker Noon. The difference is that I'm using two parallel PCB boards to position the pins instead of 3D printed parts. The setup was designed so that the pogo pins only compress to approximately half of their 100 mil travel. The mechanical frame carries most of the clamping force.

The boards I'm testing have a lead-free HASL finish and there is no solder paste applied to the test pads. This means that test pads might be sensitive to oxidation. However that shouldn't be a problem since the test is applied shortly after production. It's also worth mentioning that I'm testing an analog circuit. Compared to purely digital tests these are more sensitive to the resistance between the test fixture and the DUT.

CAD drawing of the test device with the bed-of-nails.

Since I have a lot of data collected from the test device I thought statistical analysis might shed some light on the reliability problem. If not directly showing a way to improve the existing device, perhaps it would at least give me some idea what can be expected from pogo pins when designing future test fixtures.

The first thing I was interested in was the resistance between a pogo pin on the test fixture and its corresponding test pad on the DUT. The test procedure was not designed to directly measure this. Fortunately however I found a way to estimate test point resistance for two specific pogo pins (out of 21). I calculated their resistances from certain other measurements I took during the test procedure. Of course, this was not as good as a direct measurement and the estimate is still affected somewhat by variations in some components on the DUT, the test device and resistances of other test points. A Monte Carlo simulation showed an error in the resistance estimate of less than 10 mΩ due to these effects.

As luck would have it, one of the pogo pins I was able to estimate was using the needle head while the second one was using the cupped head. This resulted in the following two histograms of resistances to two test points. They show how commonly each of the two test points exhibited a certain resistance over thousands of matings with the DUT:

Histogram of resistances through a needle-head pogo pin.

Histogram of resistances through a cupped-head pogo pin.

Different colors show data from different DUT production batches. Overall, you can see that most commonly the connection resulted in a resistance of around 0.1 Ω and majority of connections were below 0.5 Ω. This is pretty good, even if somewhat above the 50 mΩ rated contact resistance for this type of pins. The cupped head pin showed less variance than the needle head. Still, the values show much higher variance than the estimated 10 mΩ error, which gives some confidence that this is actually due to changing contact resistances of the pogo pins.

However, one thing that is not visible on these plots is the fact that some connections resulted in estimates well over 1 Ω (approximately 10% for the needle head and 6% for the cupped head). I could also only produce this estimate when the test progressed to the point where some voltage measurements have been made (which depend on a reasonably good contact over 4 pogo pins for needle head pin and 2 pogo pins for cupped head pin). Hence test runs where these measurements were not taken are not included in the histograms above.

So what about these failed attempts? One way to show them is the number of test repetitions that a DUT had to undergo before a test first passed. Using records of thousands of tests, the following histogram emerged:

Number of test repetitions required before the first pass.

Again, the colors show data from different production batches. Overall, approximately 60% of DUTs passed on the first test attempt. A bit above 20% passed on the second and around 10% on the third attempt. You can also see some differences in batches. For example, the batch shown in red was particularly bad and more DUTs required a second repetition than passed the first test. Number of DUTs that failed the test 10 times or more is very small - mostly these are the DUTs that actually had a manufacturing defect and didn't fail due to a false reading on the test fixture.

The histogram shows a nicely exponential characteristic - exactly what you would expect if each test repetition was a random event with a Ppass probability of succeeding. From the data I can estimate that:

P_{pass} = 59.4\%

If I further assume that a test will succeed if all pogo pins contact successfully, and that each of the 21 pogo pin contacts is an independent random event by itself, we can calculate the a probability Pfail-pin that a pogo pin will fail to make a good contact:

P_{fail-pin} = 1 - \sqrt[21]{P_{pass}} \approx 2.4\%

Using this model, I can back predict the probability that a DUT will pass the test after N test repetitions:

P_{pass-after-N-repetitions} = (1 - P_{pass})^{N-1} \cdot P_{pass}

This model fits almost perfectly with the measured histogram, as you can see on the picture below. The predicted number of test repetitions before first pass (red) is laid over the histogram of measurements (gray).

Comparing the model for test repetitions to measurements.

The model also fits reasonably well with number of cases where I've estimated test point resistances above 1 Ω. This might be a bit handwavy since it's hard to see how different failures would affect the results. For the needle-head test point I've seen approximately 10% of cases where resistance was above 1 Ω. This fits well with the fact that 4 points needed to be well connected for the measurement to be accurate and 2.4% failure rate for the connections:

P_{fail} = 1 - (1 - P_{fail-pin})^{N_{pins}} = 1 - (1 - 2.4\%)^4 = 9.3\%

Similarly for the cupped pin measurement, where I've seen 6% of measurements above 1 Ω and required 2 points to be well connected:

P_{fail} = 1 - (1 - 2.4\%)^2 = 4.7\%

In conclusion, my data shows that individual pogo pins seem to have approximately 2.4% chance of not mating correctly with their test points. When they do contact correctly, they usually show a reasonably low resistance of approximately 100 mΩ between the pin and the test pad, with worst cases being less than 500 mΩ. It's not clear from the data what is causing such a high rate of unsuccessful connections. Since the failure rate varies from batch to batch, this suggests that at least part of it is related in some way to the production process (for example, oxide or flux residue on the test pads). On the other hand, it's also possible that the pins themselves are responsible for these failures. The bad contact might in fact be between the plunger and pin body, not between the head and the test pad. In that case it might be worth experimenting with the more expensive pogo pins that have gold plated heads and plungers.

Posted by Tomaž | Categories: Analog | Comments »

Voltage divider cheat sheet

16.09.2019 19:46

The two most common electrical measurements I do these days is measuring output impedance of a source and input impedance of a load. I don't have any special equipment for that. I'm not doing it so often that it would warrant buying or making a specialized tool. Since it's all either DC or around audio frequencies and I'm not interested in very precise values it's a really simple measurement. I usually just use an oscilloscope and whatever else is available around the shop to use as reference loads and sources.

Deriving unknown impedances or resistances from the voltage measurements and reference values is straightforward. It only takes a minute and I must have done it a hundred times at this point by inverting the voltage divider formula. I still don't know the resulting equations by heart though. So to avoid doing it the hundred and first time and the odd mistake, I've made myself a nice cheat sheet to stick above my desk. It contains the formulas for the three most common measurements I make.

Voltage divider measurements cheat sheet

PDF version

The notes about the best accuracy refer to the selection of the reference impedance such that the result is least affected by errors in voltage measurements (which, when measuring amplitudes with an oscilloscope, is the largest source of error in my case). The selection is quite obvious, but I guess I added it there for the sake of rigor.

The cheat sheet is made in LaTeX using the circuitikz package for schematics. I'm mostly putting it here for my own future reference, but maybe someone else will find it useful.

Posted by Tomaž | Categories: Analog | Comments »

What is a good USB cable?

31.08.2019 20:36

In conclusion of my recent series on the simple matter of USB cable resistance, I would like to attempt the question of what is a good USB cable. After having a reliable measurement of a cable's resistance, the next obvious question is of course whether that resistance complies with the USB standard and whether such a cable is suitable for powering single-board computers like the Raspberry Pi. Claims that most cables don't comply with the standard are quite common whenever this topic is discussed. I'm by no means an expert on USB, but luckily USB Implementers Forum publishes the standards documents in their on-line library. I went in and studied some of the documents on the Cable and Connector Specification topic which, among other things, specify cable resistance.

I've started my reading with USB 2.0, because micro- and mini-USB cables I tested in my previous post are unlikely to be older than USB 2.0. The standard is now nearly 20 years old and over the years it seems to have received many revisions and updates. Hence it's hard to pick up a random cable from the pile and say with certainty with which document it should comply. In addition, I find that the text of the standard itself often isn't particularly clear. For example, the following text implicitly defines the maximum allowable cable resistance in the Universal Serial Bus Cables and Connectors Class Document, revision 2.0 from August 2007:

Cable Assembly Voltage Drop requirement for USB 2.0

Image by USB Implementers Forum

Initially I thought this means voltage drop over the pair of wires. As in, total voltage drop over VBUS and GND wires should be less than 125 mV at 500 mA (effectively 250 mΩ round-trip resistance). However the fact that most cables seem to be around 500 mΩ suggests that manufacturers read this as 250 mΩ per wire (500 mΩ round-trip).

A later document amends this definition somewhat and makes it clearer that the voltage drops are for each wire separately and that this voltage drop includes contact resistance. The following is from Universal Serial Bus 3.0 Connectors and Cable Assemblies Compliance Document, revision 1.0 draft from October 2010. Also note that both the measurement current and the allowable voltage drop were increased. The measurement must now be done at 900 mA, however maximum effective single-wire resistance is still 250 mΩ, same as in USB 2.0:

Cable Assembly Voltage Drop requirement for USB 3.0

Image by USB Implementers Forum

An even later document addresses cable compliance with older revisions of the standard. USB 3.1 Legacy Cable and Connector Revision 1.0 from 2017 contains this calculation:

IR drop at device calculation from a USB 3.1 document.

Image by USB 3.0 Promoter Group

This equation clearly shows that the 250 mΩ figure from the other documents is supposed to be combined from two 30 mΩ contact resistances and a 190 mΩ wire resistance. It also multiplies the voltage drop by two due to the round trip through both VBUS and GND wires.

USB type C specification tries to make this even clearer and comes with schematics that explicitly show where voltage drop must be measured. Since in USB type C you can have different types of cables that are rated for different currents, that standard only specifies maximum voltage drop. Note also that in type C the requirements for the VBUS line were relaxed compared to previous standards. Previously, for a cable delivering 1 A of current, the VBUS line must have had a maximum resistance of 250 mΩ while in type C up to 500 mΩ is allowed.

Figure showing cable IR drop from USB Type-C specification.

Image by USB 3.0 Promoter Group

7 out of 12 micro USB and 5 out of 6 mini USB cables I found at my home have less than 500 mΩ round-trip resistance. So according to my understanding of the standard for pre-type C cables, roughly 70% of my cables comply with it. Here are my resistance measurements plotted versus cable length. I've also included measurements published by Balaur on EEVblog and martinm on their blog. Points in the shaded area represent cables that comply with the standard.

Plot of cable resistance measurements versus length.

So strictly according the USB standards, the situation out there isn't perfect, but it doesn't look like the majority of cable are completely out of spec either. This seems a bit at odds with the general opinion that finding a good cable for running Raspberry Pi is hard. However, things start getting a bit clearer when you look at what exactly Raspberry Pi boards demand from these cables.

In the following table I've extracted maximum required power for all Raspberry Pi model Bs from the Wikipedia article. These boards will display the infamous under-voltage warning when their power supply voltage falls under approximately 4.63V. Assuming a perfect 5 V power supply, this is enough data to calculate the maximum allowable cable resistance for powering these boards:

R_{max} = \frac{U_{supply} - U_{min}}{I_{max}} = \frac{5.00\mathrm{V} - 4.63\mathrm{V}}{I_{max}}
Model Max. supply
current [mA]
Max. cable
resistance [mΩ]
RPi 1 Model B 700 529
RPi 1 Model B+ 350 1057
RPi 2 Model B 820 451
RPi 3 Model B 1340 276
RPi 3 Model B+ 1130 327
RPi 4 Model B 1250 296

Raspberry Pi model Bs after version 2 appear to require cables with resistance well below 500 mΩ that the standard requires for micro USB cables. Only 3 cables from my collection would be able to power a Raspberry Pi 3 model B. Raspberry Pi 4 gets a pass because the type C standard is flexible enough and doesn't directly specify cable resistance (although its type C implementation has other power-related issues). Yet, since type C cables have 750 mV maximum voltage drop at rated current, it requires a cable rated for 3 A or more according to this estimate (I'm not sure if Raspberry Pi 4 uses the same APX803 voltage monitor as earlier versions).

Also note that this calculation is for a perfect 5V power supply, which is optimistic. Power supplies don't have perfect regulation and the calculations in the USB standard assume worst case 4.75 V at the source. Such a worst case power supply, even if it provides sufficient current, would require practically zero ohm cables to power a Raspberry Pi without under-voltage warnings and associated CPU throttling.

To sum up, yes there are USB cables out there that are out of spec. However based on this limited sample, most micro and mini USB cables do seem to actually comply with the standard. Also worth noting is that shorter ones tend to have a better chance of being compliant. On the other hand, at least part of the blame for the grief surrounding USB cables appears to fall onto the Raspberry Pi itself since they designed their boards with an requirement for better-than-the-standard cables and power supplies.

Posted by Tomaž | Categories: Analog | Comments »

Resistance measurements of various USB cables

23.08.2019 10:23

After I made my USB cable resistance tester I naturally wanted to measure some cables. I searched my apartment and ended up with a big jumble of 18 micro and mini USB cables of various lengths and origins. I didn't imagine I would find that many, but I guess today just about everything comes with one and I apparently never throw away anything. In fact some cables were in a very bad shape and already had insulation flaking off from old age.

USB kabelsalat.

I measured the resistance of each cable at 1 A using the voltage ratio method I described in my previous post. The following table lists the results. For a lot of cables I don't know their origin and they must have came bundled with various devices. I've listed the brand if it was printed on or if I knew for certain which device the cable came with. I'm afraid this comparison isn't very useful as a guide which cable brand to buy, but it does give an interesting statistic of what kind of cables can be found out there in the wild.

N Brand Color Type Length [cm] R [mΩ]
1 Wacom Black A / micro B 28 199
2 CellularLine Gray A / micro B 207 212
3 White A / micro B 105 224
4 White A / micro B 51 294
5 Wacom Black A / micro B 98 334
6 Samsung Black A / micro B 82 408
7 Nokia Black / gray A / micro B 115 490
8 CubeSensors White A / micro B 103 522
9 Black A / micro B 103 569
10 HTC Black A / micro B 128 597
11 Google Black A / micro B 153 613
12 Amazon White A / micro B 182 739
13 Silver A / mini B 30 177
14 Black A / mini B 146 323
15 Black A / mini B 125 396
16 Silver A / mini B 56 412
17 Canon White A / mini B 125 435
18 Silver A / mini B 180 804

Unsurprisingly, two short 30 cm cables came out as best in terms of resistance, measuring below 200 mΩ. A bit more unexpected was finding out that the 2 m CellularLine isn't far behind. This is a fancy and laughably overpriced cable I bought in a physical store not so long ago, the only one on this list that I'm sure didn't come bundled with any device. It appears in this case the price was at least somewhat justified.

I was also a bit surprised that some cables that came bundled with devices measured pretty high. The white Amazon was for charging a Kindle 3 and it had the highest resistance among the micro B cables I tested. On the other hand, it was also in pretty bad shape, so it might be that it was damaged somehow. Cables bundled with an HTC phone and Google Chromecast also measured more than 500 mΩ.

Other measurements I could find on the web seem to roughly agree with mine. martinm lists measured values between 289 and 1429 mΩ. Balaur on EEVblog forum measured between 276 and 947 mΩ on his cables. The only report that was really off was this forum post by d_t_a where most of the cables listed are lower than 200 mΩ.

Another thing I was interested in was how repeatable these measurements were. I mentioned several times in my previous posts that contact resistance can play a big role. Since each time you plug in a cable the contacts sit differently and have a slightly different resistance, contact resistance behaves like a random variable in the measurement results. When I was doing the measurements above this was quite obvious. Minimal movements of the cable caused the voltage displayed on the voltmeter to dance around.

Histogram of 10 measurements of cable 16.

I repeated the measurement of cable 16 from the table above 10 times. Before each repetition I unplugged and re-plugged both ends of the cable. Above you can see the histogram of those measurements. The results only vary for approximately ±1%, which is much less than I thought they would. This is about the same as the expected error of the measurement itself due to the accuracy of the reference resistor. Of course, this was all done over a short period of time. I'm guessing the resistance would change more over longer periods of time and more cycles as contacts deteriorate or gather dirt.

I also checked how the measurement is affected if I plug something between the tester and the cable. Gino mentioned in a comment they used an adapter and an extension cable in their measurement. So I repeated the measurement of cable 1 from the table with a short type A-to-type A extension in series. Just for fun, I also tested how much resistance a cheap USB multimeter adds:

Assembly R [mΩ]
Cable 1 202
Cable 1 + 45 cm extension 522
Cable 1 + Muker V21 multimeter 442

As you can see from the results above, both of these added quite a lot. With the excellent 200 mΩ cable, both more than doubled the total resistance. Even with an average 500 mΩ cable, this multimeter would add around 240 mΩ or approximately 50% on top. Battery-powered devices like smartphones adjust their charging current according to the voltage drop they see on their end. Hence they might charge significantly slower when the multimeter is in series with the cable compared to just using a cable. This puts some doubt on the usability of these USB multimeters for evaluating USB cables and power supplies.

Posted by Tomaž | Categories: Analog | Comments »

USB cable resistance tester

18.08.2019 17:04

Back in June I did a short survey of tools for measuring resistance of power supply lines in USB cables. I was motivated by the common complaint about bad cables, often in the context of powering single board computers like the Raspberry Pi. I wasn't particularly happy with what I found: the tool wanted to buy was out of stock, and I've seen various issues with others. Having already dug too deep into this topic I then set out to make my own tool for this purpose.

So roughly two months later I have a working prototype in my hands. It works as designed and I spent a few hours measuring all the USB cables I could get my hands on. I'm reasonably happy with it and can share the design if anyone else wants to make it.

USB cable resistance tester.

As I mentioned in my previous post, I really liked the approach of FemtoCow's USB cable resistance tester and I basically copied their idea. Since USB type C is gaining in popularity I've added connectors so that A-to-C and C-to-C cables can be tested in addition to A-to-mini B and A-to-micro B, I've taken care that even with the added connectors, the voltmeter still has Kelvin connections in all combinations. I've also added proper 4 mm test sockets for all connections.

Simplified schematic of the USB cable tester.

The principle of operation is very simple. Electrically, the resistance tester consists of two parts. On one end of the cable is a reasonably accurate 1 Ω resistor in series with the cable's VBUS and GND lines. The other end only shorts the VBUS and GND lines together. The power supply is used to set a current through the cable. The measured resistance of the cable, which consists of the sum of the four contact resistances and resistances of the two copper cores, can then be calculated as:

R_{measured} = R_{VBUS} + R_{GND} = R_{ref}\frac{U_{measure}}{U_{calibrate}}

Or, if set current is 1 A, the voltmeter reading in volts directly corresponds to the measured resistance in ohms:

R_{measured} [\Omega] = U_{measure} [\mathrm{V}]

The nice thing about this approach is that the cable can be tested at an arbitrary current. If the first equation is used, the accuracy of the method does not depend on the accuracy of the current setting. It even doesn't depend much on the calibration accuracy of the voltmeter: since a ratio of similar voltages is used, any linear error cancels out. The only requirement is that the voltmeter is reasonably linear over the 0.1 V to 1 V range. Since Kelvin connections are used, the resistance of the PCB traces has negligible effect on measurements as well.

The only critical component is the reference resistor. 1% resistors are widely available, so getting to that kind of measurement accuracy should be trivial. With some more effort and a bit higher price, 0.1% current sense resistors aren't that exotic either. For my tool I went with a cheap 1% thick-film resistor since I considered that good enough.

USB cable tester connected to a multimeter.

After measuring a pile of cables, some shortcomings did become apparent that I didn't think of earlier: I really should have added a switch for the voltmeter instead of having four test sockets. Constantly re-plugging the test leads gets tiring really fast. It also affects the measuring accuracy somewhat since it's hard to re-plug the cables without moving the tool slightly. Since moving the connectors results in slightly changing their contact resistances, it's hard to measure both voltages in the exactly the same setup. The errors because of that seem minimal though.

Another thing I noticed is that with my analog power supply, setting the current to exactly 1 A wasn't possible. Since I have only one knob that goes from 0 to 25 V in one rotation, setting low voltages requires very small movements of the knob and isn't very accurate. Hence I mostly used the ratio equation for my measurements. My power supply also tended to drift a bit which was a bit annoying. The power supply at work with a digital interface worked much better in that respect.

Finally, I'm not sure how harmful this kind of test is for type C cables that contain active parts, like the electronically marked power delivery cables. I didn't test any so far. All schematics I could find show that the power delivery ID chip is powered from the VCONN line, which is left unconnected in this tool, so that should be fine. On the other hand, the active cables that do signal conditioning do seem to be powered from VBUS. It's possible, although I think unlikely, those could respond weirdly or even be damaged by the low voltage applied during this test.

If you want to make a tool like this, you can find all required Gerber files and the bill of materials in the GitHub repository. While it might be possible to etch and drill the board yourself, I highly recommend using one of the cheap PCB prototyping services instead. The USB C connectors require very small holes and SMD pads that I think would be pretty challenging to get right in a home workshop. There are some more notes in the README file regarding that. On the other hand, the Würth connectors listed in the BOM are solderable with only a soldering iron, so manual assembly is reasonably straightforward with no hot air station required. However again the type C ones can be pretty tricky due to the fine pitch.

Posted by Tomaž | Categories: Analog | Comments »

Measuring USB cable resistance

28.06.2019 15:04

I'm commonly hearing questions about finding good USB cables for powering single-board computers like the Raspberry Pi. The general consensus on the web seems to be that you need a good USB charger and a good USB cable. A charger typically has a specification, which gives at least some indication of whether it will be able to deliver the current you require. On the other hand, no USB cable I've seen advertises it's series resistance, so how can you distinguish good cables from bad?

Since it bothered me that I didn't have a good answer at hand, I did a bit of digging around the web to see what tools are readily available. Please note however that this isn't really a proper review, since I haven't actually used any of the devices I write about here. It's all just based on the descriptions I found on the web and my previous experience with doing similar measurements.

A bunch of random micro USB cables.

On battery-powered devices, like mobile phones, using a cable with a high resistance is hardly noticeable. It will often only result in a slightly longer charge times, since many battery management circuits adjust the charging current according to the source resistance they see. Unless the battery is completely dead, it will bridge any extra current demand from the device so operation won't be affected. Since most USB cables are used to charge smartphones these days, this tolerance of bad cables seems to have led us to the current state where many cables have unreasonably high resistance.

With a device that doesn't have its own battery the ability of the power supply to deliver a large current is much more important. If the voltage on the end of the cable drops too much, say because of high cable resistance, the device will refuse to boot up or randomly restart under load. Raspberry Pi boards try to address this to some degree with a built-in voltage monitor that detects if the supply voltage has dropped too much. In that case it will attempt to lower the CPU clock, which in turn lowers current consumption and voltage drop at the cost of computing performance. It will also print out an Under-voltage detected warning to the kernel log.

Measuring resistance is simple theoretically, it's just voltage drop divided by current. However in practice it is surprisingly hard to do accurately with tools that are commonly at hand. The troubles boil down mostly to non-destructively hooking up anything to a USB connector without some kind of a break-out board and the fact that a typical multimeter isn't able to accurately measure resistances in the range of 1 Ω.

"Charging slowly" on the bottom of Android lock screen.

Gašper tells me he has a method where he tests micro USB cables by plugging them into his smartphone and into a 2 A charger. If the phone says that it is fast charging, then the cable is probably good to power a Raspberry Pi. I guess the effectiveness of this method depends on what smartphone you're using and how it reports the charging rate. My phone for example shows either Charging or Charging slowly on the bottom of the lock screen. There are also apparently dedicated apps that show some more information. I'm not sure how much of that is actual measurement and how much is just guesswork based on the phone model and charging mode. Anyway, it's a crude, last resort method if you don't have any other equipment at hand, but it's better than nothing.

Riden UM34 USB multimeter

Image by Banggood

The ubiquitous USB multimeters aren't much use for testing cables. All I've personally seen have a USB A plug on one end and USB A socket on the other, so you can't connect them on the end of a micro USB cable. The only one I found that has a micro USB connector is the Riden UM34C. Its software also apparently has a mode for measuring cable resistance, as this video demonstrates, which conveniently calculates resistance from voltage and current measurements. However, you also need an adjustable DC load in addition to the multimeter.

I can't say much about the accuracy of this device without testing it in person. I like the fact that you can measure the cable at a high current. Contacts in connectors usually have a slightly non-linear characteristic, so a measurement at a low current can show a higher resistance than in actual use. The device also apparently compensates for the internal resistance of the source. At least that's my guess why it requires two measurements at approximately the same current: one with a cable and one without.

This was the only reasonably priced device I found that was actually in stock and could be ordered in an ready-to-use state.

USB Cable resistance tester from FemtoCow

Image by FemtoCow

I really like the approach FemtoCow USB cable resistance tester takes. It's very a simple PCB that allows you to use an adjustable lab power supply and a multi-meter to measure the resistance. It seems perfect when you already have all the necessary lab equipment, but just need a convenient setup with a reference resistor and a break-out for various USB connectors. I wanted to immediately order this one when I found it, but sadly it seems to be out of stock.

What I like about this method is again the fact that you are measuring the resistance at a high current. The method with the shunt resistor can be very accurate, since it doesn't depend on the accuracy of the multimeter. If the resistor value is accurate (and 1% resistors are widely available today), even multimeter calibration doesn't really matter, as long as the scale is roughly linear. The PCB also looks like it uses proper Kelvin connections so that resistance of the traces affects the measurement as little as possible.

USBcablecracker from SZDIY.

Finally, Gašper also pointed me to an open hardware project by the Shenzhen hackerspace SZDIY. The USB Cable Cracker is a stand-alone device based around the ATmega32U4. It tests the cable by passing approximately 25 mA through it. It then measures the voltage drop using an amplifier and ATmega's ADC and calculates the resistance. A switch allows you to measure either the power or the data lines. The measured value is displayed on an LCD. Gerber files for the PCB layout and firmware source are on GitHub, so you can make this device yourself (0603 passives can a bit of a pain to solder though). I haven't seen it sold anywhere in an assembled state.

The analog design of this device seems sound. The biggest drawback I think is the low current it uses for measurement. The digital part however looks like an overkill. The author wanted to also use it as a general development board. That is fine of course, but if you're making this only for testing cables, having an expensive 44-pin microcontroller just for using one ADC pin seems like a huge waste. Same with the large 16x2 LCD that only shows the resistance. Another thing that I was missing was a more comprehensive BOM, so if you want to make this yourself be prepared to spend a bit of time searching for the right parts that fit the PCB layout.

In conclusion, this problem of measuring USB cabling was a bit of a rabbit hole I fell into. For all practical purposes, probably any of the methods above is sufficiently accurate to find out cables that are grossly out of spec. I guess you could even do it with a 3½ digit multimeter on the 200 Ω range and a cut-off extender cable as a break-out to access the connections. In the end, if all you're interested in is stability of a Raspberry Pi, just switching cables until you find one where it runs stable works as well.

On the other hand, there is some beauty in being able to get trustworthy and repeatable measurements. I wasn't happy with any of the tools I found and considering I already wasted plenty of time researching this I decided to make my own. It's heavily inspired by FemtoCow's design and I'll write about it in another post.

Posted by Tomaž | Categories: Analog | Comments »