Gas station without pumps

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 September 6

Wilder Ranch

Filed under: Uncategorized — gasstationwithoutpumps @ 11:27
Tags: , ,

Yesterday, my son and I took a bike ride through Wilder Ranch State Park and UCSC.  We had a fun, though somewhat warm ride.  The weather was unseasonably hot over Labor Day weekend, hitting an all-time high for Santa Cruz of 108°F.  We were promised cooler weather on Tuesday, but the temperature was well over 80°F at noon.  We waited until 1:30, when the temperature finally dropped below 80°F before leaving the house.

We headed out on the paved bike path to Wilder Ranch, up Engelman’s Loop  and Long Meadow Trail to the Chinquapin Trailhead, then across Empire Grade to UCSC property, down past the Painted Barrels (there are actually two sets of barrels—Google doesn’t map the more northerly set, which were just after we entered the woods again from Marshall Field).  On the way down from campus, we stopped at the overlook above Pogonip Park and at the UCSC farm stand, where I bought some apples, cauliflower, and flowers.  The farm stand seems to have less produce this year than in previous years—I don’t know whether this is because the farm is producing fewer varieties or that they have better marketing outlets elsewhere.

Because we were doing the ride mid-week, we saw only a few other bike riders—maybe 5 or 6 on the paved path out to Wilder Ranch, one couple on the trails in the park, a pack of middle schoolers with adult guides on the UCSC trails, and a few bike commuters on the UCSC roads.  I suspect that the Wilder Ranch trails are more populated on weekends.

A map of our route. It was 13 miles (21 km) with 1178 feet (360m) of climbing.

I used Google Maps to make a route map of the route we took, which was harder than I expected.  At first I just dragged around intermediate points using Google directions, but Google kept throwing out the route.  Then my son pointed out that I could use the “+” button in directions to grow the route incrementally, though that required  couple of tries to work also, as there is a small limit on the number of points you can add, so I had to be very choosy about which points I added.

The weather was really a bit too warm for strenuous exercise, but we had cloud cover for much of the ride, so it wasn’t as bad as it could have been (certainly not as bad as last weekend would have been).  Today might have been a better choice, as the hot weather seems to have ended and we’re back to more normal temperature swings.

Neither of us have mountain bikes—my son rides a commuter bike with narrow road tires, and I have my Vanguard long-wheelbase recumbent.  The loose gravel, deep dust, and ruts of the trails in Wilder Ranch were a little difficult for us to handle, though mountain-bike enthusiasts would have found them tame.  I had to get off and walk my bike on a few steep hills, because I fell below my minimum balance speed and couldn’t start again on the loose gravel.  I only fell once—trying to get out of a rut on a steep uphill and falling below minimum balance speed.

It would have been good to do more bike riding this summer with my son—he’s headed back to UCSB in just over 2 weeks, and we’re making a trip to Boulder to see my Dad next week, so I doubt that we’ll have time to schedule another bike ride.

2017 September 2

Correcting reasoning on buck regulators

Filed under: Robotics — gasstationwithoutpumps @ 13:10
Tags: , ,

In More on cheap buck regulators, I wrote

We can fix the windup problem by either reducing the integrator coefficient (reducing the capacitor size on the COMP node, whose current size I’m uncertain of) or by using a larger inductor, so that the current changes less when the FET switches, and the time constant of the system is better matched to the integration time constant set by the RC value.

I was worried even as I wrote that claim that my reasoning was wrong.  Increasing the inductance would make the voltage on the output capacitor adjust more slowly, meaning that the system was even more under-actuated, resulting in more integrator windup. But I went ahead and bought some surface-mount 10µH inductors and put one on the board that I had taken the 1.5µH inductor off of.

In testing under light loads, the larger inductor works fairly well, though regulation is sometimes lost for short bursts even with a 145mA load.

resistance current 1.5 µH ripple 10 µH ripple
∞Ω 0 mA ±7mV ±18mV
40Ω 145 mA ±32–50mV ±36–45mV
32Ω 184 mA ±37mV ±36mV
24Ω 245mA ±60mV ±63mV
16Ω 374 mA ±50mV ±126mV
740mA ±65mV ±805mV
1388 mA ±435mV ±1186mV

