Content

Making measurements of simulation results

In the same way that digital storage oscilloscopes (DSO) allow measurements to be made of signals displayed on the screen using cursors and directly reading values from their positions and from mathematical analysis of the waveform data stored in the DSO memory, EasyEDA allows measurements to be made of simulation results directly using cursors and by analysis of the data used to create the WaveForm trace display using the .meas command.

Using the WaveForm display cursors

The WaveForm X and Y cursor functions are a simple and quick way to make measurements of points in waveforms and to make measurements of differences between points.

WaveForm allows the display of traces in any selection of up to three vertically stacked plot panes. The Y axes automatically scale to fit the units and the range of the traces being displayed. Traces can be hidden but at least one trace must be visible. X and Y trace data can be seen on-screen just by moving the mouse cursor around the plot area of a pane with the readout adapting to the Y axes in each pane.

THE FEATURE DESCRIBED IN THE FOLLOWING PARAGRAPH IS CURRENTLY NOT AVAILABLE.
SEE BUG REPORT:
https://easyeda.com/forum/topic/Left-click-and-drag-Delta-X-and-Delta-Y-info-no-longer-works-in-Waveform-6a533f06cfca4915b3af0ba40ef90c5e

Delta X and delta Y trace data can be seen on-screen using a Left-Click and Drag select box, with the readout adapting to the Y axes in each pane. Returning the cursor to within a small radius of the starting point of the select box - without releasing the Left-Click - returns the readout to X and Y trace data.

The cursor placement and results produced are volatile, meaning that they cannot be copied and pasted. They are not saved as part of a saved WaveForm file. However, using a screenshot utility, it is possible to save an image of the WaveForm display showing the cursor positions and their associated readout.

Note that the screenshot utility must have a user definable time delay to allow cursor placement to be carried out between initiating the screenshot and the screenshot actually being taken.
For more information on displaying simulation results in Waveform, please refer to the section on WaveForm in the the EasyEDA Tutorial.

Using the EasyEDA Oscilloscope

EasyEDA provides an interactive oscilloscope symbol with a short tutorial on how to use it given here:

How to use the EasyEDA Oscilloscope

Using the .meas command

The .meas command is used to analyse the output data of a .ac, .dc. Op, .tf, .tran, or .noise simulation. The command is executed immediately after the simulation has finished.
It is entered in the schematic in the same way as other spice directives with the:
Text Attribute > Text type > spice

To use .meas commands, run the simulation in the usual way by pressing:
F8
(was CTRL+R)
Then after the simulation has completed, go to the top toolbar of the Schematic tab and do:
Simulation > Show your simulation report…
to view the .meas statement results.

The meaning of terms in .MEAS commands

The .meas type [AC|DC|OP|TRAN|TF|NOISE] depends on the data which are to be evaluated, either originating from an AC analysis, DC, Operating point, Transient, Transfer Function or Noise analysis simulation. The .meas type is optional but when used allows a .MEAS statement to be used only for the given analysis type. This allows different selections of .meas statements to be used depending on the simulation type being run.

name will be a variable containing the result of the measurement. A name is required so that the result can be used as a parameter in other .MEAS statements.

trig_variable, targ_variable, and out_variable are vectors stemming from the simulation, e.g. a voltage vector v(out).

VAL=val expects a real number val. val may also be a real parameter or an expression enclosed by {} that expands to a real number.

TD=td and AT=time expect a time value if the .meas type is tran. For ac, AT will be a frequency value and TD is ignored.

For DC analysis AT is a voltage (or current), and TD is ignored.

CROSS=# requires an integer number #. CROSS=LAST is possible as well. The same is expected by RISE and FALL.

Frequency and time values may start at 0 and extend to positive real numbers. Voltage (or current) inputs for the independent (scale) axis in a dc analysis may start or end at arbitrary real valued numbers.
Results of .MEAS statements can be used as parameters in other .MEASURE statements.
Values defined as parameters in .param statements elsewhere in the simulation can be used as values and in expressions in .meas statements.
Functions can be used in values and expressions in .meas statements except for those invoking time as a variable (such as delay(x,time), the derivative function ddt(x) and the integral functions sdt(x) or idt(x)).

