Power electronics benefit from SPICE simulation by eliminating a prototype's possible smoke or heavy noise. For example, we can use SPICE to the bulk capacitor in the front-end stage of any power supply. **Fig. 1** shows a very familiar waveform: the ripple superimposed over the dc rail. With a few algebraic lines, you can quickly derive the diode conduction time:

Where:

Tc=Diode conduction time

Vmin=Valley ripple

Vacin=AC line input

Fline=Mains frequency

Also, the necessary value for the bulk capacitor to fulfill the ripple requirements imposed by your design constraints:

Where:

Cbulk=Bulk capacitor value in μF

Vripple=Ripple voltage

Vpeak=Peak ripple voltage

Pout=Delivered output power

Suppose you want to assess the ripple evolution, and thus the rms current circulating in Cbulk, over the whole input voltage range of your power supply. **Fig. 2** offers a solution that emulates the SMPS consumption (70W kept constant by the feedback loop), a B-element source can do the job for you. Using an in-line equation, the following line automatically adjusts the current drawn from the line to keep the product V×I equal to the power parameter:

*IsSpice4* B1 out 0 I=70/V(out)*PSpice* G1 out 0 value={70/V(out)}

With such a line, whatever the rail voltage *out*, the load permanently draws 70W and eases the total range sweep. Because of the possible division by zero, you need to place an .IC statement after the capacitor value as exemplified on the picture. A UIC keyword tells the simulator to start with this initial voltage during the bias point calculation and everything should properly converge.

Should you want the simulator to automatically find the capacitor value that offers a given ripple (e.g. 20Vpp), a simple objective function can do the job, providing your simulator features an optimizer. In *IsSpice4*, authorize the simulator to vary CBulk ±85% from an arbitrary value (say 500 μF to start), and include an objective function to help find the capacitor value that brings it close to zero. It could look like:

*setcursor 0 35m setcursor 1 45m ofunc=(pk_pk(V*

_{OUT})-20)^2 print ofunc

The first two lines instruct the simulator to isolate a 10 ms period between 35 ms and 45 ms. Then, you must define a measurement that will be minimized when you get your answer. This is the *ofunc* statement that delivers zero when the peak-to-peak ripple reaches 20V. During the simulation, the optimizer will sweep the CBulk value to quickly bring *ofunc* close to zero. After only a few seconds, you will get “optimized results:” cbulk capacitance=263.123812U.

**For more information on this article, CIRCLE 339 on Reader Service Card**