So larger inductors give similar control at low currents, but hit the integrator windup problem at lower current levels.

I can think of two fixes:

  • Making the capacitor of the compensation circuit smaller, so that there is less integrator windup.  I’m not sure what that will do to the stability of the regulator.
  • Adding an LC filter to the output, to remove the ripple.  Because of the resistance of the inductor, this will entail some loss of efficiency.

I tried add a 1.5µH and 10µF low-pass filter to the output of the regulator, measuring current and voltage after the filter:

resistance current 1.5 µH ripple 10 µH ripple
∞Ω 0 mA ±7mV ±12mV
40Ω 146 mA ±3.6mV ±3.5mV
32Ω 185 mA ±4.3mV ±4.5mV
24Ω 246mA ±5mV ±8.5mV
16Ω 376 mA ±7mV ±12mV
740–760mA ±7mV ±194mV
5.3Ω 1090mA ±12mV–±220mV ±500mV
1388 mA ±314mV ±510mV

Adding LC filtering seems to be a big win, but the original 1.5µH inductor is still the better choice.  I get good regulation at 0.75A, but ripple starts gets big at 1.4A.  At 1A, I sometimes get a very steady output and sometimes a large 123kHz ripple, unpredictably

The voltage drop across the 1.5µH filter inductor is about 0.2V at 1A, so I’m losing about 3% in efficiency, but the 200mW loss is not enough to cause heating problems in the inductor.  For the application I’m looking at, I don’t expect continuous currents

Changing the compensation capacitor will be harder, as it seems to be an 1005 capacitor (0402 Imperial), which is a little small for my clumsy fingers and tweezers—changing the much larger inductor was enough of a challenge for my dexterity.  I don’t know exactly how many pF  the capacitor is, either, so I’d probably have to do a lot of trial-and-error fitting, or take the capacitor out and try measuring it not in the circuit.  Getting probes onto such a small part is going to challenging when it is not on a board.

2017 August 28

More on cheap buck regulators

Filed under: Robotics — gasstationwithoutpumps @ 18:40
Tags: , ,

A couple of days ago, I wrote about the cheap buck regulators I bought, and expressed some confusion about how poorly they were working.  I’ve spent a couple of days trying to diagnose the problem, and I think it is beginning to make some sense to me.

First, the parts are almost certainly knockoffs of the original MP1584 parts, since those parts cost over $1 in 1000s and the whole board was about 44¢ in 1s.  I’ve not been able to find a good photo of an authentic part, to see if the markings match. The only data sheet available is the original one, which may or may not describe the internals of this chip accurately.

Second, I unsoldered the inductor from one of the boards using a hot-air tool, and soldered on header pins for easy testing.  The inductor appears to be a 1.5µH inductor (though the picture on the website clearly showed a 4.7uH inductor).  The smaller inductor results in larger current ripple.  According to the datasheet, a 1.5µH inductor for a 6V output with a 12V input and 930kHz switching frequency would result in about a 2A peak-to-peak current ripple, and the peak current would be about 1A higher than the load current.  Since the part is supposed to have a maximum switch current of 4A, this is consistent with a 3A limit for the board.

Third, I reverse-engineered the board as best I could by tracing wires, reading resistor values, and measuring capacitances.  It is hard to measure capacitance in circuit, and only the input and output capacitors are reasonably reliable.


Reverse-engineered board schematic. The design is essentially the same as the examples in the data sheet (other than too small an inductor).

I spent a lot of time with my Analog Discovery 2, trying to plot voltage and current curves for different loads.  I ran into some difficulty, as my 1Ω power 10W resistor that I tried using for sensing had too much inductance, so I ended up using two 0.5-ohm ¼W resistors in parallel for my sense resistor. (For lower currents, I initially used just one resistor, but at high currents that would have gotten too hot.)

I tried also playing with non-resistive loads (putting an inductor in series with the resistor or a capacitor in parallel).  What I expected to see was that putting an inductor in series would reduce the current ripple, and that putting a capacitor in parallel would reduce the voltage ripple.  Putting a 100µH inductor in series with the load did indeed smooth out the current ripple as expected.

But capacitors had a weird effect. Here are some of the plots:

