3
\$\begingroup\$

I need some help with LTspice MEAS directive. I have a simple circuit, a DC power supply, and a variable Load resistor to observe the current limiter behavior. I made the variable load resistor and have it working with .step param Load .5 .1 .01, which starts at .5 ohms and ends at .1 ohms in .01 increments. I want to measure the current in the Load resistor, record the current at each step, and graph it out with current on the vertical axis and resistance on the horizontal axis.

Someone suggested I try.meas I1 peak I(R1). Unfortunately, it did not work. I looked at the error log and saw it tried to do something, but the values were 0.0, as shown below. Can anyone help me out with the code? I know it has to be easy, but I have little experience with LTspice.

Thank You

enter image description here

Edit: Added circuit

I added the circuit in case anyone is interested. It is an LDO voltage regulator with foldback current and soft turn-on. It is a CCCV linear 12-volt, 30-amp DC Power supply and battery charger.

U3 provides the 5-volt reference, and the associated RC circuit provides the soft turn-on circuit. U1, R12, and R13 are the voltage regulator and feedback network that set the output to 14 volts.

U2 and R1 to R6 form the current regulator with some degree of precision. At the 30-amp output, the circuit goes into Constant Current mode. If loaded over 30-amp, the voltage folds back and limits the current to 5 amps. R16 is my variable load.

FWIW I am not showing the pass elements M1 is driving. Fortunately, LTspice does not know I exceeded M1's current limit and does not let smoke out.

enter image description here

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

I just tossed together a quick foldback circuit. I set up \$R_1=1\:\Omega\$ so that the foldback should start somewhere after \$650\:\text{mA}\$. I set \$R_3\$ to provide enough base current for \$Q_2\$ (\$20\:\text{mA}\$ at a rough guess) to handle that maximum load current goal. \$R_2\$ and \$R_4\$ are set for the foldback bits. (Deferring the explanation unless/until someone cares.)

The circuit goal is to start seeing some foldback when the load current exceeds \$650\:\text{mA}\$ and before it gets above \$800\:\text{mA}\$, at a guess. Honestly, I'm just throwing mud at the wall here, but hopefully close enough.

The teaching goal is to just show how to use the .OP card to plot foldback behavior:

enter image description here

And that's it! The x-axis only goes from smaller to larger, so I can't flip the chart without modifying the x-axis. But the x-axis is the load resistance. Clearly the supply voltage is somewhere near \$15\:\text{V}\$, but a little less because of the circuit overhead.

As can be seen, it does exhibit some foldback right at \$750\:\text{mA}\$ peak. Read the chart from right to left (lower loading towards higher loading) and you can see that the supply voltage is dead-flat until the foldback point is reached (green curve.) The red curve shows the load current increasing until the foldback point is hit, when it is forced to decline as the load increases still further.

(I could add a few more BJTs to bring \$V_O\$ under voltage regulation, while including the foldback circuit. This is old-school stuff, pre-swicher days, so it almost flows out from my fingertips without thinking much about it. But I tried to keep the above focused on the foldback part. So there is a very small change in \$V_O\$ as the load increases prior to foldback due to the increasing overhead of the circuit. Just wanted to point out that this isn't a necessary consequence and that it is possible to include both precision voltage regulation as well as current foldback. But that it requires another few BJTs to get there and I avoided it, here, for now. It would have added additional unwanted distractions. If interested, the book I cut my eye-teeth on, is Switching and Linear Power Supply, Power Converter Design, by Abraham I. Pressman, 1977. It covers this and much more from a perspective during the very slow transition period between linear power supply design and the newly developing switcher design. It was top-notch at the time. And very much worth a review if interested in how things looked back then as compared to now. I owe the author much I cannot ever pay back.)

\$\endgroup\$
2
  • \$\begingroup\$ FWIw if you want to see the circuit, I added it. It is a working design. I am trying to find the right Op-Amps over my head. I think I can use something else, but I do not know what I want in an opamp. I know CMRR, unity gain stability, and rail-to-rail are important, but outside of that, I am clueless. I know just enough to be dangerous and how to modify a circuit. \$\endgroup\$
    – Dereck
    Commented Mar 6 at 21:19
  • \$\begingroup\$ @Dereck I wanted to show how to set up a series of resistor values as trial loads and then plot results using the .OP card. Hopefully, that helps you with your own schematic work. \$\endgroup\$ Commented Mar 7 at 3:41
3
\$\begingroup\$

That .meas command isn't going to work.

Try this: .MEAS TRAN I1 FIND I(R1) AT 0.5

This will give you a .MEASurement for TRANsient analysis, name the result I1, and FIND the value of I(R1) at time 0.5 seconds (change that if needed, it needs to be within the time range of your .tran command).

You can right click the .meas command in the schematic and it will give you a dialog to change all kinds of settings for it.

\$\endgroup\$
8
  • \$\begingroup\$ thank you, it worked—one follow-up question. When I look in the error log I see the Step param started at .1 and counted up to .5 which I can make work. But I thought the way I wrote it would count down from .5 to .1. Can I make that happen? I have it written (.step param Load .5 .01 0.01) Thx again, very much appreciated. \$\endgroup\$
    – Dereck
    Commented Mar 6 at 1:43
  • \$\begingroup\$ @Dereck try stepping from .1 to .5, see if the results come out in opposite order. \$\endgroup\$
    – GodJihyo
    Commented Mar 6 at 1:56
  • \$\begingroup\$ I ran some comparisons tests. LTspice accepts a negative increment, but it seems still to order the values in ascending order. LTspice will not accept a previously defined variable as an increment, though: ".param Vin list 20V 0V -5V" generates the sequence 0V, 5V, 10V, 15V, and 20V. But ".param Vin list 20V 0V {increment}" fails even if the variable "increment" has already been defined as -5V. \$\endgroup\$ Commented Mar 6 at 2:56
  • 1
    \$\begingroup\$ @periblepsis Oh... that's nice. I did not know it would do that. That will come in handy I'm sure. Thanks. \$\endgroup\$
    – GodJihyo
    Commented Mar 6 at 4:38
  • 1
    \$\begingroup\$ @GodJihyo I tossed out something. I've no clue what kind of foldback the questioner is using, so I made one up. I have no clue what else surrounds their circuit, so I didn't care and just used an ideal voltage source. But it does show how to get a plot using the .OP card and a .STEP. \$\endgroup\$ Commented Mar 6 at 6:21

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.