Types, syntaxes and examples of .meas commands

Types

There are two basic different types of .MEASURE statements. Those that refer to a point along the abscissa (the independent variable plotted along the horizontal, or x, axis, i.e., the time axis of a .tran analysis or the frequency axis of a .ac analysis) and .MEASURE statements that refer to a range over the abscissa.

For the purposes of this Tutorial, the first type of .MEASURE statements will be referred to as Point and the second as Range.

Point

.MEAS statements that point to a single point on the horizontal axis, are used to print a data value or expression thereof at a specific point or when a condition is met. The following syntax is used:

Syntax: .MEAS[SURE] [AC|DC|OP|TRAN|TF|NOISE]

  • [ ]
  • [WHEN | AT=]]
  • [TD=] [=[|LAST]]

The analysis type is optional but if used specifies the type of analysis to which the .MEAS statement applies. This allows .MEAS statements to be applied to only certain analysis types.

The result of the measurement is contained by the variable called name. The variable name can then allows the result to be used as a parameter in other .MEAS statements.

Below are examples of Point type .MEAS statements that return a value referring to a single point on the horizontal axis:

.MEAS TRAN res1 FIND V(out) AT=5m

Print the value of V(out) at t=5ms labelled as res1.

.MEAS TRAN res2 FIND V(out)*I(Vout) WHEN V(x)=3*V(y)

Print the value of the expression V(out)I(Vout) the first time the condition V(x)=3V(y) is met. This will be labelled res2.

.MEAS TRAN res3 FIND V(out) WHEN V(x)=3*V(y) cross=3

Print the value of V(out) the third time the condition V(x)=3*V(y) is met. This will be labelled res3.

.MEAS TRAN res4 FIND V(out) WHEN V(x)=3*V(y) rise=last

Print the value of V(out) the last time the condition V(x)=3V(y) is met when approached as V(x) increasing wrt 3V(y). This will be labelled res4.

.MEAS TRAN res5 FIND V(out) WHEN V(x)=3*V(y) cross=3 TD=1m

Print the value of V(out) the third time the condition V(x)=3*V(y) is met, but don’t start counting until the time has reached 1ms. This will be labelled res5.

.MEAS TRAN slope DERIV V(out) AT=5m

Print the value of the slope of V(out) at t=5ms labelled as slope.

.MEAS TRAN res6 PARAM 3*res1/res2

Print the value of 3*res1/res2. This form is useful for printing expressions of other .meas statement results. It’s not intended that expressions based on direct simulation data, such as V(3), are present in the expression to be evaluated, but if they are, the data is taken from the last simulated point. The result will be labelled res6.

Note that in the above examples, whilst the result refers to a single point along the horizontal axis, it is based on ordinate data (the dependent variables plotted on the vertical or y axis). If no ordinate information is requested, then the .MEAS statement prints the point on the abscissa at which the measurement condition occurs:

.MEAS TRAN res6 WHEN V(x)=3*V(y)

Print the first time the condition V(x)=3*V(y) is met. This will be labelled res6.

Similarly in an AC analysis:

.MEAS AC acres6 WHEN mag(V(x))=1/sqrt(2)

Print the lowest frequency that the condition mag(V(x))=1/sqrt(2) is met. This will be labelled acres6.

Range

The other type of .MEAS statement refers to a range over the abscissa (the independent variable plotted along the horizontal, or x, axis, i.e., the time axis of a .tran analysis or the frequency axis of a .ac analysis). The following syntax is used:

Syntax: .MEAS [AC|DC|OP|TRAN|TF|NOISE]

  • [ ]
  • [TRIG [[VAL]=]] [TD=]
  • [=]
  • [TARG [[VAL]=]] [TD=]
  • [=]

The range over the abscissa is specified with the points defined by “TRIG” and “TARG”. The TRIG point defaults to the start of the simulation if omitted. Similarly, the TARG point defaults to the end of simulation data. If all three of the TRIG, TARG, and the previous WHEN points are omitted, then the .MEAS statement operates over the entire range of data. The types of measurement operations that can be done over an interval are:

keyword Operation performed over interval
AVG Compute the average of
MAX Find the maximum value of
MIN Find the minximum value of
PP Find the peak-to-peak of
RMS Compute the root mean square of
INTEG Integrate

If no measurement operation is specified, the result of the .MEAS statement is the distance along the abscissa between the TRIG and TARG points.

Below are example interval .MEAS statements:

.MEAS TRAN res7 AVG V(NS01)
+ TRIG V(NS05) VAL=1.5 TD=1.1u FALL=1
+ TARG V(NS03) VAL=1.5 TD=1.1u FALL=1

Print the average value of V(NS01) from the 1st fall of V(NS05) to 1.5V after 1.1us and the 1st fall of V(NS03) to 1.5V after 1.1us. This will be labelled res7.

For .AC analyses, the conditional expressions of complex data are translated to real conditions by considering only the real part of the complex value of the expression.

This is an example of how the result of a .MEAS statement can be used in another .MEAS statement. In this case, the 3dB bandwidth is computed:

.MEAS AC tmp max mag(V(out)); find the peak response and call it "tmp"

.MEAS AC BW trig mag(V(out))=tmp/sqrt(2) rise=1
+ targ mag(V(out))=tmp/sqrt(2) fall=last

Print the difference in frequency between the two points 3dB down from peak response. NOTE: The data from a .AC analysis is complex and so are the .measurement statements results. However, the equality refers only to the real part of the complex number, that is, “mag(V(out))=tmp/sqrt(2)” is equivalent to Re(mag(V(out)))=Re(tmp/sqrt(2)).

The AVG, RMS, and INTEG operations are different for .NOISE analysis than the analysis types since the noise is more meaningfully integrated in quadrature over frequency. Hence AVG and RMS both give the RMS noise voltage and INTEG gives the integrated total noise. Hence, if you add the SPICE directives

.MEAS NOISE out_totn INTEG V(onoise)

.MEAS NOISE in_totn INTEG V(inoise)

the total integrated input and output referenced rms noise will be printed in the Simulation report.

Examples of the use of .MEAS statements

The .MEAS statements in LTspice are incredibly powerful but it can take a while to understand how to use them and get the best results.

It is therefore strongly recommended that a simplified test simulation should be set up and played with to try different set ups before using up the simulation allowance running blockbuster sims from which the .MEAS statements consistently fail.

To help in this, the following examples illustrate some of the measurements that can be made using .MEAS statements:

Measuring WaveForm parameters 01

Measuring WaveForm parameters 02

Measuring settling time

Find gain and bandwidth

How to measure period and frequency using a .meas statement

For more information on the .meas statement, search for .measure in Help in a locally installed copy of LTspiceXVII or visit ltwiki.org here:

http://ltwiki.org/LTspiceHelpXVII/LTspiceHelp/html/DotMeasure.htm

More examples of measure statements

.meas tran inv_delay 2 trig v(in) val='vp/2' td=1n fall=1 targ v(out) val='vp/2' rise=1 

.meas tran test_data1 trig AT=1n targ v(out) val='vp/2' rise=3

.meas tran out_slew trig v(out) val=' 0.2*vp' rise=2 targ v(out) val=' 0.8*vp' rise=2

.meas tran skew when v(out)=0.6

.meas tran skew2 when v(out)=skew_meas

.meas tran skew3 when v(out)=skew_meas fall=2

.meas tran skew4 when v(out)=skew_meas fall=LAST

.meas tran skew5 FIND v(out) AT=2n

.meas tran v0_min min i(v0) from='dfall' to='dfall+period'

.meas tran v0_avg avg i(v0) from='dfall' to='dfall+period'

.meas tran v0_integ integ i(v0) from='dfall' to='dfall+period'

.meas tran v0_rms rms i(v0) from='dfall' to='dfall+period'

.meas dc is_at FIND i(vs) AT=1

.meas dc is_max max i(vs) from=0 to=3.5

.meas dc vds_at when i(vs)=0.01

.meas ac vout_at FIND v(out) AT=1MEG