Putting a big low-ESR (aluminum polymer) capacitor in parallel with the load increased the voltage ripple instead of decreasing it!

Voltage ripple was fairly constant for moderate loads, but got extreme once the current requested got high.

The ±50mV voltage ripple had a frequency of about 930kHz, which was consistent with the 100kΩ resistor used on the FREQ input. At larger currents  (somewhere between 1.34A and 1.46A) the frequency dropped by a factor of 4 or 5, and the ripple went way up.

At first, I could not understand how capacitors could increase the ripple, nor could I make sense of the dV/dt slopes of the voltage.  Partly this came from misunderstanding the block diagram:

Block diagram, copied directly from the data sheet for the MP1584 (copyright Monolithic Power Systems Inc.).

I thought that the system was a simple PWM system, with the oscillator turning on the nFET between SW and Vin, and the feedback deciding when to turn it off.  When the nFET is on, the inductor (and load) current rises. When the inductor is off, the inductor continues to conduct, pulling SW down and eventually turning on the Schottky diode.

The set-reset latch (cross-coupled NAND gates) in the middle makes it look like a simple 2-state system: ON and OFF, but it turns out to be more complicated than that.  The oscillator does indeed turn the nFET on, but the feedback does not turn it fully off. Instead, the nFET oscillates between being on and being off, possibly based on the SW voltage.  The block diagram shows the gate voltage of the nFET as being referenced to SW, so once the nFET is off it should stay off, but I suspect that there are delays that result in the nFET turning back on as SW drops (at least if SW drops fast enough).

I tried looking at the input current to the regulator, which should spike up every time the nFET is turned on.  (Because I was using a 0.25Ω sense resistor on the input and the input capacitor seems to be 10µF, there is a 2.5µs RC time constant that averages out the input current, keeping it from appearing as large spikes.)

The spikes on the input current shows that the nFET turns on and off several times during the cycle, not just once when the oscillator requests it. The input current spikes correspond to places where the output voltage is rising.
Note: this plot averages 500 traces, to reduce the noise on the current measurements.

So the system is not a simple PWM switching between on and off, but switches between on and pulsing. The pulses seem to be around 7.4 MHz, much faster than the oscillator (about the 8th harmonic).

I think I have an explanation for the switching to lower frequencies for the ripple and getting larger ripples at low frequencies. The R+C circuit on the COMP pin is integrating a current proportional to the error to get an error control voltage.  That means that we have essentially a PI (proportional-integral) control loop, with R setting the coefficient for P and C setting the coefficient for I.  When we don’t have sufficient actuator values (that is, when we can’t raise the voltage fast enough with the FET on or lower if fast enough with the FET off), the integrator suffers from “integrator windup” (see my discussion in controlling temperature with just a heater and fan), accumulating lots of error that takes time to be erased.  Windup causes there to be massive overshoot.

We can fix the windup problem by either reducing the integrator coefficient (reducing the capacitor size on the COMP node, whose current size I’m uncertain of) or by using a larger inductor, so that the current changes less when the FET switches, and the time constant of the system is better matched to the integration time constant set by the RC value. [Update 2017-Sep-2: the reasoning here is wrong.  See Correcting reasoning on buck regulators.]

The data sheet makes it clear that the MP1584 is not designed to be used as an adjustable regulator—the R3 and C3 values for the compensation need to be adjusted based on the load resistance, the output capacitor, the output voltage, and the frequency.  They recommend choosing a switching frequency, then setting a crossover frequency to about 0.1 times that.  If we keep the 930kHz switching frequency, then f_c=93kHz.  They then recommend R_3=\frac{2\pi f_c C_2}{G_{EA} G_{CS}} \frac{V_{out}}{V_{FB}}, where C_2 is the output capacitance G_{EA}=60\mu A/V is the error amplifier transconductance, G_{CS}=9A/V is the current-sense amplifier transconductance, and V_{FB}=0.8V is the feedback voltage.  For a 10µF output capacitor and a 6V output, this would set R3=81kΩ, close to the 100kΩ chosen.  With a 470µF output capacitor, R3 would need to increase to around 390kΩ.

