Difference between revisions of "Hints on using individual LTspice commands and things the Help Manual sometimes may not help you with"

From LTwiki-Wiki for LTspice
(.Param and Curly Brackets)
(9 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
.param
 
.param
  
One of the more confusing aspects of using .param (at least when I began using LT) was where and when do you use the curly barckets {} ?
+
One of the more confusing aspects of using .param (at least when I began using LTspice) was where and when do you use the curly barckets { } ?
  
Beginning with the simplest definition, LT doesn't require curly brackets  
+
Beginning with the simplest definition, LTspice doesn't require curly brackets:
 
+
.param res1 = 1000
.param res1 = 1000
+
This could be used to define a resistor of 1000 Ohms.
 
 
This could be used to define a resistor of 1000 Ohms  
 
  
 
However, in the real world, a parameter sometimes needs to be defined from other parameters.
 
However, in the real world, a parameter sometimes needs to be defined from other parameters.
  
To get results and not pull errors within LT, it becomes useful to use curly brackets.
+
To get results and not pull errors within LTspice, it becomes useful to use curly brackets. Without them - you can only nest (calculated) .param values, one parameter calculation deep.
Without them - you can only nest (calculated) .param values, one parameter calculation deep.
 
  
Going any deeper (where one calculation depends on another etc) will invite LTspice to complain with an error.
+
Going any deeper (where one calculation depends on another etc.) will invite LTspice to complain with an error.
  
  
  
'''Correct Method { doesn't pull errors }'''  
+
'''Correct Method (doesn't pull errors)'''  
  
 +
<nowiki>*</nowiki> Comment line : Calculate capacitance
  
* Comment line : Calculate capacitance
+
<nowiki>*</nowiki> -------------------------------------
* -------------------------------------
 
.param length = {3e-2}
 
.param width  = {4e-3}
 
.param area = {length * width}
 
.param gap = {40e-6}
 
.param Eo = {8.85e-12}
 
.param Capa = { (Eo * gap) / area}
 
.MEAS Capa_  PARAM Capa
 
  
 +
.param length = {3e-2}
 +
 
 +
.param width  = {4e-3}
 +
 +
.param area = {length * width}
 +
 +
.param gap = {40e-6}
 +
 +
.param Eo = {8.85e-12}
 +
 +
.param Capa = { (Eo * gap) / area}
 +
 +
.MEAS Capa_  PARAM Capa
  
 
The answer (from the error log ) is:
 
The answer (from the error log ) is:
capa_: capa=2.95e-012
+
capa_: capa=2.95e-012
  
 
+
To see the results in LTspice use the Error Log (a better name would have perhaps been ''Results Log'' or ''Output Log'')  
To see the results in LTspice  
 
Use the Error Log (a better name would have been the results log)  
 
  
 
   
 
   
 
'''Incorrect method (pulls errors)'''
 
'''Incorrect method (pulls errors)'''
 
+
.param length = 3e-2  
.param length = 3e-2  
+
.param width  = 4e-3
+
.param width  = 4e-3
.param area = length * width
+
.param gap = 40e-6
+
.param area = length * width
.param Eo = 8.85e-12
+
.param Cap =  (Eo * gap) / area}
+
.param gap = 40e-6
.MEAS Capa_  PARAM Capa
+
 +
.param Eo = 8.85e-12
 +
 +
.param Cap =  (Eo * gap) / area
 
   
 
   
 +
.MEAS Capa_  PARAM Capa
  
 
Error:
 
Error:
Warning Can't resolve .param cap=(eo * gap)area)
+
Measurement "capa_" FAIL'ed
 
 
  
The quickest way to check a calculation before you commit it to a library  
+
The quickest way to check a calculation before you commit it to a library is to create a section of text within the LT schematic. Set the text as LTspice directive (command), then run the schematic  
is to create a section of text within the LT schematic.  
 
Set the text as LTspice directive (command) ,  
 
then run the schematic  
 
  
  
Line 73: Line 74:
  
 
'''Suggestion:'''  
 
'''Suggestion:'''  
Set the Tools/Control panel/ Operation / Generate Expanded Listing  
+
Set the Tools/Control panel/ Operation / Generate Expanded Listing and tick (yes) to see a more comprehensive output listing - helps with debugging
and tick (yes) to see a more comprehensive output listing - helps with debugging
 

Revision as of 00:10, 10 August 2009

Add items as subpages (rather than details at this page level)


.Param and Curly Brackets

.param

One of the more confusing aspects of using .param (at least when I began using LTspice) was where and when do you use the curly barckets { } ?

Beginning with the simplest definition, LTspice doesn't require curly brackets:

.param res1 = 1000

This could be used to define a resistor of 1000 Ohms.

However, in the real world, a parameter sometimes needs to be defined from other parameters.

To get results and not pull errors within LTspice, it becomes useful to use curly brackets. Without them - you can only nest (calculated) .param values, one parameter calculation deep.

Going any deeper (where one calculation depends on another etc.) will invite LTspice to complain with an error.


Correct Method (doesn't pull errors)

* Comment line : Calculate capacitance

* -------------------------------------

.param length = {3e-2}
 
.param width  = {4e-3}

.param area = {length * width}

.param gap = {40e-6}

.param Eo = {8.85e-12}

.param Capa = { (Eo * gap) / area}

.MEAS Capa_  PARAM Capa

The answer (from the error log ) is:

capa_: capa=2.95e-012

To see the results in LTspice use the Error Log (a better name would have perhaps been Results Log or Output Log)


Incorrect method (pulls errors)

.param length = 3e-2 

.param width  = 4e-3

.param area = length * width

.param gap = 40e-6

.param Eo = 8.85e-12

.param Cap =  (Eo * gap) / area

.MEAS Capa_  PARAM Capa

Error:

Measurement "capa_" FAIL'ed

The quickest way to check a calculation before you commit it to a library is to create a section of text within the LT schematic. Set the text as LTspice directive (command), then run the schematic


Finding the measure results of a simulation Check your results in the error log Found from the toolbar : View/Spice error Log


Suggestion: Set the Tools/Control panel/ Operation / Generate Expanded Listing and tick (yes) to see a more comprehensive output listing - helps with debugging