Sometimes in your simulations you want to use a resistance that is varying with time or some other quantity, LTspice gives you different ways to do it. Let's have a look at them.

- Resistance as a function of time
- Resistance as a generic function of measured quantities
- Resistance as a look up table
- Resistance as a function of parameters
- Frequency dependent Resistance

If you want to experiment with the circuits shown in the figures below while you are reading the tutorial they can be downloaded as a zip file here.

LTspice allows you to access simulation time value through the the internal variable "time" and use it to control resistor value. Case A in figure 1 shows an example where $$\textbf{R=}f(\textbf{time})$$

It is also possible to assign resistance as a function of any measurable quantity. Case B (figure 1), shows a linear relation between resistance and current while Case C (figure 1) shows a linear relation between resistance and voltage. Resistance can also be dependent on several quantities as well. For example, you can write (Case C, figure 2) $$\textbf{R=}log\left(I(R4)V(Res)\right)$$ \(\textbf{If}\) statements are allowed as well (Case E, figure 1), the syntax is defined below $$\textbf{R=if(}condition, \textit{value if true}, \textit{value if false} \textbf{)}$$

As shown in Case D (figure 1) resistance can be expressed as a look up table using the following syntax $$\textbf{R=table(} X, X(1),R(1), ... X(n), R(n) \textbf{)}$$ where \(X\) is the variable and \(R(p)\) with \(p \in [1,...,n]\) is the resistance value associated with \(X(p)\). Interpolation is linear.

You can also use parameters and step or list them, the syntax is

$$ \textbf{.step param } R_x \text{ } R_{min} \text{ } R_{max} \text{ } increment \qquad \text{or} \qquad \textbf{.step lin param } R_x \text{ } R_{min} \text{ } R_{max} \text{ } increment $$ $$\textbf{.step dec param } R_x \text{ } R_{min} \text{ } R_{max} \text{ } n_{steps}/dec$$ $$\textbf{.step oct param } R_x\text{ } R_{min} \text{ } R_{max} \text{ } n_{steps}/oct$$ $$\textbf{.step param } R_x \textbf{ list } R_1, ..., R_n$$Where \(R_x\) is the parameter that we want to step, \(R_{min}\) is the minimum value of \(R_x\), \(R_{max}\) is the maximum value of \(R_x\), \(increment\) is the interval size between two consequent steps of \(R_x\), \(n_{steps}/dec\) is the number of steps over a decade, \(n_{steps}/oct\) is the number of steps over one octave and \(R_1, ..., R_n\) are the values assigned to \(R_x\) at step \(1, ..., n\).

LTspice's internally defined parameter "temp" (temperature) can be stepped as well.

Case A and B in figure 2 shows an example where \(R_x\) is stepped linearly from 1 to 3 with a step increment of 1.NB1: Case B requires curly braces for \(R_x\) because you are not using the syntax "\(\textbf{R=}...\)". This, however, is a grey area, we will see that in the frequency domain this is not correct and curly braces must be included. The reason for that is probably due to compatibility with classic SPICE notation.

NB2: The semicolon in front of the \(\textbf{.step list}\) command (figure 2) prevents it from being executed during simulation thus it is possible to change the type of step by moving the semicolon in front of the command that you want to exclude.

A frequency dependent resistance can be created using the \(\textbf{Laplace}\) command. The simplest way to implement it is using a \(G\) source (voltage controlled current source) or an \(R\) element.

An alternative source would be a \(B\) (arbitrary behavioural voltage/current source) but you would then have to add labels or commands to identify the voltage/current that you want to use with it.

The syntax for \(G\) is defined as follows (in the schematics right-click on G source and fill the section Value, see Figure 3 ) \begin{equation} \textbf{Laplace=}g( \textbf{s} ) \end{equation} while for the resistor element we have \begin{equation} \label{Rfreq} \textbf{R=} 1 \textbf{ Laplace=}g( \textbf{s} ) \end{equation} where \(g( \textbf{s} )\) is the Laplace transform of the conductance. From the syntax above it can be immediately noticed that \eqref{Rfreq} is a little bit dodgy because we are actually defining \(R\) as a conductance. This is due to how the solver interpret the command internally. The final result will be $$ \textbf{R=} \frac{1}{g( \textbf{s})} $$ Another tiny caveat with syntax \eqref{Rfreq} is that if you use parameters and the number \(\pi\) you will have to wrap them in curly braces (Figure 4). This is not intuitive and is probably related to supporting SPICE classic syntax together with LTspice's proprietary one.

Figure 5 shows an example of a frequency dependent resistor defined in a frequency domain analysis as $$ R=f $$ About frequency dependent resistor and time domain simulations, it is important to note that the \(\textbf{Laplace}\) command works well only in the frequency domain, results are not guaranteed to represent the correct solution of the circuit when doing a transient analysis.