.meas ac vout_atd FIND vdb (out) AT=1MEG

.meas ac vout_max max v(out) from=1k to=10MEG

.meas ac freq_at when v(out)=0.1

.meas ac vout_diff trig v(out) val=01 rise=1 targ v(out) val=01 fall=1

.meas ac fixed_diff trig AT=10k targ v(out) val=0.1 rise=1

.meas ac vout_avg avg v(out) from=10k to=1MEG

.meas ac vout_integ integ v(out) from=20k to=500k

.meas ac freq_at2 when v(out)=01 fall=LAST

.meas ac vout_rms rms v(out) from=10 to=1G

On the accuracy of the results of .meas statements

.MEAS statements are carried out on post-simulation data, in other words after the simulation has completed and the data from it stored.

It is important to note that data generated by LTspice is in floating point format.

LTspice has optional settings on the level of compression that applies to the data that it generates as it is stored.

The combination of floating point number formats and data compression means that there is some scope for small errors in numerical accuracy due to the finite precision used in storing numbers.

Another consequence of this is that the accuracy of the .MEAS statement output is limited by the accuracy of the waveform data after it has been stored by LTspice using whatever the default data compression setting is used.

To limit the amount of data being handled by the EasyEDA servers, the full control of compression available through the Control Panel in a local installation of LTspice, is not made available to users.

It is however possible to reduce the level of compression applied to the stored data - and which is often enough - by including the following .option statement in a simulation schematic as a spice directive:

.option plotwinsize=0

Improving accuracy by reducing the level of compression of course may result in so much data being generated during the simulation that it will exceed the EasyEDA internal data storage limits and generate a

“Your Simulation Results are too large”

warning.

LTspice is very good at choosing its own value for the Maximum Timestep so it is perfectly permissible to enter a .tran statement simply as:

.tran

with no Maximum Timestep assigned.

The accuracy of the results from a Transient Analysis (.tran) however, is strongly dependent on the ratio:

(Stop Time)/(Maximum Timestep)

Therefore to increase the accuracy it may be desirable to add a Maximum Timestep value.

The larger this ratio the more accurate the results will be at the expense of longer simulation times and possibly exceeding the EasyEDA internal data storage limits and generating a

“Your Simulation Results are too large”

warning.

Similarly, the accuracy of the results from an AC Analysis (.ac) is strongly dependent on the number of points per decade/octave/sweep.

The larger the number of points, the more accurate the results will be but again there is the risk of generating too much data as described above.

(Note that due to a bug in EasyEDA a linear sweep is diplayed on a log frequency axis with a minimum span of a decade. This currently renders the display of linear frequency sweeps in EasyEDA useless.)

In the light of these accuracy considerations, it is therefore important to understand that when testing a condition such as:

“when =

It is more reliable to require that the conditions cross each other, rather than to require an exact equality, which may not be met due to an error in numerical accuracy.

This can be particularly problematic when trying to find exactly where the peak value of a signal or plat may occur on the x axis ( i.e. the time or the frequency axis).

It is easy enough to find the maximum (MAX) value but the x axis value at which this maximum may occur may not be available as a parameter. It is therefore tempting to use an equality testing WHEN the signal equals the MAX value to return the x axis value. Sometimes this may work, other times it may not.

There are several ways to solve this problem but about the most reliable solution is to test when the signal crosses a point slightly less than the MAX when approaching from the low side of the peak and again when departing from the high side.

To do this the signal could be compared to the maximum value minus and offset - or the maximum value multiplied by a number just less than 1 - on a RISE and then again on the next FALL. The RISE test returns a value on the x axis just below when the peak occurs and the FALL test another value just above it. It is then up to the user to decide whether to use one or the other or some function such as the average or the geometric mean of the two to give a better estimate of where the peak actually lies.

Since the slope of a function passes through zero at a peak or a trough, a more complex solution - although one that only works for Transient analyses (i.e. with time domain signals only) and which may not work well with noisy signals - could be to use a B Source with the ddt(x) function to generate the derivative of the signal being measured and then test for the derivative crossing zero to find the exact time of the peak or trough.


goToTop