# LDO stability with resistor in the feedback path

I am working on a circuit for measuring very low and very "fast" currents (think: measuring power consumption of an MCU). I found out that I can measure what I want with a sense amp and a shunt resistance of 270R. The load needs around 2.5 V and can have a peak current of 20 mA but the usual current is well below 1 uA. At the maximum current the shunt would be dropping 5.4 V so I picked a regulator (LT3042) that has an independent sense pin to compensate for the drop in the shunt.

When I connect a fixed load (resistor or current DAC) the circuit works exactly as desired but when I connect the real load (an MCU) the circuit starts to oscillate and the voltage at the load is lower than desired.

When I short the shunt with a piece of wire the circuit immediately stabilizes and delivers proper fixed voltage but goes bad immediately when I remove the wire.

R1 & C1 are to stabilize the regulator. Without them the regulator delivers unreliable voltages in all circumstances.

Is there a a better topology (or components) for an adjustable LDO that can regulate the voltage behind a 270R shunt?

simulate this circuit – Schematic created using CircuitLab

CH 1 (top blue trace) is the voltage "before" the shunt. CH 2 (bottom red trace) is the voltage "after" the shunt (at the load), it should be 2.5 but oscillates between 1.8 and 2.47 V.

UPDATE 1

Cset = 4u7 reduced the output ripple a little bit but there are still wild oscillations on the regulator output.

UPDATE 2

I was able to reduce the shunt to 45R and increase sense amp gain. The output still oscillates but now the voltage after the shunt has a ripple of 5 mV which is "good enough".

Both channels AC-coupled:

• Make C3 more like 10 uF and retry. Sep 11 at 11:32
• @Andyaka I think that a bigger C3 would defeat the purpose of measuring fast transient currents. Now, whether measuring those is really necessary or not, is another question :) Sep 12 at 12:55

You must use a capacitor in parallel with Rset (sets the output voltage, should be 25k for your application). Drop across Rset sets the reference voltage for the regulator's error amplifier, so it should be stable and noise-free. Also the cap is needed for better transient response (Refer to datasheet p.12 for details).

The 270R shunt resistor appears in the transfer function and therefore may alter the regulator's overall behaviour. So it's better to keep it as low as possible. I don't know what accuracy you have targeted but for most applications a few tens or hundreds of milliohms should work.

Another option is to use that shunt resistor before the linear regulator. Theoretically, the input current is equal to the output current so it should give the same drop. This way the the shunt won't change the behaviour because it won't be a part of the transfer function. But in practice the drop across the shunt will include the regulator's internal current draw which can be a few tens of microamps or a few milliamps, depending on the regulator chip. So the results will be off by some amount. Again, depending on your accuracy target this can be compensated.

• The pre-regulator sense also has the issue that the sensed signal is filtered through Rsense-C1, so you might not get the required temporal detail. Sep 11 at 11:40
• @colintd Sorry, I can't see how the signal to SENSE is filtered. Sep 11 at 12:23
• The sense resistor before the regulator, and the regulator output cap form a low pass filter, so short term spikes on load current (which the questioner stated they wanted to monitor) will come from the output cap not through the sense resistor. Only longer term average current will be visible across the sense resistor. Sep 11 at 12:30
• @colintd Oh, okay. You meant placing the sense resistor before the regulator (that I stated in the last paragraph). For a moment I thought you meant the circuit in OP's application. Sorry. My bad. And yes, you are right on that. Sep 11 at 12:35
• Actually now I think again, it is more complex than that, because of the feedback loop in the regulator, but for "fast" transients in load current (MHz level you might expect from MPU) it will definitely have an impact. Sep 11 at 12:36

That's a lot of shunt resistance.

Suppose you have x100 sense amplification, and 5V full-scale output at 20mA. The sense resistance only needs to be 2.5Ω.

With a 2.5Ω shunt, the loop should have wider bandwidth while remaining stable on all but the widest-bandwidth LDOs. The quiescent current should be probably a bit higher than what you have to keep the LDO conductance constant-ish. I'd set the idle between 1x and 5x the full-scale load current presented by the MCU.

With x100 gain and 5V full scale, 1uA gives 0.25mV, and a 16-bit ADC will have no trouble resolving that.

An ADC with a built-in PGA can absorb the 2nd gain stage.

Here's a little calculator I've put together: https://www.wolframcloud.com/obj/kuba0/Published/ISense%20Calculator.nb

Mathematica source:

V = Quantity[1, "Volts"];
A = Quantity[1, "Amperes"];
Manipulate[
soln = Solve[Vs V == Is A*Rs*G, {Rs}],
{{Vs, 5}, ControlType -> InputField},
{{Is, 0.02}, ControlType -> InputField},
{{G, 100}, ControlType -> InputField}
]


The C1-Rshunt phase shift is almost certain to cause you issues. The regulator's separation of Out and Outsense is only designed to provide Kelvin monitoring/compensation of losses in the output pin connection, not a 270R sense resistor.

To get stable operation, you would have to do a detailed analysis of the pole you've introduced into the feedback loop, and shift it relative to the regulator gain function via a compensating capacitor in parallel with Rset.

Edit As noted in the other answer, you are also missing the Cset capacitor which is supposed to be in parallel with Rset (see datasheet example circuit). Without this, you are bound to have issues.

• I think it is the Rshunt / C3 phase shift that is the problem. C1 is driven directly by the regulator output, which is a very low impedance causing very little phase shift. Sep 11 at 12:38
• If the traces are accurate (rather than being undersampling artifacts), then the oscillation is about 2KHz. 4.7uf and 270R give an RC time constant of ~1ms, which was what made me think the issue was Rshunt & C3. However, you might well be right, Sep 11 at 13:10

