Wednesday, May 23, 2012

Design Notes: Op-amp Stability Analysis in SPICE

Op-amp stability analysis involves getting an DC operating point with the amplifier running normally then opening the feedback loop and getting small-signal AC information. This can be done by using a very large inductor to pass DC and block AC and a very large capacitor to pass AC and block DC, but I've only seen it done that way once (and that was just last week, go figure).
HSPICE and many of its relatives, including SmartSpice, have the ability for a resistor to have a different value depening on if the simulation is DC (like an operating point analysis) or AC. The schematic below shows a simple way to accomplish this. This even works with Cadence's analogLib res, but I have not gotten it work with Cadence's analogLib resBias. But if you have access to Cadence you probably want to use the stb analysis and skip all of this. 


The listing shown here is for Silvaco's SmartSpice. HSPICE isn't that different. 


.option
+ post=1
+ measout
+ nomod
+ unwrap=1
+ usedegrees
+ savemfiles=1
+ savemodelslog
+ ingold=1
.temp 25
.AC DEC 50 10 10000meg
.LET AC mGAIN = vdb(out)-vdb(pos)
.LET AC mGAINM = -(vdb(out)-vdb(pos))
.LET AC mPHASE = vp(out, pos)
.LET AC mPHASEM = 180+(vp(out, pos))
.MEAS AC mGANMRG FIND mGAINM WHEN mPHASE=-180
.MEAS AC mPHSMRG FIND mPHASEM WHEN mGAIN=0
.MEAS AC mUGF WHEN mGAIN=0



There have been some some health problems in my family, so this was just a quick note to keep this blog weekly. I expect to have assembly and operation notes on the LED drivers next week. 

Bruce McLaren

Wednesday, May 16, 2012

Boost Regulator Soft Start

I am using the soft start circuit more-or-less straight from the LM317 datasheet

Soft Start using an LM317. Takes 300msec to reach 9V.

I started by adjusting the resistors to give a 9V output and use 1mA of bias current. It turns out the LM317 requires 10mA of output current to regulate. It's right there in the datasheet, but I missed it until I started to put the circuit together and couldn't figure out why it wasn't regulating. So I went for 10mA of current. Which seems like a lot. Maybe I should make an improved 317.

10mA. Ouch!

My intention is to soft start both the power supply for the compensator and the reference voltage. I used a diode model I had handy; I don't think the diode itself is particularly important.

Soft Start simulation results.


This entry is just a quick note. I ordered parts from Mouser and have started actually building the LED driver. I had trouble finding comparators of the needed speed at a price I could stomach. I'm going to try using the op-amps and only buy comparators if I need to. 

The approach to building the circuit will be to make the linear regulator with soft-start and use it to provide references. Then make the triangle-wave generator and see if I can really get a 400kHz triangle wave out it. Then make the boost regulator, but drive it from a pulse generator to check it out. Then pull the whole thing together. 

Then design a battery charger and interface and an on/off switch. Then install the beast in the trailer. 

I intend to publish photos of the building and verification process next week. I will also publish the schematic as it now is. I switched to direct current control and didn't document the change. It's not a big change, but it lowers the operating voltage and therefore the power requirements.

Late addition. I soldered the linear regulator and soft-start (and resoldered after finding I needed more LM317 current as explained above). I'm actually hitting 9.2V for input voltages above about 11V, that's less than 5% error.  The scope shot shows lower because my waveform generator only goes up to 10V. The soldering is not the best I've done. I could blame the re-solder, but I'm out of practice. I will have to do better when I put the triangle wave generator on here. I'm trying to decide if I use sockets for that part. It would make soldering safer.


9V regulator with soft start.

Soft start in operation. A bit faster than expected, but close enough. 


Miscellaneous tidbit for this week. I use this alias in my .cshrc.
alias big 'find . -type f -exec ls -s1k {}  \; | sort -gr | head'

And this one in a .bashrc.
alias big='find . -type f -exec ls -s1k '{}'  \; | sort -gr | head'

I don't remember now if the syntax is different for the different shells or just how they have drifted.
big gives a sorted list of the ten largest files in the current hierarchy


Bruce McLaren

