In responding to another thread it became apparent that it's not obvious how to simulate a potentiometer, using LTSpice. Rather than clog it up, I decided to make a quick tutorial and it can be made sticky if people find it useful, otherwise it'll just sink to the bottom of the list and rot, if it's no good.
There are several ways to do it.
Firstly the potentiometer must be broken down into two resistors: the top (POT1a) and bottom (POT1b), with the wiper joining them both. If you wanted to, you could add an extra resistor in series with the wiper, to emulate the contact resistance, but it's not needed in most applications, as it's small, compared to the total resistance.
Now you need a way to alter the resistance value.
There are three ways:
Use the .step param directive.
.step param variable_name start_value end_value increment
Where
variable_name is the name of the variable i.e. POT
start_value is the resistance value at the beginning of the simulation.,
end_value is the resistance value to be swept towards, as the end of the simulation
increment is the step size.
The value of the potentiometer is simply set to {variable_name} with a mathematical expression. To make a potentiometer, the top resistor's value is incremented, as the bottom resistor value is decremented, with a small value added to both to ensure neither value is zero: LTSpice can't handle zero Ohm resistors as they result in division by zero.
demo 1 and 2 use the step param method.
demo 1 uses absolute values
demo 2 uses a percentage which is scaled, allowing the potentiometer's value to be more easily changed.
The above two are fine, but no good for analysing the transient response, as the resistance is varies.
demo 3 uses the time to control the resistance. The downside to this is changing the length of the simulation time affects the resistance value.
demo 4 uses a voltage to control the resistance. A voltage of near 0V to 1V is used because it makes scaling easier. Note again, to avoid zero Ohm resistors, the voltage can never equal 0 or 1. It's a bit more tricky to set up but is the most flexible option since the resistance can be arbitrarily varied at and speed and wave shape.