# What is causing the oscillation in the feedback loop of an SMPS?

I am trying to make a switching constant current regulator for a Ni-MH charger. It accepts a current set input from the microcontroller using a PWM DAC. I basically want to source 2000mA and 200mA for 1C and 0.1C relatively for charging the 2700mAh battery.

The way that I've tried to accomplish this is as follows:

An OP-AMP which is configured in negative feedback, takes Vset (PWM DAC) as non-inverting input and Vsense (the voltage on sense resistor) as inverting input. It drives a small signal MOSFET with its output so that buck converter's voltage output is for desired current at the load.

However, I am getting oscillations on TP1, which affects the whole system.

Here is the schematic, I am sorry that it is 3500 x 2500px :

I have connected a short instead of R6, since Rdson of Q2 is about 50mohms. Also, I have connected a 1R 11W ceramic power resistor instead of a battery. Q3 is set off and Q2 is ON. I have connected an ampere meter and it shows about 1.9A through the resistor.

Here are some scope-shots of various test points which I have used very short ground lead on the probe to capture.

• Test Point 5; non-inverting input of the OP-AMP:

• Test Point 6; inverting input of the OP-AMP, voltage on the sense resistor:

AC Coupled:

• Test Point 1; Vsense pin of the switcher, drain of Q1:

• Test Point 2; switch node:

• Test Point 4 - Test Point 6; probe on TP4, ground clip on TP6, or in other words, voltage on P3 connector, or output voltage:

AC Coupled:

• Are you using LM393 or are you using an op-amp? Oct 18, 2012 at 19:22
• @ThePhoton I am using a LM393. Oct 18, 2012 at 19:42
• This is a low voltage design. So LM393 is oky for that? Are you at correct operating point? Oct 18, 2012 at 21:15
• @sandundhammika He cannot create an operating point with an on-off comparator. Vsense should be an analog level, not chopped. Oct 18, 2012 at 21:38

Fundamentally, you have way too much gain in your feedback loop, along with enough phase shift to create a very nice ~50 kHz oscillator.

First, I would simplify the circuit by eliminating the MOSFET Q1; instead I would consider swapping the inputs of the LM393 and using its open-collector output to drive the Vref node directly. Secondly, I would add a significant amount of negative feedback around the LM393, along with a capacitor to roll off the frequency response. You really do not need a lot of bandwidth in your control loop for a battery charger — a battery is not a highly dynamic load.

I understand about limiting the voltage swing on Vsense; that's what R1 and R2 are for. I'm saying eliminate Q1 and R3 and connect the LM393 to the junction of R1 and R2. Then, you need to swap the inputs to the LM393 in order to preserve the correct polarity of the feedback.

For negative feedback, just connect a capacitor between pins 1 and 2 of the LM393. Since pin 2 is now connected to your reference source, you'll also need a resistor between C7 and pin 2. Together, these components will roll off the frequency response of the comparator. I would start with values like 10K and 100 nF, giving a corner frequency of about 160 Hz. I don't know if this will be enough to make the system stable, but at least it gets you started in the right direction.

Let's take a step back for a moment. If we ignore PWM_Vset for the moment, what's really needed is to take the 200 mV that appears across the sense resistor and translate this to the 1.221 V that the regulator expects on its Vsense pin. This requires a simple noninverting amplifier with a gain of a little more than 6.

Based on the new circuit, it would be an interesting experiment to short out C7 and reduce R3 to 51K (gain = 6.1) and see if the regulator is now stable. If it is, we can then think about ways to make the setpoint adjustable.

