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.