13

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?

jkiv
  • 182
  • 1
  • 1
  • 8

3 Answers3

12

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.

Joe Hass
  • 8,447
  • 1
  • 29
  • 41
5

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

pfabri
  • 758
  • 7
  • 18
a concerned citizen
  • 21,167
  • 1
  • 20
  • 40
0

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

pfabri
  • 758
  • 7
  • 18
  • 1
    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. – a concerned citizen Apr 30 '20 at 16:40
  • 1
    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. – a concerned citizen Apr 30 '20 at 16:51