In part one of "displaying and measuring signals" I have shown how to use the waveform viewer to interactively analyze signals.

Another method for analysis is the .MEASURE directive. Using this directive it is possible to let SPICE measure and log many signals directly and indirectly (e.g. derived by user-defined equations).

The .MEASURE directive is very powerful. Therefore I can and will not elaborate on it in detail. See the LTSPICE help for more information. However, in order to give you a glimpse of .MEASURE's capabilities, I will demonstrate how to find the -3 dB corner frequency of a simple LC low pass filter.

I will be using the circuit in figure 1:

Figure 1 Simple LC low pass filter

Running the simulation and displaying the voltage across C1 (V(N002)) gives a display as shown in figure 2:

Figure 2 Simulation result for the low pass filter

Using a combination of zooming and measurement via cursor an approximate -3 dB frequency of 24.8 kHz can be found (figure 3):

Figure 3 Finding the -3 dB frequency using a cursor and zooming

Using .MEASURE this point can be evaluated with better precision. Add the following SPICE directive to the schematic (see „Adding LTSPICE directives“):

.MEASURE AC meas_3db when mag(V(n002))=(1/sqrt(2))

This directive tells LTSPICE to measure a derived signal named meas_3db under the condition ("when") that the magnitude ("mag") of V(N002) is 0.707, i.e. -3 dB.

Figure 4 Using .MEASURE to find the -3 dB frequency of the low pass filter

After the simulation there will be a log file placed in the simulation directory (where your circuit file *.asc is stored). The log file has the same name as your circuit but the extension ".log", e.g. test.log. For the above example the log file reads:

Circuit: * d:\temp\test.ascThis tells us, that the -3 dB point for this filter is at 24815.6 Hz. This is as good a result as the one found by using the zoom-and-cursor method.

meas_3db: mag(v(n002))=(1/sqrt(2)) AT 24815.6

Date: Tue Aug 31 08:33:29 2010

Total elapsed time: 0.015 seconds.

... (plus some stuff irrelevant for this chapter)

However, .MEASURE is much more powerful:

Multiple .MEASURE directives can be added to quickly get all simulation results in one compact file.

.MEASURE directives can use math and a (limited) set of conditions to measure signals depending on simulation results

For example the following directives:

.MEASURE AC tmp max mag(V(n002))give a log file:

.MEASURE AC meas_3db_1 when mag(V(n002))=(tmp/sqrt(2)) cross=1

.MEASURE AC meas_3db_2 when mag(V(n002))=(tmp/sqrt(2)) cross=2

Circuit: * d:\temp\test.ascFrom this we can see that the rising edge of the transfer curve crosses max-3 dB at 15.4 kHz whereas the falling edge of the transfer curve crosses max-3 dB at 16.1 kHz. Therefore the -3 dB bandwidth of the resonant peak is 700 Hz. Of course, this measurement can be delegated completely to LTSPICE:

tmp: MAX(mag(v(n002)))=(34.1492dB,0°) FROM 100 TO 100000

meas_3db_1: mag(v(n002))=(tmp/sqrt(2)) AT 15401.8

meas_3db_2: mag(v(n002))=(tmp/sqrt(2)) AT 16150.9

...

.MEASURE AC tmp MAX mag(V(n002))which results in the following log file entries:

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

Circuit: * d:\temp\test.ascwhere the bandwidth is directly computed as being 749 Hz between 15.401 kHz and 16.1509 kHz.

tmp: MAX(mag(v(n002)))=(34.1492dB,0°) FROM 100 TO 100000

bw=749.112 FROM 15401.8 TO 16150.9

...

SPICE help topics to look at: .MEASURE, Zooming, waveform viewer including its sub-chapters

Harald Kapp, 2014-05-13