Wednesday, May 09, 2012

Triangle Wave Generator

The part of the saw-tooth wave generator has been played by an ideal voltage pulse source in my boost generator schematics and simulations. It's time to make a "real" one. 

Note that a saw-tooth wave generator can be replaced by a triangle wave generator operating at twice the frequency. Think of a triangle wave as two back-to-back saw-tooth waves. So I need a triangle wave generator operating at 200kHz. 

This little circuit took me longer than I thought it would. I've designed triangle wave oscillator on chips in the 100kHz to 1MHz range. Doing this from components and keeping the capacitors large enough that I'm not worried about stray capacitance swamping the real capacitance has been a bit of a mind-bender for me. 

Triangle Wave generator schematic

In the schematic shown above, the comparator has significant hysterisis. On an IC, I am used to implementing that circuit using two pass gates (an analog multiplexor) selecting which reference voltage to apply to the positive input of the comparator. This is a smaller, simpler solution on a CMOS chip.  Two resistors are the smaller, simpler solution on a PCB. 

The 10Ohm resistor R4 was needed to get the circuit to converge. 
I needed to select a very small minimum time step to get the circuit to simulate accurately. This will cause trouble if I integrate this circuit in with the boost simulation. 

Triangle wave generator simulation. The light blue signal third from the top is the output.


This is actually operating at 448kHz. once stray capacitance has its way on what will be a hand soldered board, I wouldn't be surprised at 400kHz. That's still twice as fast as I expected. I will gladly re-do my calculations in return for a smaller inductor. 

Bruce

Wednesday, May 02, 2012

Boost Regulator

My first attempt at designing a boost regulator was comical. I took what I knew about SMPS (Switched Mode Power Supply) buck regulators and applied that. Then I figured out that running a boost regulator in CCM (Continuos Conduction Mode) creates a RHPZ (Right Half Plane Zero) that is not present in the buck regulator. That creates a circuit that is not stable. Did everybody get through that pile of acronyms? Then it's time to make something that works.

There are three basic approaches that I could take. 
1) I could design it to run in DCM (Dis-continuos Conduction Mode), where the inductor is small enough that it is fully discharged before the end of the cycle and the current is drawn from the capacitor. This requires a bit of finesse in component sizing, load current specification, and feedback network setup. It could make sense for this application because the load current has a narrow expected range.

2) I could stick with CCM but roll the response off at a fairly low frequency. This works for this application because I'm driving LEDs through a current regulator. The load current will change very slowly, mostly with temperature.

3) I could make sense of this paper or similar and keep a high bandwidth while retaining CCM. That isn't needed for this application. Maybe next time. 

First, the most important stage of any design, the specification. You can't design something if you don't know what you're designing.

Parameter Minimum Typical Maximum
Input Voltage 10 V 13.8 V 20 V
Output Voltage 40 V 44 V 48 V
Output current 36 mA 40 mA 44 mA

That's all that really matters. The input voltage minimum and maximum are somewhat arbitrary. The output voltage needs to be at least 40V to allow for the worst case corner, +/-10% seemed reasonable, so I set the maximum 20% higher. The frequency should be higher than 200Hz to avoid visible flicker, but I'll want much higher to keep the inductor size reasonable. 
Very simplified Bode plot for the boost control to output gain

The frequencies fLC, fZ, and fESR are from the output stage. The fC frequency is where the feedback system will get the crossover frequency to be. The crossover frequency needs to be at least three times higher than fLC so the peaking doesn't mess with it too much. fC also needs to be at least 1/3 of the lowest fZ. fZ needs to be at least 10*fLC.
Time for some numbers now.

The duty cycle is D ≈ (Vout−Vin)/Vout = 50-79%, 69% typical.

The minimum inductor size needed stay in continuous conduction mode with a 100kHz switching frequency is
L ≥ (Vout D (1−D)2)/(2 Iout f) = 156-347μH I choose 750μH.

The minimum capacitor to keep the output ripple to less than, say, 1V is
C ≥ (Iout D)/(ΔV f) = 0.035μF choose 1μF because that seperates fLC and fZ.

