Stabilize op-amp current source with gain in feedback loop - Page 1
Forum section: electronics / beginners

author: Streamtronics
author_rank: Newbie
timestamp: May 31, 2024, 01:53:43 pm
content: Hi! I'm trying to design a small linear li-ion battery testbench using a power op-amp. However, I'm not sure how I'm supposed to approach the issue of stability (or well behaved response in general) in this case.I hope this isn't too complicated for the beginners section, this is my first post here and I consider myself a beginner.Here's what I'm trying to achieve with the actual "power path":Voltage input sets battery current (bipolar)Current output: ±250mA for an input voltage of ±1V superimposed on a local reference voltage (I picked 1.25V)Supply voltage will be USB, so maybe 4.65V worst caseBattery voltage can be 2V ... 4.3VIdeally I'd like around 10 kHz bandwidth and 0.5% DC accuracyThings like battery protection are ignored for now.The ZIP in the attachments contains the LTspice schematic and the model/symbol for the OPA569.Current schematic:Bode plot of the current through the battery (should ideally be a constant -12dB ≙ 250mA):I picked a 200mOhm current shunt because I can't afford a 4-Ohm one (1V @ 250mA) due to limited voltage headroom. So I amplified the voltage across the shunt with a gain of 20 to get back to my ±1V signal, hoping to avoid any offset and noise considerations.I assume that with this decision I completely destroyed any phase margin I'd have if I ran U1 at a gain of 1 or more? But I hoped I could compensate U1 to a point where the phase shift of U2 doesn't matter much (bandwidth of the AD8237 should be around 50kHz at G=20 if I'm not mistaken). However, I'm feeling quite lost trying to approach this, how to even find out what needs correcting and how to correct whatever needs correcting.I feel like I have a bunch of errors in my thinking, should I rather just use a current sense amp with a gain of 1 and attenuate the input signal down to the same ±50mV instead of trying to get this contraption to be stable? At that point I guess the offset voltage of the OPA569 would be an issue, but I probably could get around that by using the OPA569 simply as a buffer for another precision op-amp with much smaller offset voltage?I'm glad for any kind of input on this, negative feedback is what we want after all :DThanks for your help! Please ask if something is unclear.

author: mikerj
author_rank: Super Contributor
timestamp: May 31, 2024, 02:38:16 pm
content: You'll need to add some local AC feedback around the OPA569. I just quickly guestimated the values in the attached circuit, you'll need to do some proper analysis.

author: Streamtronics
author_rank: Newbie
timestamp: May 31, 2024, 03:00:46 pm
content: Thanks for taking the time to look into it! I have attached a screenshot of your schematic for others to follow along.I have tried to add the same two resistors + capacitor that you have added (sorry for not including that in the OP, I wanted to keep it short) but no matter what values I tried, this made the current through the battery become quite large at higher frequencies (which makes sense to me: A compensation cap basically pushes the gain towards 1 at high f, so that ±1V at the input will result in ±1V at the output of U1, which is a much larger swing than what would be needed to get ±250mA through the battery).Could you also explain why you placed the AC source (which is supposed to be the current-setting input voltage for the regulator) in the feedback path and turned the original voltage source into 1V DC? I need the current through the battery to be 0 if the input voltage is also 0.

author: mikerj
author_rank: Super Contributor
timestamp: May 31, 2024, 05:23:35 pm
content: You were measuring the closed loop gain of the system, by putting the a voltage source into the feedback path and plotting fb/inm you can get the open loop response of the OPA569 which is what you need for phase and gain margin. This is a simplistic method and not totally accurate, but gives you much more information than closed loop response.https://www.analog.com/en/resources/media-center/videos/5579254320001.htmlLocal feedback will reduce the gain at high frequencies, the resistor in series with the cap limits this reduction.

author: Streamtronics
author_rank: Newbie
timestamp: June 01, 2024, 01:01:27 am
content: Injecting an AC signal into the feedback loop to get open-loop gain and phase margin seems like a very useful trick nobody told me about before, thanks! This is very useful.However, whenever I use values for the local feefback capacitor and resistor that are meaningfully impacting the phase margin, I get an undesirable effect: Plotting the current through the battery vs. frequency shows the current rising for frequencies above 1kHz or so.Quote from: mikerj on May 31, 2024, 05:23:35 pmI‘m not sure if this is accurate in this case. At DC, the feedback is via the current sense amplifier, and the overall gain is basically <1 (an input signal of 1V equals in an output rise of much less than 1V). If we assume for a minute that the battery is a stiff voltage source, with a 200 mOhm shunt I think the overall gain of the circuit should be 0.05 (50mV output swing for 1V input swing). With the local feedback capacitor, at high frequencies I believe we‘re transitioning from getting feedback via the current shunt to a direct voltage feedback, and more current is flowing through the battery, which is undesirable. Am I missing something obvious here? I‘d want the AC battery current vs. frequency to be mostly flat up to 10 kHz or so.

author: magic
author_rank: Super Contributor
timestamp: June 01, 2024, 03:10:13 pm
content: Are your noise and precision requirements strict enough to justify the ±1V control voltage range?If you could reduce your control voltage to ±50mV, then running U1 at unity gain would give you (almost) the exact behavior you want due to resistance of R_shunt (plus battery ESR). Also U2 would be working at unity gain, which would probably extend its bandwidth at least a little (I'm not familiar with this part but it seems a safe bet) and allow you to have full accuracy at even higher frequencies.Having gain in the feedback network is always problematic. U1 is internally compensated for unity closed loop gain, i.e. just stable enough if it receives 100% negative feedback. With amplified negative feedback, it may easily become unstable even if feedback has zero phase delay. And U2 likely adds phase delay of its own, so you are totally screwed. But even an ideal 20x amp with no delay would surely add enough loop gain around U1 to destabilize it. It's same effect as increasing U1 open loop gain by 26dB without changing its open loop phase response. Not gonna work. You must revert to unity gain below the nominal GBW of U1.(Another, shorter way of thinking about it is that U1 is compensated for unity gain or higher, but not lower. You need 0.05 closed loop gain to avoid excessive current response at high frequencies. You can't have it.)If you really don't want to reduce control voltage range due to U1 offset error or something like that, it may be possible to devise an RC network which attenuates only high frequency components of the control signal, above the bandwidth of U1/U2 control loop, and have U1 work unity gain at this point.

author: Streamtronics
author_rank: Newbie
timestamp: June 03, 2024, 11:12:18 pm
content: Hey magic, thanks for the input and sorry for the late reply. Also thanks for the explanation on stability. I feared that'd be the case, but wasn't totally sure... and kinda hoped there'd be some kind of engineering magic trick that still made it work (I now wonder how this is done on much larger current sources, do they all attenuate the control voltage instead of amplifying the current sense voltage?)Honestly I'm not sure about how much of an issue the noise would be, honestly I'm making up the requirements myself out of thin air pretty much. I doubt it'll be much of an issue, I think we can take the average over several AC cycles for example if we have to.What's worrying me more is that I have to make this thing compatible with anNI myDAQ card(which has ±2V differential inputs and single-ended outputs) but also a 3.3V microcontroller for future use. So I compromised and planned on using a diff amp at the input to give me a differential input and lets me add that difference to a ref voltage (because I feel like creating a bipolar supply from USB is a bit too much for this project, if I can avoid it). So now I need an attenuating diff amp (1/20) at the input, which is probably hard to find. Or possibly 1/10 and bump R_shunt to 400mOhms...Battery current (and voltage, but that's easy) also need to be measured, and the reason why I used a x20 current sense amplifier was so I could directly feed that signal into the myDAQ (with Vref = 1.25V at the inverting input of the myDAQ, so it sees ±1V). I need to shift the 50mV signal up still though because of the single supply. And that means I won't be able to simply amplify it with a gain of 20 (unless I use Vref/20 as my DC offset, which seems silly). So I'll probably have to use two current sense amplifiers with the same shunt, one for feedback and one for measurement? I wanted to avoid that, but frankly cost is no concern here, I still just want an elegant solution because that's how I'll learn the most in the process.

author: magic
author_rank: Super Contributor
timestamp: June 04, 2024, 08:29:20 am
content: You can attenuate the control voltage 20x with a resistive divider (say, 19kΩ/1kΩ) connected to 1.25V instead of ground.If you want that 1V output swing from U2 for direct feeding into ADC, you don't need to attenuate the control voltage at low frequencies. If you add 15nF in series with 1kΩ above, the control voltage will be ±1V from DC up to 10kHz and then gradually drop to a flat ±50mV above 200kHz. Then tweak U1 feedback to have unity gain starting at 200kHz and this might be good enough.

author: Zero999
author_rank: Super Contributor
timestamp: June 04, 2024, 11:33:26 am
content: Putting two high gain amplifiers in the same feedback loop is asking for oscillation.Consider using Howland topology, with the AD8237 in unitiy gain configuration and the OPA569 to increase the current output. The input will need to be scaled down using a potential divider.Here's an example using LT1990.Howland diff amp boost.ascEDIT: R1 isn't needed. It was originally there to allow the instrumentation amplifier to make up for the fact that the chosen op-amp didn't quite have enough current drive.

author: Zero999
author_rank: Super Contributor
timestamp: June 04, 2024, 06:01:09 pm
content: Here's how to use the AD8237 in Howland configuration, with the OPA569 as a current booster.