18 - Measurement Expressions
Measurements overview
Measurement expressions evaluate the characteristics of a waveform. A measurement expression is made by choosing the waveform and the waveform calculation you want to evaluate.
The waveform calculation is defined by a measurement definition such as rise time, bandpass bandwidth, minimum value, and maximum value.
For example, if you want to measure the risetime of your circuit output voltage, use the following expression:
Risetime(v(out))
For a list of the PSpice A/D measurement definitions, see Measurement definitions included in PSpice A/D.
You can also create your own custom measurement definitions. See Creating custom measurement definitions in the Power Users section of this chapter.
Measurement strategy
- Start with a circuit created in design entry tool and a working PSpice A/D simulation.
- Decide what you want to measure.
- Select the measurement definition that matches the waveform characteristics you want to measure.
- Insert the output variable (whose waveform you want to measure) into the measurement definition, to form a measurement expression.
- Test the measurement expression.
Procedure for creating measurement expressions
Setup
Before you create a measurement expression:
- Design a circuit in a design entry tool.
- Set up a PSpice simulation:
- Time Domain (transient)
- DC Sweep
- AC Sweep/Noise
- Run the circuit in PSpice A/D.
Make sure the circuit is valid and you have the results you expect.
Composing a measurement expression
These steps show you how to create a measurement expression in PSpice.
First select a measurement definition, and then select output variables to measure. The two combined become a measurement expression.
Work in the Simulation Results view in PSpice A/D. In the side toolbar, click .
- From the Trace menu in PSpice A/D, select Measurements.
The Measurements dialog box appears. - Select the measurement definition you want to evaluate.
- Click Eval (evaluate).
The Arguments for Measurement Evaluation dialog box appears. - Click the Name of trace to search button.
The Traces for Measurement Arguments dialog box appears.
You will only be using the Simulation Output Variables list on the left side. Ignore the Functions or Macros list. - Uncheck the output types you do not need (if you want to simplify the list).
- Click on the output variable you want to evaluate.
The output variable appears in the Trace Expression field. - Click OK.
The Arguments for Measurement Evaluation dialog box reappears with the output variable you chose in the Name of trace to search field. - Click OK.
Your new measurement expression is evaluated and displayed in the PSpice A/D window. - Click OK in the Display Measurement Evaluation pop-up box to continue working in PSpice A/D.
Your new measurement expression is saved, but it no longer displays in the window. The only way to get another graphical display is to redo these steps.
You can see a numerical evaluation by following the next steps.
Viewing the results of measurement evaluations
- From the View menu in PSpice A/D, select Measurement Results.
The Measurement Results table displays below the plot window. - Click the box in the Evaluate column.
The PSpice A/D calculation for your measurement expression appears in the Value column.
Example
First you select a measurement definition, and then you select an output variable to measure. The two combined become a measurement expression.
Work in the Simulation Results view in PSpice A/D. In the side toolbar, click on .
- From the Trace menu in PSpice A/D, select Measurements.
The Measurements dialog box appears.
- Select the measurement definition you want to evaluate.
- Click the Eval button.
The Arguments for Measurement Evaluation dialog box appears.
- Click the Name of trace to search button.
The Traces for Measurement Arguments dialog box appears.You will only be using the Simulation Output Variables list on the left side. Ignore the Functions or Macros list. - Uncheck the output types you do not need (if you want to simplify the list).
- Click on the output variable you want to evaluate.
The output variable appears in the Trace Expression field. - Click OK.
The Arguments for Measurement Evaluation dialog box reappears with the output variable you chose in the Name of trace to search field. - Click OK.
Your new measurement expression is evaluated and displayed in the PSpice A/D window. - Click OK in the Display Measurement Evaluation pop-up box to continue working in PSpice A/D.
Your new measurement expression is saved, but does not display in the window. The only way to get another graphical display is to redo these steps. You can see a numerical evaluation by following the next steps. - Click Close.
Viewing the results of measurement evaluations.
- From the View menu, select Measurement Results.
The Measurement Results table displays below the plot window. - Click the box in the Evaluate column.
A check mark appears in the Evaluate column check box and the PSpice A/D calculation for your measurement expression appears in the Value column.
Measurement definitions included in PSpice A/D
Definition | Finds the. . . |
---|---|
Bandwidth |
Bandwidth of a waveform (you choose dB level) |
Bandwidth_Bandpass_3dB |
Bandwidth (3dB level) of a waveform |
Bandwidth_Bandpass_3dB_XRange |
Bandwidth (3dB level) of a waveform over a specified X-range |
CenterFrequency |
Center frequency (dB level) of a waveform |
CenterFrequency_XRange |
Center frequency (dB level) of a waveform over a specified X-range |
ConversionGain |
Ratio of the maximum value of the first waveform to the maximum value of the second waveform |
ConversionGain_XRange |
Ratio of the maximum value of the first waveform to the maximum value of the second waveform over a specified X-range |
Cutoff_Highpass_3dB |
High pass bandwidth (for the given dB level) |
Cutoff_Highpass_3dB_XRange |
High pass bandwidth (for the given dB level) |
Cutoff_Lowpass_3dB |
Low pass bandwidth (for the given dB level) |
Cutoff_Lowpass_3dB_XRange |
Low pass bandwidth (for the given dB level) over a specified range |
DutyCycle |
Duty cycle of the first pulse/period |
DutyCycle_XRange |
Duty cycle of the first pulse/period over a range |
Falltime_NoOvershoot |
Falltime with no overshoot. |
Falltime_StepResponse |
Falltime of a negative-going step response curve |
Falltime_StepResponse_XRange |
Falltime of a negative-going step response curve over a specified range |
GainMargin |
Gain (dB level) at the first 180-degree out-of-phase mark |
Max |
Maximum value of the waveform |
Max_XRange |
Maximum value of the waveform within the specified range of X |
Min |
Minimum value of the waveform |
Min_XRange |
Minimum value of the waveform within the specified range of X |
NthPeak |
Value of a waveform at its nth peak |
Overshoot |
Overshoot of a step response curve |
Overshoot_XRange |
Overshoot of a step response curve over a specified range |
Peak |
Value of a waveform at its nth peak |
Period |
Period of a time domain signal |
Period_XRange |
Period of a time domain signal over a specified range |
PhaseMargin |
Phase margin |
PowerDissipation_mW |
Total power dissipation in milli-watts during the final period of time (can be used to calculate total power dissipation, if the first waveform is the integral of V(load) |
Pulsewidth |
Width of the first pulse |
Pulsewidth_XRange |
Width of the first pulse at a specified range |
Q_Bandpass |
Calculates Q (center frequency / bandwidth) of a bandpass response at the specified dB point |
Q_Bandpass_XRange |
Calculates Q (center frequency / bandwidth) of a bandpass response at the specified dB point and the specified range |
Risetime_NoOvershoot |
Risetime of a step response curve with no overshoot |
Risetime_StepResponse |
Risetime of a step response curve |
Risetime_StepResponse_XRange |
Risetime of a step response curve at a specified range |
SettlingTime |
Time from <begin_x> to the time it takes a step response to settle within a specified band |
SettlingTime_XRange |
Time from <begin_x> to the time it takes a step response to settle within a specified band and within a specified range.
|
SlewRate_Fall |
Slew rate of a negative-going step response curve |
SlewRate_Fall_XRange |
Slew rate of a negative-going step response curve over an X-range |
SlewRate_Rise |
Slew rate of a positive-going step response curve |
SlewRate_Rise_XRange |
Slew rate of a positive-going step response curve over an X-range |
Swing_XRange |
Difference between the maximum and minimum values of the waveform within the specified range |
XatNthY |
Value of X corresponding to the nth occurrence of the given Y_value, for the specified waveform |
XatNthY_NegativeSlope |
Value of X corresponding to the nth negative slope crossing of the given Y_value, for the specified waveform |
XatNthY_PercentYRange |
Value of X corresponding to the nth occurrence of the waveform crossing the given percentage of its full Y-axis range; specifically, nth occurrence of Y=Ymin+(Ymax-Ymin)*Y_pct/100 |
XatNthY_Positive Slope |
Value of X corresponding to the nth positive slope crossing of the given Y_value, for the specified waveform |
YatFirstX |
Value of the waveform at the beginning of the X_value range |
YatLastX |
Value of the waveform at the end of the X_value range |
YatX |
Value of the waveform at the given X_value |
YatX_PercentXRange |
Value of the waveform at the given percentage of the X-axis range |
ZeroCross |
X-value where the Y-value first crosses zero |
ZeroCross_XRange |
X-value where the Y-value first crosses zero at the specified range |
XatMinY |
Value of X corresponding to the minimum Y value, for the specified waveform |
XatMaxY |
Value of X corresponding to the maximum Y value, for the specified waveform |
XatMaxY_Range() |
Value of X corresponding to the maximum value of Y within the specified X-range |
For power users
Creating custom measurement definitions
Measurement definitions establish rules to locate interesting points and compute values for a waveform. In order to do this, a measurement definition needs:
- A measurement definition name
- A marked point expression
These are the calculations that compute the final point on the waveform. - One or more search commands
These commands specify how to search for the interesting points.
Strategy
- Decide what you want to measure.
- Examine the waveforms you have and choose which points on the waveform are needed to calculate the measured value.
- Compose the search commands to find and mark the desired points.
- Use the marked points in the Marked Point Expressions to calculate the final value for the waveform.
- Test the search commands and measurements.
An easy way to create a new definition is to use the PSpice Trace menu. Select Measurements to open the Measurements dialog box and then do the following:
- Select the definition most similar to your needs
- Click Copy and follow the prompts to rename and edit.
Writing a new measurement definition
- From the PSpice A/D Trace menu, choose Measurements.
The Measurements dialog box appears. - Click New.
The New Measurement dialog box appears. - Type a name for the new measurement in the New Measurement name field.
Make sure local file is selected.
This stores the new measurement in a .prb file local to the design. - Click OK.
The Edit New Measurement dialog box appears. - Type in the marked expression.
- Type in any comments you want.
- Type in the search function.
Your new measurement definition is now listed in the Measurements dialog box.
Using the new measurement definition
Your new measurement definition is now listed in the Measurements dialog box.
Definition example
- From the PSpice A/D Trace menu, choose Measurements.
The Measurements dialog box appears. - Click New.
The New Measurement dialog box appears. - Type in a name in the New Measurement name field.
- Make sure use local file is selected.
This stores the new measurement in a .prb file local to the design. - Click OK.
The Edit New Measurement dialog box appears. - Type in the marked expression:
point707(1) = y1
- Type in the search function.
{
1|Search forward level(70.7%, p) !1;
}
The search function is enclosed within curly braces.Always place a semicolon at the end of the last search function. - Type in any explanatory comments you want:
*
*#Desc#* Find the .707 value of the trace.
*
*#Arg1#* Name of trace to search
*
Similarly, you can create complex measurements. For example, you might want to determine the time at which a current wave crosses a specified value, say 2mA, and then determine the voltage value at this time. You can use the following syntax:
<Measurement Name>(1,2,Y_value,n_occur)=y2
*
*#Desc#* Find the value of voltage at the time at which
current crosses Y_value for the nth time.
*#Arg1#* Name of current trace to search
*#Arg2#* Name of voltage trace to search
*#Arg3#* Y value
*#Arg4#* nth occurrence
*
{
1| search forward for n_occur:level (Y_value,positive)
!1 ;
2| search forward Xvalue (x1) !2 ;
}
Using the new measurement definition
Your new measurement definition is now listed in the Measurements dialog box.
For an example of using a definition in a measurement expression to evaluate a trace, see Example .
Measurement definition syntax
Check out the existing measurement definitions in PSpice A/D for syntax examples.
- From the Trace menu in PSpice A/D, choose Measurements.
The Measurement dialog box appears. - Highlight any example, and select View to examine the syntax.
Measurement definition: fill in the place holders
Measurement name syntax
Can contain any alphanumeric character (A-Z, 0-9) or underscore _ , up to 50 characters in length. The first character should be an upper or lower case letter.
Examples of valid function names: Bandwidth, CenterFreq, delay_time, DBlevel1.
Comments syntax
A comment line always starts with an asterisk. Special comment lines include the following examples:
*#Desc#*
The measurement description
*#Arg1#*
Description of an argument used in the measurement definition.
These comment lines will be used in dialog boxes, such as the Arguments for Measurement Evaluation box.
Marked Point Expressions syntax
A marked point expression calculates a single value, which is the value of the measurement, based on the X and Y coordinates of one or more marked points on a curve. The marked points are found by the search command.
All the arithmetic operators (+, -, *, /, ( ) ) and all the functions that apply to a single point (for example, ABS(), SGN(), SIN(), SQRT() ) can be used in marked point expressions.
The result of the expression is one number (a real value).
Marked point expressions differ from a regular expression in the following ways:
- Marked point coordinate values (for example, x1, y3), are used instead of simulation output variables (v(4), ic(Q1)).
- Multiple-point functions such as d(), s(), AVG(), RMS(), MIN(), and MAX() cannot be used.
- Complex functions such as M(), P(), R(), IMG(), and G() cannot be used.
- One additional function called MPAVG can also be used. It is used to find the average Y value between 2 marked points. The format is:
MPAVG(p1, p2,[<.fraction>])
where p1 and p2 are marked X points and fraction (expressed in decimal form) specifies the range. The range specified by [<.fraction>] is centered on the midpoint of the total range. The default value is 1.
Example:
The marked point expression
MPAVG (x1, x5, .2)
will find the halfway point between x1 and x5 and will calculate the average Y value based on the 20 percent of the range that is centered on the halfway point.
Search command syntax
search [direction] [/start_point/] [#consecutive_points#] [(range_x [,range_y])] |
[for] |
[repeat:] <condition> |
Brackets indicate optional arguments.
You can use uppercase or lowercase characters, because searches are case independent.
[direction]
forward or backward
The direction of the search. Search commands can specify either a forward or reverse direction. The search begins at the origin of the curve.
[Forward] searches in the normal X expression direction, which may appear as backwards on the plot if the X axis has been reversed with a user-defined range.
Forward is the default direction.
[/start_point/]
The starting point to begin a search. The current point is the default.
Use this… | To start the search at this… |
---|---|
^ |
the first point in the search range |
Begin |
the first point in the search range |
$ |
the last point in the search range |
End |
the last point in the search range |
xn |
a marked point number or an expression of marked points, for example, x1 (x1 - (x2 - x1) / 2) |
[#consecutive points#]
Defines the number of consecutive points required for a condition to be met. Usage varies for individual conditions; the default is 1.
A peak is a data point with one neighboring data point on both sides that has a lower Y value than the data point.
If [#consecutive_points#] is 2 and <condition> is PEak, then the peak searched for is a data point with two neighboring data points on both sides with lower Y values than the marked data point.
[(range_x[,range_y])]
Specifies the range of values to confine the search.
The range can be specified as floating-point values, as a percent of the full range, as marked points, or as an expression of marked points. The default range is all points available.
Examples
This range… | Means this… |
---|---|
(1n,200n) |
X range limited from 1e-9 to 200e-9, Y range defaults to full range |
(1.5,20e-9,0,1m) |
both X and Y ranges are limited |
(5m,1,10%,90%) |
both X and Y ranges are limited |
(0%,100%,1,3) |
full X range, limited Y range |
(,,1,3) |
full X range, limited Y range |
(,30n) |
X range limited only on upper end |
[for] [repeat:]
Specifies which occurrence of <condition> to find.
If repeat is greater than the number of found instances of <condition>, then the last <condition> found is used.
Example
The argument:
2:LEvel
would find the second level crossing.
<condition>
Must be exactly one of the following:
- LEvel(value[,posneg])
- SLope[(posneg)]
- PEak
- TRough
- MAx
- MIn
- POint
- XValue(value)
Each <condition> requires just the first 2 characters of the word. For example, you can shorten LEvel to LE.
If a <condition> is not found, then either the cursor is not moved or the measurement is not evaluated.
LEvel(value[,posneg])
[,posneg] Finds the next Y value crossing at the specified level. This can be between real data points, in which case an interpolated artificial point is created.
At least [#consecutive_points#]-1 points following the level crossing point must be on the same side of the level crossing for the first point to count as the level crossing.
[,posneg] can be Positive (P), Negative (P), or Both (B). The default is Both.
(value) can take any of the following forms:
Value form | Example |
---|---|
a floating number |
1e5 100n 1 |
a percentage of full range |
50% |
a marked point or an expression of marked points |
x1 y1 (x1-x2)/2 |
a value relative to startvalue |
.-3 ⇒ startvalue -3 .+3 ⇒ startvalue +3 |
a db value relative to startvalue |
.-3db ⇒ 3db below startvalue .+3db ⇒ 3db above startvalue |
a value relative to max or min |
max-3 ⇒ maxrng -3 min+3 ⇒ minrng +3 |
a db value relative to max or min |
max-3db ⇒ 3db below maxrng min+3db ⇒ 3db above minrng |
decimal point ( . )
A decimal point ( . ) represents the Y value of the last point found using a search on the current trace expression of the measurement. If this is the first search command, then it represents the Y value of the startpoint of the search.
SLope[(posneg)]
Finds the next maximum slope (positive or negative as specified) in the specified direction.
[(posneg)] refers to the slope going Positive (P), Negative (N), or Both (B). If more than the next [#consecutive_points#] points have zero or opposite slope, the Slope function does not look any further for the maximum slope.
Positive slope means increasing Y value for increasing indices of the X expression.
The point found is an artificial point halfway between the two data points defining the maximum slope.
The default [(posneg)] is Positive.
PEak
Finds the nearest peak. At least [#consecutive_points#] points on each side of the peak must have Y values less than the peak Y value.
TRough
Finds nearest negative peak. At least [#consecutive_points#] points on each side of the trough must have Y values greater than the trough Y value.
MAx
Finds the greatest Y value for all points in the specified X range. If more than one maximum exists (same Y values), then the nearest one is found.
MAx is not affected by [direction], [#consecutive_points#], or [repeat:].
MIn
Finds the minimum Y value for all points in the specified X range.
MIn is not affected by [direction], [#consecutive_points#], or [repeat:].
POint
Finds the next data point in the given direction.
XValue(value)
Finds the first point on the curve that has the specified X axis value.
The (value) is a floating-point value or percent of full range.
XValue is not affected by [direction], [#consecutive_points#], [(range_x [,range_y])], or [repeat:].
(value) can take any of the following forms:
Value form | Example |
---|---|
a floating number |
1e5 100n 1 |
a percentage of full range |
50% |
a marked point or an expression of marked points |
x1 y1 (x1+x2)/2 |
a value relative to startvalue |
.-3 ⇒ startvalue -3 .+3 ⇒ startvalue +3 |
a db value relative to startvalue |
.-3db ⇒ 3db below startvalue .+3db ⇒ 3db above startvalue |
a value relative to max or min |
max-3 ⇒ maxrng -3 min+3 ⇒ minrng +3 |
Syntax example
The measurement definition is made up of:
- A measurement name
- A marked point expression
- One or more search commands enclosed within curly braces
This example also includes comments about:
- The measurement definition
- What arguments it expects when used
- A sample command line for its usage
Any line beginning with an asterisk is considered a comment line.
Risetime definition |
---|
Risetime(1) = x2-x1 * *#Desc#* Find the difference between the X values where the trace first *#Desc#* crosses 10% and then 90% of its maximum value with a positive *#Desc#* slope. *#Desc#* (i.e. Find the risetime of a step response curve with no *#Desc#* overshoot. If the signal has overshoot, use GenRise().) * *#Arg1#* Name of trace to search * * Usage: *Risetime(<trace name>) * { 1|Search forward level(10%, p) !1 Search forward level(90%, p) !2; } |
The name of the measurement is Risetime. Risetime will take 1 argument, a trace name (as seen from the comments).
The first search function searches forward (positive x direction) for the point on the trace where the waveform crosses the 10% point in a positive direction. That point’s X and Y coordinates will be marked and saved as point 1.
The second search function searches forward in the positive direction for the point on the trace where the waveform crosses the 90% mark. That point’s X and Y coordinates will be marked and saved as point 2.
The marked point expression is x2-x1. This means the measurement calculates the X value of point 2 minus the X value of point 1 and returns that number.
- Depending on the license available, you will access either PSpice A/D or PSpice Simulator.
- In this guide, design entry tool is used for both OrCAD X Capture and Design Entry HDL. Any differences between the two tools is mentioned, if necessary.
View the next document: 19 - Output and Export Options
If you have any questions or comments about the OrCAD X platform, click on the link below.
Contact Us