LTSpice problem with varying parameters

Thread Starter

bordonbert

Joined Feb 21, 2012
40
Hi guys. I'm new to Spice so realise this will probably come down to my own lack of understanding. My apologies in advance.

I'm trying to learn about varying device parameters in LTSpice by setting up a potentiometer model so I can vary the rotation percent and see factors change within the circuit. I've created a .asc file with basically two resistors in it offering 3 terminals and with their values defined as R*(Val/100) and R*(1-Val/100) based on parameter Val which represents percentage rotation. I have created a .asy file, saved in the same place, with a simple symbol for it with 3 pin/ports. It has attributes Prefix: P, Spiceline: R=10k Val=50, Description: A Potentiometer.

When I set this up in a simple DC Voltage circuit and check the DC on the wiper, it behaves exactly as it should. Changing Val manually generates the right voltages on the wiper. If I try to automate stepping through the Val range 1-100 and displaying DC on the wiper it won't play!

I have the pot set in my schematic as "R=50k Val={PC}" and added a .op with two lines ".step param PC 1 100 1" and ".op". When I try to run I get the message "Cannot find definition of model "1" ". Changing the first start value parameter changes the message to match so it is the first parameter in the .step line after PC which is confusing it.

What I have set up seems to fit in with what I can see in other tutorial/references for this sort of thing. Can anyone point out where I am going wrong?
 

MikeML

Joined Oct 2, 2009
5,444
This works for me.

Note that the resistance computing expressions cannot evaluate to R=0; that is not allowed in Spice, so 1<=PC<=99; it cannot go to zero or 100.

137a.gif

I got a parametric hierarchical pot somewhere years ago (likely from the Yahoo LTSpice group)
 

Thread Starter

bordonbert

Joined Feb 21, 2012
40
This works for me.

Note that the resistance computing expressions cannot evaluate to R=0; that is not allowed in Spice, so 1<=PC<=99; it cannot go to zero or 100.
Thanks for the help Mike, I knew about the 0 issue but hadn't realised that 100 would be a problem. What you have there seems to be a carbon copy of what I have, with one little exception. In your formulae you have the value of the pot hard coded as 50k whereas I used a generic parameter 'R' to pass it in. So in each formula there are two variables. I didn't think that would be a problem but maybe it is the issue here? Can I only define one variable to the pot?

The original idea was to produce a generic pot so I could reuse it and define it as 25k, 100k etc without going into the hard coding in the background. Playing with the 'Val' parameter then gave me the ability to place it in any position.
 

eetech00

Joined Jun 8, 2013
3,942
hi

See attached. Image is self explanatory.

The 0 voltage source acts as a current meter.
I also used the 0 voltage source to allow independent naming of the nets.

The horizontal axis represents percentage of rotation.

Also..Change this
.param R=50k Val={PC} ValMin=1

To this:
.param R=50k Val=limit({PC},100,{ValMin}/100)

ValMin is minimum percentage.
This will limit the range of "Val" from 100 to 1.
 

Attachments

Last edited:

Deve

Joined Dec 28, 2015
95
That is my first obstacle in using LTSpice. I need to use Potentiometers for most everything I design and learning to use LTSpice is sort of hard without a Potentiometer model. If anyone has a working Pot symbol with working function, please let me in!
 

Alec_t

Joined Sep 17, 2013
14,313
Here's some pot files: linear, logarithmic and voltage-controlled. The control voltage and parameter 'wiper' are each in the range 0-1 inclusive. You can use the '.inc' directive to include potentiometer.sub, logpot.sub, potentiometer_vc.sub or logpot_vc.sub as appropriate.
 

Attachments

If you would like to have a more convenient way to work with potentiometers, you might like to try SystemVision. Here's your example using a potentiometer model:
https://www.systemvision.com/design/voltage-divider-circuit-using-potentiometer

upload_2016-1-6_13-4-3.png

The function generator creates a signal that models the human interaction with the pot.

If you want to try this yourself, you can create a free account on www.systemvision.com and copy the design. To add this potentiometer model to your personal library just right-click and select "Add Favorite" to add it to your favorites palette.

Here's another example of a design that uses a potentiometer (and a 555 timer): https://www.systemvision.com/design/555-timer-variable-duty-cycle
 
Top