12
\$\begingroup\$

I'm designing a circuit but I'm computing the values of components based on a set of design values. For example,

.param Vi=120
.param Po=100
.param Ro='(Vi*Vi)/(2*pi*pi*Po)'

where Vi and Po are design parameters and Ro is being computed from the design values. This is convenient but I don't know the value of Ro unless I compute it by hand, spreadsheet, etc., which is inconvenient.

Is there any way in LTSpice to automatically display/print out the value of Ro when I run the simulation?

\$\endgroup\$

3 Answers 3

12
\$\begingroup\$

Use the .measure directive and the result will appear in the LTspice log file. Something like

.measure tran MyRoValue param Ro

if I recall correctly.

\$\endgroup\$
4
\$\begingroup\$

I'll turn to necromancy just for the sake of adding that you can have the .params displayed in the schematic, without the need to check the error log, but available only after the simulation, by placing a voltage source with the value of the .param, and adding an .op label:

test

Caveat emptor: if the circuit can be solved without a .op, the label will only display ??? (or the menu entry for Place .op Data Label will not be available), so either use some initial conditions in the simulation card, or add a behavioural source (like in the image above). A bv will always display the .op labels.

Of course, all this comes with the drawback of extra elements in the schematic, but if your schematic has many such .params to be measured, having a dedicated little corner with a bunch of these bv can save you of a headache, since these, and their nodes, can also be (re-)named into something meaningful and easily recognizeable, while the error log can be a little bit too much of a clutter. And, even if they are extra elements and count towards the matrix solver, they won't burden the computations in a palpable way.


To add a .op Data Label:

Right-click on the net and a 5-entry menu will appear. The 4th entry will be 'Place .op Data Label'. You can also perform some math on the expressions.

Adding a .op data label

\$\endgroup\$
2
  • \$\begingroup\$ What's an ".op label" and how do you add it? \$\endgroup\$
    – asdf30
    Sep 19, 2020 at 13:29
  • 3
    \$\begingroup\$ @asdf30 Right-click on the net and a 5-entry menu will appear. The 4th entry will be Place .op Data Label. You can also perform some math on the expressions. \$\endgroup\$ Sep 20, 2020 at 10:09
1
\$\begingroup\$

Joe is right, but use curly braces in your .param definition to define non-constant values:

.param Vi = 120
.param Po = 100
.param Ro = {(Vi*Vi) / (2*pi*pi*Po)}

Or, as an alternative curly braces can be substituted with single quotes (as per the comments, below):

.param Ro = '(Vi*Vi) / (2*pi*pi*Po)'

After the simulation is done check the 'SPICE Error Log' for your calculated values. (View Menu > SPICE Error Log) or simply CTRL + L.

See the link LTWiki Hints

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You don't need curly braces with .param statements, the same way you don't need them inside the expressions of behavioural sources. They may be needed in Laplace expressions, in certain cases. That example you linked is false and misleading, since the so-called "wrong" example has the parameter for capacitor Cap, not Capa. If you modify it accodingly, you'll see there is no error in any of those two cases. ltwiki.org is a site to be trusted, but sometimes errors can creep up, since it's only humans that modify it. \$\endgroup\$ Apr 30, 2020 at 16:40
  • 1
    \$\begingroup\$ Besides, even if useless, OP has already used single quotes, '...', which are the equivalent of the curly braces. Curly braces were needed once upon a time, in .meas commands, but that has not been the case for quite a while now. \$\endgroup\$ Apr 30, 2020 at 16:51

Your Answer

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

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