Therefore
fLC = (1-D)/2π (LC)1/2 = 1210-2910 Hz, 1.8k Hz typical.
fZ = (Vout/Iout) (1-D)2/(2π L) = 10.1-58.4 kHz, 23 kHz typical.
I'll want fC to be about 8kHz.

FESR = 1/(2π CRESR) = 320kHz (I assumed 500mΩ)

DC Gain is 20*log(Vout/((1-D)Vramp) = 43dB.
Gain at fC (8kHz) is about 18dB.

So the feedback compensation needs to provide a couple of zeros at about 3/4fLC or 1.35kHz, a couple of poles at fESR or 320kHz and attenuation of about -18dB at about 8kHz.

The next table summarizes this in terms of component values. I made a spread sheet to do the actual calculations.

Compensator values
ParameterFormulaNumbersResultStd Value
GZGC-(20*Log(fZ/(3/4fLC)-18dB-(20*10^(23kHz*0.75*1.8kHz))-46dB
R1picked200kΩ200kΩ200kΩ
RZ2R1*10^(GZ/20)200kΩ*10^(-43dB/20)1.50kΩ1.5kΩ
CZ21/(2π RZ2 3/4fLC)1/(2*3.1416*1.0kΩ*0.75*1.8kHz)77.6nF75F
CZ31/(2π R3/4fLC)1/(2*3.1416*200kΩ*0.75*1.8Hz)582pF470pF
Cp11/(2π RZ2 FESR)1/(2*3.1416*1.0kΩ*320kHz)334pF470pF
Rz31/(2π CZ2 FESR)1/(2*3.1416*0.68μF*320kHz)1.064kΩ1.0kΩ

The inductor is larger than I'd like, but it is set by the basic specifications. I don't think I can easily make a triangle wave generator faster than 100kHz on a PCB (this will be a breadboard style project, no custom PCB will be purchased). Raising that frequency would allow a smaller inductor.

Schematic is below. This is obviously not the implementation schematic. I am using ideal op-amps, comparators, and saw-tooth wave generator. The resistors on the the op-amp outputs helped initial convergence. The highest value comped (the output of the feedback loop) can take is 9V. The saw-wave switches between 0V and 10V. This means the gate signal will always be switching, even when the feedback is saturated to its rail.

Simulation schematic for boost regulator.


A simulation showing typical operation is below. The current through the LED legs is in blue, the voltage output (pwr) is in green on the right axis, the inductor current is in orange on the left axis. The pwr output overshoots then settles to 44V. The currents are controlled at 18mA in each leg. Not too bad; I may want to raise the LED currents. I do not understand the quick drops to ground that the pwr signal does every now and then. When zoomed in on, they drop in one time step which suggests a simulation issue. I'm not certain of that, though. The 10V case input gets the output voltage up past 40V which meets spec, but it is no longer regulating. I'm going to call that good enough; low voltage operation works, but not well.

Simulation results for 10, 13, and 20V batteries.

Zoom in to show inductor current. I'm going to need a hefty inductor to handle 400mA continuous. 

The next steps are to find real components that can be used and design a saw-tooth generator. I will probably use a triangle wave generator running at twice the frequency. This would be trivial for me on and IC, but I haven't done it using components before. "It shouldn't be too bad." I'm still thinking through how best to ensure the triangle-wave always has a peak higher then feedback network's high saturation point. I will also need to either make a soft-start or a voltage limiter. 80V initial transient is a bit large, and I wouldn't be surprised if the real (non-simulation) peak is even higher. I am also considering removing the LM317 based current sources and instead controlling the current directly.


I found several good references while working to understand boost converter stabalization.

Loop compensation of voltage-mode boost converters This stepped through the design process in a organized and understandable fashion. If I had found this first instead of last, I would not have had much trouble.

Compensating the RHPZ in a CCM Boost Converter: the analytical way This is part three of a four part series that is pretty good, but hard to follow because the equations and figures are not in-line with the text.

DC/DC Boost Calc This is a quick and dirty component calculator.


I'm making some progress on this project. I would like to finish up the design in nest week's blog. What I expect to do is write an entry on miller op-amp compensation or ADC specifications because I need to prepare for a technical phone interview.

Bruce