To choose C3, they recommend C_3 > \frac{4}{2\pi f_c R_3}, or C_3 > 68pF for R3=100kΩ, and I think that they chose 100pF (but I’m not certain).  With this method for picking R3 and C3, they are setting the RC time constant larger than 4 times the time constant for the crossover frequency, or larger than 40 times the time constant for the switching frequency.  The tradeoff between R3 and C3 is based on the output capacitance  (and output voltage and switching frequency), with larger output voltage, capacitance or switching frequency increasing R3.

I think that the values for R3 and C3 are reasonable on the board, but there is nothing on the data sheet about what to do when integrator windup happens—they recommend big enough inductors that I don’t think it is a problem for them, so I’m going to try replacing the inductor on the board with a good 10µH inductor, probably Abracon ASPI-0630LR-100M-T15, which looks like it is close enough in size to solder onto the same pads.  I’ll let people know in a couple of weeks whether this works.


2017 August 26

Review of cheap buck regulators

Filed under: Robotics,Uncategorized — gasstationwithoutpumps @ 14:15
Tags: , ,

I recently bought some very cheap buck regulators from Ali Express:

At only 44¢ each with claimed specs

Input voltage: 4.5V-28V
Output voltage: 0.8V-20V
Output Current: 3A (maximum)
Conversion efficiency: 96% (maximum)
Output ripple: <30mV
Switching Frequency: 1.4MHz (highest), typical 1MHz
Operating temperature: -45 to +85 degrees Celsius
Dimensions: 22mm * 17mm * 4mm

they seemed too good to pass up.  The data sheet for the MP 1584EN chip seemed to justify the claims, so I bought three of them to try out.

I’ve done a little testing with a 12V input and the output set to 6.08V, and they seem not to work as specified:
DC RMS voltage [V] DC RMS current [mA] Peak-to-peak ripple [mV] ripple freq [kHz]
6.091  0 15.09 6.29
6.098  1.9  69.1  34.0
6.084  16  70.1 65
6.077  194  75.8  930.4
6.072  376  104 929.1
6.072  568  122.8  929.7
6.163 1309 2266 168.1
6.084  2131  1576  230.3

The regulation to an average voltage is fine, but the ripple is enormous! Adding a capacitor (470µF aluminum polymer) helps at higher currents, but not much, and hurts at the 0.3–0.6A level:

DC RMS voltage [V] DC RMS current [mA] Peak-to-peak ripple [mV] ripple freq [kHz]
6.090  0  7 0.0396
6.090  1.9  28.2  35.5
6.090  15.8  18.4  3.6
6.077  194  75.5  930.3
6.078  375  310.3  465.2
6.083  568  630.6  465.8
6.091  1246  910  464.9
6.088  2112  1028  461.4
A 1µF ceramic (instead of a 470µF electrolytic) actually helps more at the higher currents, possibly because the electrolytic capacitor is too slow to respond (large equivalent series resistance and lead inductance).
DC RMS voltage [V] DC RMS current [mA] Peak-to-peak ripple [mV] ripple freq [kHz]
6.090  0  11.4 7.8
6.090 2.2  59  30.7
6.090  16.7  62  62
6.077  194  82  930.3
6.077  376  123  929.3
6.071  577  137  929.6
6.075  1297  189  928.0
6.088  2155  636  305.4

Still the regulator is way out of spec for ripple pretty much across the board.

The only explanation I’ve come up with for this way-out-of-spec behavior is that the manufacturers may have used a very cheap inductor which saturates at a much lower current than the 3A this regulator is supposed to provide.  A 150mA 10µH inductor costs about 3¢, while a 3.2A one costs about 17¢ (in 1000s)—on a 44¢ device, that’s a big difference in cost!  (In single-unit quantities, the price is more like 50¢ each for a beefy enough inductor.)

The inductor is not labeled, so determining what it is would require removing it from the board and soldering on some test leads.  That might be worth doing, especially if I could find a decent inductor of the same size (both physically and in terms of inductance) to replace it with.  If a 50¢ part fixes the boards, they might still be worthwhile, as adequately beefy DC-DC converters from reputable companies cost $10 or more, and designing and building my own board would cost a lot more than just replacing the inductor.

Next Page »

Create a free website or blog at

%d bloggers like this: