# LTSpice IV help with variable resistor

Discussion in 'General Electronics Chat' started by Bassalisk, Mar 10, 2012.

1. ### Bassalisk Thread Starter New Member

Jul 12, 2011
8
1
So I am newbie with LTspice and I need some help.

I am trying to simulate variable resistor, like photoresistor.

The key here is that the flux is changing with some law.

That law is a sine wave.

So we have a light source that changes it flux with the following law:

$\Phi (t)=\Phi _0 (1+sin(\omega t+\phi ))$

And the resistor value is determined by:
$R=R_0 e^{-A\Phi }$

I want to make such resistor in LTSpice, that is changing resistance in given law, with given flux. But I am unfamiliar with the functions in LTSpice and their parameters.

So I want to write function
$R=R_0 e^{-A\Phi _0 (1+sin(\omega t+\phi )) }$

And I want to see voltage across it in time. Say like 10 sec.(I will adjust the frequency of the sine later)

Jul 12, 2011
8
1
.......bump

3. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
Instead of trying to create a variable resistor, use a voltage source. It's easy to vary a voltage during a simulation. I don't know a good, straightforward method to change a resistance during a run.

4. ### Bassalisk Thread Starter New Member

Jul 12, 2011
8
1
Hmm but will I get the same results?

I attached my circuit.

I am trying to see what form of voltage across capacitor will I get, if my resistance changes with the law I described.

I cannot solve this analytically because, you get some unsolvable integrals and you need to transform them into infinite series etc.

And by all means I am not doing that

So in a nutshell I want to see how will my voltage across capacitor look like.

Input voltage is constant and equals some value E

File size:
8.8 KB
Views:
276
5. ### ifixit Distinguished Member

Nov 20, 2008
639
110
Hi Bassalisk,

Here is an LT spice example of how you can have a circuit resistance vary with time during a transient analysis. IE a voltage dependent resistor. LTspice has no knowlwedge of light flux so you have to arbitrarily assign a voltage to represent a light flux level.

When you assign a value to a resistance use this form:
R=V(node reference)* (a formula of your choice).

The voltage you reference will be your light flux value represented as a voltage.

The formula of your choice can contain functions referenced in the LTspice Help for the; Arbitrary behavioral voltage (BV) circuit element. Be careful that R2 doesn't ever equal zero because a zero ohm resistor is not allowed in LTspice. Apparently, negative resistances are allowed so to keep photocell resistances realistic & positive you can add an offset to your formula.

Math sometimes makes my head hurt, so you'll have to put your own formula in place of my simple sin function.

Good Luck & have fun with it,
Ifixit

File size:
841 bytes
Views:
300
File size:
82.8 KB
Views:
467
6. ### Bassalisk Thread Starter New Member

Jul 12, 2011
8
1
Thank you! I got something to work with now!

7. ### crutschow Expert

Mar 14, 2008
13,475
3,362
That's really cool. I often wondered how to model a variable resistor. I didn't realize you could use arbitrary variables for the resistor value, the same as the arbitrary behavioral voltage and current sources. Learned something really useful. Thanks.

Edit: A thought -- If you use two of these resistors in series and fed them both the same control signal but with one inverted, you could simulate a pot with the wiper moving up and down (one resistor value increases by the same amount the other is decreasing).

Last edited: Mar 12, 2012