32
\$\begingroup\$

I want to simulate the load regulation of a power-supply. I'm sure I remember being able to vary the value of a resistor over the course of a simulation in LTspice, but I can't remember how. Anyone?

\$\endgroup\$

5 Answers 5

14
\$\begingroup\$

Use the SpecialFunctions/Varistor.asy component with a time-varying voltage source

Screenshot

\$\endgroup\$
7
  • \$\begingroup\$ +1 Thanks, Its not how I remember doing it but It should do the trick. I won't mark this approved just yet I like to see if anyone has any alternatives..(although it doesn't look likely...) \$\endgroup\$
    – volting
    Commented Jul 20, 2010 at 15:29
  • 2
    \$\begingroup\$ There are plenty of alternatives - You could use a transistor with a known Rds characteristic, and change the gate voltage from 0 to saturation, or just put in a voltage or current source and ramp through the voltage or current range that you want to establish across your resistor. The varistor, however, is the controllable resistor you asked for. \$\endgroup\$ Commented Jul 20, 2010 at 16:35
  • \$\begingroup\$ Sure.. but if my memory serves me correctly(which it probably doesn't) it is possible to do it with a regular resistor + some simulation command, which would be more intuitive and straight forward. Anyway Thanks again for the suggestions \$\endgroup\$
    – volting
    Commented Jul 20, 2010 at 18:19
  • \$\begingroup\$ Use the source, Luke! Open up the varistor model definition and subcircuit, and figure out what it does - The SPICE commands should be in there somewhere. This document: ltspice.linear.com/software/scad3.pdf should help you. \$\endgroup\$ Commented Jul 20, 2010 at 19:20
  • \$\begingroup\$ Point taken! It came to me... what I used before was a parametric sweep \$\endgroup\$
    – volting
    Commented Jul 20, 2010 at 20:22
39
\$\begingroup\$

Unfortunately using a varistor will not work, as a varistor itself has a dependence on the voltage across it. Much simpler is to right click onto an existing resistor, and to enter a formula. E.g.

R=11-100*time

will linearily reduce the resistance from 11Ohm to 1Ohm over the time of 100ms. You can use almost all functions available for the voltage b sources (arbitrary behavioural voltage source), as well as all kinds of measurements e.g. of voltages of other nodes.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ It woint work for R=0+100*time. \$\endgroup\$
    – 71GA
    Commented Feb 14, 2020 at 15:44
  • 3
    \$\begingroup\$ @71GA: neither will any construct that has 0Ω resistance... just don't do it then. \$\endgroup\$
    – PlasmaHH
    Commented Feb 21, 2020 at 10:22
  • \$\begingroup\$ Ah! So this was the problem. Thank you! \$\endgroup\$
    – 71GA
    Commented Feb 21, 2020 at 15:55
  • \$\begingroup\$ I find this method fiddly to work with - it's easier to use Paul McHale's solution and use a voltage source with the standard pulse/sine/pwm etc. to control it, easily editable via the dialog. (or any other signal you can label). \$\endgroup\$
    – drojf
    Commented Apr 5 at 13:49
  • \$\begingroup\$ @drojf all ways have their pros and cons, this one is quick to change back and forth and also doesn't clutter your schematic if you have lots of them. Also it is a tiny bit more performant. Using the voltage source way has the advantage of being able to use all the ways you configure them for values. \$\endgroup\$
    – PlasmaHH
    Commented Apr 5 at 21:18
29
\$\begingroup\$

There is another way. Setup a Voltage source and choose the output you want. Label the output net VResistance. Volts on source will be exactly what the resistance is. I.e. 10KV will be the same as 10K ohm. Then use the standard resistor with the assignment R=V(Vresistance). As the voltage source changes, the resistor changes with it. The nice thing about this is the PWL file can now be used to control the resistance. Expecially nice when running things from Mathematica or Matlab.

\$\endgroup\$
7
  • \$\begingroup\$ Nice Paul, that was exactly what I was looking for. Even tried "R=PWL(...)" as the value. \$\endgroup\$
    – rdtsc
    Commented Aug 11, 2015 at 21:28
  • \$\begingroup\$ I had to google "PWL file", but now I see potential advantage of this method when interacting with external programs. By the way, I think under the hood this works also as behavioral (expression) for the resistor. \$\endgroup\$ Commented Oct 13, 2015 at 22:32
  • \$\begingroup\$ This was my favorite solution. Full write up here:electronicspoint.com/resources/… \$\endgroup\$
    – Frederick
    Commented Sep 30, 2018 at 21:28
  • \$\begingroup\$ I believe I've done this all correctly, but am getting the error "Can't find definition of model "V". I've created a PWL voltage source and wired up ground and a node "Vres" to it. Then I have a resistor R6 which I've assigned the value V(Vres) as the resistance. @Frederick is there an updated link you could provide to that electronicspoint page? \$\endgroup\$
    – AJbotic
    Commented Oct 30, 2022 at 17:59
  • 1
    \$\begingroup\$ @AJbotic - yes.. though do note that the Source for your article is this exact StackExange convo... very circular! \$\endgroup\$
    – Frederick
    Commented Nov 3, 2022 at 14:03
2
\$\begingroup\$

Using McHale's suggestion, I produced a Current Dummy xLoad to test power supplies and power circuits. Based on a PWL sequence, the Load sucks current from the power supply, no matter the voltage at the supply.

The PWL sequence specifies a ramp&shake profile that exercises the supply, so one could analyse the behavior of such supply, if it bounces, oscillate, ring, voltage recuperation time, etc.

The xLoad .asy file can be anything with two connections, since it behaves like a dynamic resistor that change its value based on the PWL values AND the voltage applied at the Load inputs. You can apply a 10Vdc with a ripple of 9V and the Load will adapt its dynamic resistor so it follows the current profile from the PWL.

The xLoad has only one parameter, "mult". This parameter allows the user to change the maximum current from the PWL profile, so, mult=1 will use a profile that will suck maximum of 1A from the supply, mult=4.2 will suck a maximum of 4.2A. Your xload.asy must have a visible attribute "mult=1", so the xLoad will work, and you will be able to change the attribute at any time.

The xLoad uses a small capacitor to round very sharp edges that can simulate very high frequencies and rings, what doesn't happen in real life, so all the corners are a little rounded. If you want to change or eliminate this feature, just change the value of C1 from 10n or even eliminate that line. The feature is just a RC filter, R2 and C1, other way to change the filter is changing the value or R2, just don't delete such line, xLoad will not work without R2, you can change its value to zero ohms to eliminate completely the filter, even so I don't know why you will want to have MegaHertz sharp corners.

Create a text filename XLOAD.SUB into your LTSPICE/LIB/SUB directory, with the following contents (the "v1" line is long, not broken):

    * xLOAD
    * PWL Current Profile
    * By Wagner Lipnharski Nov/2015
    *
    *              Positive (Input)
    *              |  Negative (Output)
    *              |  |
    .SUBCKT XLOAD  1  2

    V1 3 2 PWL(0 0 +100m 0 +0.1m 0.2 +5m 0.2 +.1m 0.5 +5m 0.5 +.1m 1 +5m 1 +.1m 1.5 +5m 1.5 +.1m 2 +5m 2 +.1m 2.5 +5m 2.5 +.1m 3 +5m 3 +.1m 3.5 +5m 3.5 +.1m 4 +10m 4 +1m 3.5 +8m 3.5 +1m 4 +10m 4 +2m 2.5 +8m 2.5 +2m 4 +10m 4 +2m 1.5 +8m 1.5 +2m 4 +3m 4 +2m 0.2 +3m 0.2 +2m 4 +10m 4 +3m 0.2 +8m 0)

    R1 1 2 R=V(1,2)*4/(mult*V(4,2)+1n)

    R2 3 4 1k

    C1 4 2 10n

    .ENDS XLOAD

The simple .asc simulation with the symbol I made, and the plot planes showing current and supply rippled voltage below. Note that based on the PWL timmings, xLoad starts running at 100ms and finished at 235ms. You can change those timings at the PWL values inside the SUB.

enter image description here

enter image description here

\$\endgroup\$
1
\$\begingroup\$

If you want to step through values for resistor values (example R):

  1. Set the value of resistor that you want to be variable, to be {R} (don't forget the curly brackets!)
  2. Click on .op (far right on the toolbar)
  3. Type: .step param R 1 10k 1k (steps from 1 to 10K in 1k increments)

If you want to sweep the value of R in time, then it's not possible as the simulators will have convergence problems!

\$\endgroup\$
1
  • \$\begingroup\$ I don't think this is what the OP is looking for, though, and other answers suggest it's possible. \$\endgroup\$
    – Null
    Commented Mar 18, 2016 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.