Seeking help with LTspice simulation of Variable Power Supply - Page 1
Forum section: electronics / beginners

author: ChanceMcCrance
author_rank: Newbie
timestamp: August 15, 2018, 11:22:24 pm
content: Hello,I am trying to create an LTspice (version XVII) simulation of a variable power supply. When I try to run the simulation, I get an error saying "Unknown subcircuit called in: xr1 n004 n003 5000." Based on what I have read, the software cannot find the subcircuit for R1 (5k, variable resistor). The component was taken directly from the LTspice library, so I was not sure why I encountered this error. Any insight as to how I can correct the issue? Is there something I should add to the simulation command?Any help would be super appreciated. The file is attached if you would like to test it for yourself.Best,Chance

author: hugo
author_rank: Regular Contributor
timestamp: August 15, 2018, 11:58:13 pm
content: Why don't you try this one instead?

author: Ian.M
author_rank: Super Contributor
timestamp: August 16, 2018, 12:03:59 am
content: The description of 'xvaristor.asy' that you used for R1 says:QuoteIf you simply want to patch it to run with the default fixed resistor model, Ctrl-click R1 to open the component attribute editor and change the prefix line from X to R

author: mdszy
author_rank: Unknown
timestamp: August 16, 2018, 01:24:15 am
content: Is there a specific reason you need a variable resistor model? You can always do a.step commandto change the value of a normal resistor across multiple simulations and see what the effect of changing the value is.

author: ChanceMcCrance
author_rank: Newbie
timestamp: August 16, 2018, 01:36:05 am
content: I wanted to create a simulation of a variable power supply that I had built which used a 5k variable resistor. I suppose using the .step command would be ok for now.

author: mdszy
author_rank: Unknown
timestamp: August 16, 2018, 01:38:50 am
content: Quote from: ChanceMcCrance on August 16, 2018, 01:36:05 amVariable resistor, or potentiometer? If you're using a potentiometer, you can replace it with two resistors that change along with each other to always be a constant 5k, but the resistance at each side of the "wiper" changes.

author: ChanceMcCrance
author_rank: Newbie
timestamp: August 16, 2018, 01:43:48 am
content: It's technically a potentiometer, but I am only using the first two terminals of it. (like a rheostat)

author: mdszy
author_rank: Unknown
timestamp: August 16, 2018, 01:45:34 am
content: Quote from: ChanceMcCrance on August 16, 2018, 01:43:48 amAh, right. Then the .step command with a single resistor is exactly what you want.

author: Zero999
author_rank: Super Contributor
timestamp: August 16, 2018, 03:10:04 pm
content: An arrow can by drawn on the standard resistor symbol, to make it clear it's a variable resistor.Other options are a time and voltage controlled resistor.To make a variable resistor, which starts at 1Ohm and increases to just over 1k, over a second:Set the value of the resistor to:R=1+1k*timeOr: set the resistor value to:R=V(V_res)And create a voltage source with the net named V_res and set its value to:PULSE(1 1k 0 1)The time controlled resistor is the easiest, but least flexible and the voltage controlled resistor is a bit more difficult but more flexible, as it can be ramped up and down.I've attached the .asc files.

author: Ian.M
author_rank: Super Contributor
timestamp: August 16, 2018, 03:56:17 pm
content: As Hero999 points out, a voltage controlled resistor or potentiometer is the most flexible, but a parameter controlled one is much simpler to simulate and is adequate if you only need to set or step its initial value, which is then fixed within each run.If you need actual potentiometers, here are the models I use:potentiometer.asy is parameter controlled - set the instance parameter Rtot to total track resistance and wiper to the wiper position (0 to 1). Use a .param or .step param command on your sim for control. e.g to sweep it 0% to 100% in 10% steps :Code:.step param pot1 0 1 0.1and on the actual potentiometer instance:Code:Rtot=10K wiper={pot1}potentiometerVC is voltage controlled with the wiper position set by a control voltage in the range 0 to 1V, with respect to the circuit universal ground node 0. Simply ground the control voltage source's negative terminal, drop a net label on its positive terminal, and the same net label on the potentiometerVC's control terminal (far end of dotted line opposite wiper). Its total track resistance is set by the instance parameter Rtot.Both limit the effective wiper position to the range 0.001 to 0.999 as the LTspice SPICE engine cant handle resistances actually going to zero. When the wiper position is zero, its at the bottom end of the track if the symbol hasn't been rotated.