• How do I add that negative feedback? Could you lead me in the correct path? By the way, one another reason that the MOSFET is there so that I can protect U1's Vsense pin which has –0.3 to 3V absolute maximum rating. Oct 18, 2012 at 20:30
• @davetweed The LM393 output is either high-impedance or low, and cannot settle to an operating point like an op-amp can. I don't see how op-amp-style negative feedback can work at all. Oct 19, 2012 at 2:13
• I don't know why you think that. The only thing the LM393 is missing is an internal current source for the output pin; it'll work just fine with an external source, such as a pullup resistor, or the pair of resistors the OP has. There really isn't that much difference between an opamp and a comparator, except that the latter is uncompensated and is designed not to have excessive charge storage on its internal nodes; both features are intended to enhance its speed. Oct 19, 2012 at 3:36
• Oh, I see the point in your comments now, after doing some simulation and thinking. I will try them out. Thanks! Oct 19, 2012 at 8:40

Your control scheme is puzzling me.

U3A is an LM393. A comparator. The output is either high-impedance or ground.

The TPS5430 is meant to take an analog voltage at pin 4 and use an internal reference of 1.221V and an internal error amplifier to generate PWM. You have Vsense tied to 2.5V, so when Q1 is off the duty cycle will go to zero (sense > reference), and when it's on it will go to maximum (sense < reference) at some slew rate controlled by the internal compensation.

You're essentially driving an analog pin with a digital signal - this is a hard way to go about things.

You also have zero hysteresis on the comparator, so the output may chatter if the inputs are close to each other.

Your idea about using the DAC to make a reference voltage, to control the output voltage (and the current) is valid and correct. What you really need is a buck controller that gives you access to the internal error amplifier output, so that you can replace your comparator circuit with an actual error amplifier (bypassing the internal one) and have closed-loop control with whatever compensation you need.

(You set up the buck controller so that the internal error amplifier is always high, then tie your external amplifier to it so that it can pull down the signal and control the duty cycle.)

EDIT: Your revised solution will work. Replacing the comparator with an op-amp error amplifer to set the external operating point is a good compromise. You're essentially feeding a loop (the internal compensation of the buck) with the output of another loop (your external error amplifier) but that's the price you pay using one of those tiny-buck control chips with integrated feedback. I would experiment with load steps to see if the output has any oscillatory tendencies, just to make sure that there's no chance of instability.

• Ah, does LM393 work only as a comparator even if I had a negative feedback? So, if I change LM393 with a LM324N, will this circuit work? Oct 18, 2012 at 20:35
• The output is either on or off. There isn't really a way to do negative feedback as the part isn't an amplifier per se. If you change U3 to an op-amp, you can add negative feedback and generate a control voltage to go into Vsense, just remember that the buck IC's internal compensation will also come into play (the loops may interact with each other unless you make the external loop very slow). You can clamp the output of the op-amp with a zener to keep it away from the pin's maximum input voltage, and try driving Vsense directly. Oct 18, 2012 at 21:00
• Thanks for the edit. I have checked the output for load steps and shorts. There are no oscillations. I am really surprised how this worked a treat! Now, I have to make some additions so that I can use this for a Li-Ion charger which I need a constant voltage for. Oct 21, 2012 at 8:00
• That's a good sign. The 'proper' way to test for stability is with a gain/phase analyzer, but that's a $10k-and-up piece of equipment. Oct 21, 2012 at 13:55 Solution to this problem I had, is a combination of both of the answers by Dave Tweed and Madmanguruman. Thank you guys. I have replaced the comparator LM393 by a LM358 which has almost the same price, at least in Digi-Key.$0.0797 for LM358 and \$0.0756 for LM393, both in 100 quantities.

I also added some negative feedback with a capacitor, so that output will ramp up slowly enough, letting TPS5430 control the buck regulation. Oh, and let's not forget that I have swapped the input pins.

Test results are great. I have tried stepping the load, no problems. I have also shorted the output or applied very little (less than half an ohm) resistance and again, no problem.

For a 5 ohms load at 1A, efficiency is about 91%. For a 2A current at the same load, efficiency is at 90%. Output noise is about 60mV peak to peak. I am pretty happy with the results. My goal now is to add some voltage regulation mechanism too so that I can implement Li-Ion charging. Here is the latest schematic: