Wednesday, December 16, 2009

Simple Constant Power Loads in LTspice

I recently needed to model active and passive power factor correction techniques as part of the design process for a 100 watt offline LED ballast. The LED driver is essentially a constant power load, but, unfortunately, LTspice doesn't include a constant power load element. A quick Google search didn't turn up anything particularly elegant, so I decided to roll my own. Below are two simple constant power loads I came up with. The first is a resistor whose resistance is a function of the voltage across it, and the second is a voltage-dependent current source using a piece-wise linear approximation. Both are bounded to prevent convergence problems. Click for a bigger image.


The resistor-based load is more accurate and works for either polarity. To create it just place a resistor on your schematic, but instead of entering a numeric resistance value you put in a formula, in my example:
R=limit(10,V(v1)**2/100,1000)
Ignoring the limit command for the moment, the resistance is simply V(v1)**2/100, load voltage squared divided by the desired load wattage, in this case 100 watts. The limit command is necessary to constrain the min and max resistance values. The limit function is described, rather tersely but accurately, in the LTspice manual as "limit(x,y,z) - Intermediate value of x, y, and z". The order of the arguments doesn't matter because it really does just take the intermediate value of the three. In my example the limits are 10 and 1000 ohms.

Although the voltage dependent current source based load is not as accurate as the resistor based load, it offers more flexibility. The example I show is a constant power load, but you can use the table concept to define arbitrary load functions. To create it, just place a voltage dependent current source, listed as "g" in LTspice's component menu, on your schematic. Right click on the current source's value, which will be shown as "G", and enter your table. The table consists of pairs of voltages and currents separated by commas. It's a good idea to have your first pair be (0 0) so that the current goes to zero at zero volts. In the constant power case the voltage times the current of all of the other pairs is your desired load power. Here's my 100 watt example:
table = (0 0, 25 4, 50 2, 75 1.333, 100 1, 125 0.8, 150 0.667, 175 0.572, 200 0.5)
Notice that after the first pair each subsequent pair multiplies to 100. You should choose voltages to cover your entire anticipated operating range, and have enough pairs so that the interpolation error is acceptable. My operating range is roughly 50 to 175 volts, so my table covers 25 to 200 volts to provide a little margin. With eight pairs (not counting the first) the error over the operating range is a few percent.

To get accurate simulations with nonlinear elements, like these loads, you must keep your time steps small. I found that the default LTspice .tran settings resulted in obvious artifacts, and that to get reasonably clean results with a 60Hz voltage source I needed to set to set the .tran maximum timestep to around 10uS.

Below are plots showing the behavior of both loads when driven by a 120VAC 60Hz sine wave. Click for a bigger image. The resistor load, on top, works for both polarities. The voltage controlled current source load, at the bottom, only works for positive voltages. The table interpolation errors are visible as ripple in the power level, particularly at lower voltages.



If you'd like more information about constant power loads, this thread on the LTspice Yahoo group is a good place to start.

12 comments:

Just Lost said...

Excellent, this is just what I needed, thank you for posting this. Any idea how I could modify the resistor-based load to pulse between two different wattages? thanks again!

Russell said...

That's something I haven't tried yet. I don't have time to play with it now, but I'll put it on my list of things to explore further in LTspice.

Unknown said...

Create a "pulse" voltage source whose output voltage is your desired output power. Label its output voltage "Power".

Then in the constant power resistor definition, change it to:
R=limit(10,V(v1)**2/V(Power),1000)

Should do the trick ;)

Unknown said...

You can also use the Behavioral current source B1 to do this.

In this case:
I=100/limit(50,V(v1),500)

A small resistor in series with this aids convergence. You can also use a small RC to create a filtered reference node to drive it.

Paul E said...

Thanks very much for this. I'd spent ages mucking about with compensating MOSFET-based active loads and you've got an infinitely cleaner solution in one line of code. Good stuff.

Unknown said...

This is awesome! Exactly what I needed. Thank you so much for posting this information

Unknown said...

Thanks for this. I usually don't comment but this is good knowledge.

DBll said...

This resistance-based sim is exactly what I was looking for, and elegantly simple!

But, I'm finding that LTspice IV doesn't accept the code. I went back and copied it directly from the blog post, in case I typoed, but it refuses to correctly parse the "V(v1)" term. Appears to reject the V() syntax itself.

Any ideas? Surely something dumb!
Dave

forseeus said...

Another good way to make a constant wattage source is to use an "Arbitrary Behavioral Current Source" (B) with a "Voltage Source" (V). Define a net name Vxxx that is the output of the voltage source.

Next define the current for the B element to be "I=W/V(Vxxx)", where W is a number that is the desired wattage of the wattage source.

Note that if you need Vxxx to go to zero then you will need to add a small offset term to keep the calculation from blowing up.

JoelB said...

This was really helpful for my simulation of a DC-DC Converter capacitor hold up circuit. Simulation ran much faster using the constant power load in place of the DC-DC converter circuit. I tried the B element first but ran into problems with it.

Meir said...

Much simpler. A current source with a zener diode. I prefer a battery with a diode instead a zener diode

zdenekbachicha said...

Betting on sports toto in NJ: Guide & FAQ
The sportsbooks in New Jersey offer oakley titanium glasses wagering on all major U.S. columbia titanium jacket sports, and in a limited number of states, there will 토토사이트 only nier titanium alloy be a handful of online sportsbooks titanium white fennec in