**For the PDF version of this article, click here. Click to read part I and part III of this article.**

In part one of this article (see βSPICE Analog Behavioral Modeling of Variable Passives,β March 2005, *Power Electronics Technology*), a method for modeling a variable resistor within SPICE was described. Here in part two, a similar technique is applied to model variable capacitors.

As we did in the previous article with the resistor, a capacitor can be portrayed by a voltage source obeying the following law:

In other words, if we integrate the current flowing into our equivalent subcircuit capacitor and multiply it by the inverse of a control voltage V, we obtain a capacitor of value C = V. Unfortunately, there is no integral primitive in SPICE since it involves the variable t, which is continuously varying. Therefore, why not capitalize on the equation and force the subcircuit current into a 1-F capacitor? By observing the resulting voltage over this 1-F capacitor, we have integrated I_{c}(t). **Fig. 1** shows how we can build the subcircuit.

In **Fig. 1**, the dummy source V routes the current into the 1-F capacitor, which develops the integrated voltage on the βintβ node. Then, once multiplied by the inverse of the CTRL node voltage, it mimics our variable capacitor. **Fig. 2** shows an actual test circuit used to verify the validity of our Spice model. **Fig. 3** displays voltages and currents obtained from both the real capacitor and the variable one modelled in Spice. There is no difference between plots.

Below are the models in both IsSpice and PSpice:

**IsSpice**

.SUBCKT VARICAP 1 2 CTRL

R1 1 3 1u

VC 3 4

BC 4 2 V=(1/v(ctrl))*v(int)

BINT 0 INT I=I(VC)

CINT INT 0 1

.ENDS

**PSpice**

.SUBCKT VARICAP 1 2 CTRL

R1 1 3 1u

VC 3 4

EC 4 2 Value = { (1/v(ctrl))*v(int) |

GINT 0 INT Value = { I(VC) |

CINT INT 0 1

.ENDS

Tests also were run in ac analysis where the model confirmed its accuracy in the frequency domain.