This whole configuration is flawed- you're adding a ton of phase shift and destabilizing the regulator. The di/dt from the MCU will be very high compared to the bandwidth of the regulator.

I suggest separating your measurement into two regimes using two different shunts (one at a time). Parallel the higher resistance shunt with a diode when measuring the low currents (so the MCU doesn't crash). The leakage of, say, a BAT54 is only a few nA (typically, room temperature) with 1mV across it (3.7uA using your 270Ω), so it shouldn't affect the measurement of your lower current significantly.

• Would a circuit with the high current shunt in series with the diode you propose work? The idea is that while the current is low, the diode is off and you read through the low I shunt - when current is higher the drop across the shunt is enough to turn on the diode, and all excess current goes through the other shunt. You then need to sum the two currents of course. Sep 12 at 12:59
• @VladimirCravero Yes it would work, a good suggestion. I suppose you'd really want to ignore the voltage drop across the higher resistance shunt/diode when it's more than a few tens of mV, but maybe the error is low enough it could just be ignored compared to resistor tolerance etc.. OP can run the numbers for their high/low current values. Sep 12 at 13:06
• Perhaps one of the "superdiodes"/"ideal diode" ICs can come in handy - I swear for some of them you can set the vgamma via a couple of resistors, but I am not sure :D Sep 12 at 13:54

Which MCU do you need to take measurements on?

Texas Instruments have designed Energy Trace into some of their debug probes. They describe the following benefits over sampling the current through a shunt resistor:

EnergyTrace implements a new method for measuring current consumption for ultra low power currents. Traditionally, power is calculated by measuring the current consumption and voltage drop over a shunt resistor at sampling intervals via analog to digital converters. In Debug Probes that support EnergyTrace, a software-controlled DC-DC converter generates the target power supply and keeps it regulated via a train of pulses. The density of the DC/DC converter charge pulses is proportional to the energy consumption of the target microcontroller. Because the width of each charge pulse remains constant, the Debug Probe simply counts each charge pulse and then sums them over time to calculate the average current. The accuracy of measurements is guaranteed by a built-in calibration circuit in the Debug Probe, which quantifies the energy equivalent of a single charge pulse. Using this approach, even the shortest device activity that consumes energy contributes to the overall recorded energy.

I'm Not A Lawyer, but the README of energytrace-util says Energy Trace is covered by patents US20130154594, US20140253096. Is this question about designing a product to measure MCU current consumption, or just measuring the current consumption of your MCU?

The energytrace-util GIT repository describes how to use TI's open source library to obtain the current consumption of a MCU powered by a TI Energy Trace debug probe without needing to use TI's Code Composer Studio IDE.

You could try by adding a series resistor and bypass capacitor in the feedback path (and also the missing Cset capacitor):

The capacitor directly between OUT and SENS will provide a direct path for high speed changes, while the DC level comes through the 1 kohm resistor. This reduces the tendency of the circuit to oscillate. Note that when the load current changes quickly, the regulator will take about 10 µs to react to it.

But in practice it is usually easier to use a smaller shunt resistor and higher gain in the sense amplifier.

• @RohatKılıç It will reduce oscillation, because the bypass capacitor reduces phase shift between OUT and SENS. I agree that it will increase response time to load changes, like the answer says.
– jpa
Sep 12 at 7:06
• Sorry, didn't read the answer completely. Deleted my comment. Sep 12 at 7:07
• Yes this is the answer I was going to give and I suspect it will work. Sep 18 at 3:01

In your schematic C1 creates the normal LDO output pole. Putting the 270 resistor and 10nF cap on the output add an extra RC filter thus an extra pole in the feedback loop, which makes it unstable. It won't work, the LDO is not designed for this. Maybe removing C1 could do the trick but I'm not optimistic.

If you insist both on a sense resistor value of 270 ohms, and sense resistor placement on your schematic, and a 10nF cap on the output, then yikes.

Increasing the output cap makes it more doable with a discrete LDO using custom compensation. Left plot is output impedance. Here R10 introduces a zero to cancel the pole due to C1. C1 has a full RLC model.

OK, let's put the shunt resistor before the pass transistor and use a more reasonable value. Again a custom LDO so it is stable with a low value of output cap.

Problem: at very low currents (µA) the MOSFET loses transconductance so much that the whole "LDO" becomes useless. In fact the loop transfer function depends on FET transconductance (and therefore output current) so much that it would be quite heroic to make it stable. We'd have to pre-bias the FET so it keeps a decent transconductance, but we can't do that, as that would add an offset to the measured current...

Anyway.

If your goal is to measure the average current used by your micro to estimate battery life, then you don't need high bandwidth. You can use a large output cap. In fact, since your micro will probably use a LDO, you should also include the LDO that you'll use. Here's an example with LT1761 (because I have the spice model for this one):

R13 (the sense resistor) could also be placed on the ground side, making it easier to measure but harder to SPICE. In this case voltage on R13 represents your average current. However the cutoff frequency of the lowpass filter doing the averaging depends on the regulator's internal pass transistor's transconductance, therefore on output current. It's somewhere between 1Hz and 10kHz.

If your goal is to measure the peak current current used by your micro to choose a LDO that can deliver it, then you don't need a 270 ohms resistor, peak current is high enough that it will work fine with a 1 ohm resistor from a stable 3V3 supply, problem solved.

If your goal is to measure the instantaneous current drawn by the microcontroller for another purpose not covered above, then it gets tricky, because you'll need bandwidth. Here's a proposal. It looks a bit funny, but it should do the trick. Blue is the output impedance, red is the measured voltage (ie current) on the sense resistor.