# Encyclopedia Magnetica

Encyclopedia of magnetics and electromagnetics.

### Site Tools

ltspice:variable_resistor

# Variable resistor

 Stan Zurek, Variable resistor , Encyclopedia-Magnetica.com, {accessed 2019-06-16}
 Go to: LTspice.

The Arbitrary Behavioral Current Source in LTspice can be used to simulate time-variable resistor in transient simulations.

### Method 1 (proportional resistance)

The steps are:

1. Connect a voltage source to ground and label its other end for example as “var”. Set the voltage waveform/pulse such that its value in volts corresponds directly to the desired variable resistance in ohms (e.g. “50 V” will correspond to “50 Ω”).

2. In value of the variable resistor enter:

R = V(var)

such that the name “var” represents the node name from step 1.

Variable resistance: green curve shows an example of sinusoidal supply voltage, blue is the resultant current, red is the function by which the load current is scaled, namely V(var). Resistance is directly proportional to the variable voltage.

by S. Zurek, E. Magnetica, CC-BY-3.0

### Method 2 (proportional current)

The steps are:

1. Label the node(s) the variable resistor is going to be connected between.

2. Use “Arbitrary Behavioral Current Source (bi)” and put it between the labelled nodes. If the resistor is connected to ground then only one node needs to be labelled (e.g. “test”).

3. Create a new voltage source connected somewhere to ground, and label its voltage output (e.g. “VAR”). The shape of this voltage source will determine how the resistance changes - this can be set to be a pulse, sine with offset, piece-wise linear (PWL) etc. Set the shape of this voltage source to vary between zero (infinite resistance, zero current) to unity (resistance equal to the value “LOAD”, see next point).

4. Add directive “.param LOAD 100” where “LOAD” represents a variable and “100” is the minimum value of resistance.

5. Edit the function of the Behavioral Current Source to be:

I=V(VAR)*V(test)/LOAD

This will set the current to vary anywhere between zero (if V(VAR)=0 then resistance = infinity), scaled to the real voltage “V(test)” and the value of LOAD (if V(VAR)=1 then resistance = LOAD). If the variable resistor is placed between two labelled nodes then a voltage difference between these nodes needs to be calculated in the equation.

Variable resistance: green curve shows an example of sinusoidal supply voltage, blue is the resultant current, red is the function by which the load current is scaled, namely V(VAR). Resistance is proportional to the inverse of the current.

by S. Zurek, E. Magnetica, CC-BY-3.0

### Method 3 (proportional resistance)

The steps are:

1. Label the node(s) the variable resistor is going to be connected between.

2. Use “Arbitrary Behavioral Current Source (bi)” and put it between the labelled nodes. If the resistor is connected to ground then only one node needs to be labelled (e.g. “test”).

3. Create a new voltage source connected somewhere to ground, and label its voltage output (e.g. “VAR”). The shape of this voltage source will determine how the resistance changes - this can be set to be a pulse, sine with offset, piece-wise linear (PWL) etc. Set the shape of this voltage source to vary between any positive values (zero and negative values are not allowed). For “infinitely high” resistance use very high value, for example “1G” (1 giga) as the amplitude. For “infinitely low” resistance use a very low value, for example “1f” (1 femto).

4. Edit the function of the Behavioral Current Source to be:

I=V(test)/V(VAR)

This will set the resistance to be directly proportional to the V(VAR) voltage. If the variable resistor is placed between two labelled nodes then a voltage difference between these nodes needs to be calculated in the equation.

Variable resistance: green curve shows an example of sinusoidal supply voltage, blue is the resultant current, red is the function by which the load resistance is scaled, namely V(VAR).

by S. Zurek, E. Magnetica, CC-BY-3.0

### Method 4 (operating point)

This method is applicable only in the operating point simulation (.op) not transient (.tran).

The steps are:

.step param Rvar list 1 2 3 4 5 10

where “Rvar” denotes a variable resistance.

2. In the given resistor enter the value of resistance as “{Rvar}” (with curly brackets).

3. Run the simulation in the .op mode (operating point). When plotting currents and voltages, they will be plotted with the Rvar in the horizontal axis of the graphs.

Variable resistance in “.op” mode: green curve shows the supply voltage, blue is the resultant current.

by S. Zurek, E. Magnetica, CC-BY-3.0