40 Uses for Math Traces
There are two sides to the math traces feature:
- Math Function Syntax: define a new graph trace derived from standard traces using a math function (15 uses)
- Defining Calculators: define a calculation which is computed repeatedly throughout the test, and the results plotted vs. test time. (25 uses)
1. Math function syntax
Equations are written in standard form, and standard math associativity properties apply. For example (5+3)*2 = 2*(5+3) = 16, but 5+3*2 = 11 and 2*5+3 = 13.
A full suite of standard functions is available, including “sin”, “cos”, “tan”, “exp”, “ln”, “sqrt”, and many more. Refer to the appendix for a full list of the available functions, or check in the online help file.
You can use report fields as variables in the calculation by enclosing the desired field name in square brackets, for example “[Ch1Accel]” will give the channel 1 acceleration reading. These report fields are implemented as variables, so you can use one anywhere in the equation where you would otherwise put in a numerical value. The square brackets imply you are inserting a “PARAM” report field, so you don’t need to spell out [PARAM:Ch1Accel], although you may if you wish. For a full list of available fields, refer to the “How to create customized reports” section in the online help file or the manual.
Defining new traces using math functions
To add a math trace to a graph, right-click on the graph, and select “Add math trace”. A dialog will pop up asking for a trace annotation label and the equation to use. Math traces work on almost any plot, and use that plot type to determine the source data. For example, on a spectrum plot the source data will be the channel spectra, while on the channel waveforms plot the source data will be the raw waveform traces.
Math traces using time waveforms
1. Difference waveform
(Ch2 – Ch1)
2. Mark min and max peaks with horizontal lines
Min(control)
Max(control)
Add math traces “min(Ch1)” and “max(Ch1)” and set the line color appropriately, and set the line type to a dotted line. This will add dotted horizontal lines on the plot indicating the level of the min and max values.
3. Displacement time waveforms
disp(Ch1)
For time waveforms, this will convert the channel 1 acceleration waveform to a displacement waveform, with appropriate unit conversions and trendline removal.
4. Velocity time waveforms
vel(Ch1)
For time waveforms, this will convert the channel 1 acceleration waveform to a velocity waveform, with appropriate unit conversions and trendline removal.
5. Jerk time waveforms
diff(Ch1)
For time waveforms, this will differentiate the channel 1 acceleration waveform, which gives the rate of change in acceleration, also called “jerk.” The units will be the currently selected acceleration units/second.
6. Differential displacement measurements
disp(Ch2 – Ch1)
DoubleInteg(Ch2 – Ch1)*AtoD
For time waveforms, particularly for user-defined transients such as earthquake simulation, these functions will both compute the relative displacement waveform between channels 1 and 2. The “AtoD” factor converts the acceleration units to displacement units using the configured system unit selection.
The “disp” function will remove trendlines due to accelerometer biasto get a 0-mean displacement waveform. The “DoubleInteg” calculation assumes initial velocity and displacement values are zero. The latter may be more appropriate for transient events which are not necessarily zero-mean, but will be susceptible to wandering trendlines.
7. Plot the FDR error waveform
Control – Demand
In F.D.R. test mode this will plot the error signal between the Demand trace and the Control trace.
Math traces using frequency spectra
8. dB error plot in Sine
20*log10(Control/Demand) && (Demand > 0)
This will compute the dB difference between the Control and Demand traces in Sine mode. The logical “&&” operator will select out only the calculations where the demand trace is positive, and set the result to 0.0 where the demand is zero.
9. dB error plot in Random, Shock or FDR
10*log10(Control/Demand) && (Demand > 0)
This will compute the dB difference between the Control and Demand traces in Random, Shock, or FDR modes, where the vertical plot axis is a power value.
10. Weighted average spectrum
(4*Ch1 + 2*Ch2 + 5*Ch3 + Ch4) / 12
In Random and F.D.R. test modes, which have PSD plots, this will compute a weighted average PSD of the 4 channels.
11. Display the velocity spectrum
vel(Ch1)
When computed on a frequency spectrum, this will compute the velocity spectrum. You can then use the RMS cursor functions to measure the RMS velocity over any sub-band of the spectrum.
12. Display the displacement spectrum
disp(Ch1)
When computed on a frequency spectrum, this will compute the displacement spectrum. You can then use the RMS cursor functions to measure the RMS velocity over any sub-band of the spectrum.
Math traces using histograms (aka PDF)
13. Gaussian PDF overlay
exp( -0.5*(x/[Ch1])^2 ) / sqrt(2*pi*[Ch1]^2)
When applied to a probability density function plot (PDF, aka histogram or amplitude distribution), this will compute the exact Gaussian PDF trace given the RMS level of channel 1. This can be used to compare the actual probability distribution to a true Gaussian distribution.
14. Cumulative distribution
integ(Ch1)
When applied to a probability density function plot (PDF, aka histogram or amplitude distribution), the integration of the trace will compute and plot the cumulative distribution function instead of the probability density function. The cumulative distribution function is the fraction of samples less than the value, so this number will start at 0.0 and end to 1.0.
15. Percent of time above G level
200-100*integ(Ch1+flip(Ch1))
When applied to a probability density function plot, this will compute the percent of time the absolute value of the waveform is above a G level. You will want to set the Y axis to log scaling, and adjust the X axis to start at 0, because the half of the plot for negative G values will be a mirror image with 100% added to it. Note that the flip() function reverses the trace, so this adds the positive values to the negative values to the probability levels for positive values to get the probability values for the absolute value.
2. Defining Calculators
The other half of the math equations feature is a set of calculators that are computed repeatedly while the test runs. You can define up to 32 calculations on the “Calc” tab in the test settings.
The equations are entered the same as for the math traces, but the stored value is the final value of the vector (highest time sample, or highest frequency sample). To control the value stored by the calculator, you can use the min(), max(), mean(), rms(), sum(), integ(), head(), or tail() functions to pick out some specific value. Each calculator has a selection for the source data: waveform, spectrum, or PDF. The calculation results can then be plotted vs. test time as the test runs using the “Calculator” plot type. You must pre-define these functions prior to running the test since the calculation results are computed and logged as the test runs. You can add calculations as the test runs, but any calculations defined in the middle of a test will only plot calculation results after the time you define it.
In addition to plotting the values, min and max limits may be defined for each calculator. When the calculation lies outside of the defined limits the test will abort. This allows for a wide variety of user-defined limits to be defined. The “High” limit applies always, while the “Low” limit does not apply while the test is ramping up, only while the test is running at level.
Calculations from time waveforms
16. Compute and log the crest factor vs. time
max(Ch1)/RMS(Ch1)
17. Compute and log the peak displacement vs. time
max(abs(disp(Ch1)))
For a waveform source, this will compute the displacement waveform for channel 1, and then return the maximum absolute value of that waveform. Note that integration from acceleration to displacement amplifies low-frequency noise, so these calculations will be susceptible to noise. Also, this calculation will fail for low-frequency sine tests, where the waveform snapshot does not provide enough of the sine wave to properly integrate.
18. Compute and log the peak jerk vs. time
max(abs(diff(Ch1)))
For a waveform source, this will compute the jerk waveform for channel 1, and then return the maximum absolute value of that waveform. The differential of acceleration is the rate of change in acceleration, also called “jerk.” The units will be the currently selected acceleration units/second.
19. RMS error
RMS(Demand – Control)
Computed from the waveform traces in Field Data Replicator test mode, this will compute the RMS value of the error signal between Demand and Control. Note that the RMS calculation here will include all frequencies, so this calculation will include frequencies outside of the configured Min and Max Frequency settings.
20. RMS readings
RMS(Ch1)
For waveform source, gives a short-duration RMS reading. For a spectrum source, gives a long- duration RMS reading calculated from the averaged spectrum.
Calculations from frequency spectra
21. Compute the dB spread of control spectrum
10*log10(max(Control)/min(Control+(1e10*(Demand==0))))
This computes the dB spread of the in-band control spectrum. The 1e10*(Demand==0) effectively removes the out-of-band (zero demand) frequencies from the calculation. If this factor is omitted, then the calculation will be performed over the full band, including the out-of- band noise floor. Note that random spectra are plotted as power values, so to convert to dB you use the calculation 10*log10(ratio).
22. Compute the maximum dB deviation from the demand spectrum
max( abs( 10*log10( Control / Demand ) ) )
This computes the maximum error, in dB, between the demand spectrum and control spectrum. Of special note here is the max() operator will ignore the infinite values where Demand = 0.
Recall that the DOF, or averaging, setting determines how smooth the spectrum is. For example, for DOF=120, we would expect 99% of the frequency bins will be closer than 1.6dB. With 800 control lines, this means that at any given time 8 of the control lines would be expected to be greater than 1.6dB. If you don’t get this amount of variation, then your waveform is not truly random. Since the waveform is random, it won’t always be the same 8 lines – they should randomly jump around throughout the spectrum.
23. Compute the number of outlier lines
sum( abs( 10*log10( Control / (Demand + Control*(Demand==0)) ) ) > 1.0 ) This counts the number of spectrum lines more than 1.0 dB from the Demand trace. The 1.0 value can be changed to the desired dB level to compare.
24. Compute the average spectrum error, in dB
mean( abs( 10*log10( Control / Demand ) ) )
This computes the average error, in dB, between the demand spectrum and control spectrum. Of special note here is the mean() operator will ignore the infinite values where Demand = 0. The average error will be a more statistically stable calculation than the peak error, and for Gaussian data will directly depend on the DOF value used for averaging.
25. Estimate the DOF from a random spectrum
2*sum(Demand>0) / sum( ((Control-Demand)/Demand)^2 )
The ‘hashy-ness’ of the random spectrum for true Gaussian data is directly related to the DOF value used for averaging, because the spectrum will also be random, with a chi-squared probability distribution with ‘DOF’ degrees-of-freedom. This relationship can be used to estimate the DOF from the variance of the normalized error between the Control and Demand spectra. Of special note here is the sum() operator will ignore any non-finite values, so this calculation will effectively ignore the graph points where Demand = 0 because they result in a (divide-by-0) infinite result.
26. Narrow-band RMS readings
RMS(Ch1*(freq>400)*(freq<500))
This computes the narrow-band RMS of channel 1, computed between 400Hz and 500Hz. Note that multiplication of logical (1=TRUE, 0=FALSE) values is a logical AND operation. Alternatively, you can use the logical “&&” operator to achieve the same effect.
27. Harmonic levels
RMS(Ch1 * (Freq>(3*[Frequency] – 2.1*df)* (Freq<(3*[Frequency] + 2.1*df) )
For sine tests with spectrum source data, this will compute the RMS value of the 3rd harmonic The +/- 2.1*df factor is used because the FFT spectrum is computed at discrete frequencies, so the harmonic will rarely exactly match the FFT spectrum frequency. FFT processing uses windowing which has the effect of distributing the energy among the bins closest to the actual frequency. The RMS value of the 3rd harmonic can be recovered by computing the RMS over the frequency range of +/- 2 FFT bins.
28. Harmonic+noise content
RMS( Ch1 * Freq>(1.5*[Frequency]) )
For sine tests with spectrum source data, this will compute the RMS value of the signal components above 1.5 times the current frequency. This will be the sum of both harmonic content and the noise floor.
29. THD+N measure
RMS( Ch1 * Freq>(1.5*[Frequency]) ) * sqrt(2) / [Ch1] * 100.0
For sine tests with spectrum source data, this will compute the RMS value of the harmonic distortion+noise, and divide by the RMS value of the input channel. The multiplication by sqrt(2) is necessary to convert the channel 1 peak value, [Ch1], to an RMS value. The multiplication by 100.0 converts the result to a percentage.
30. Compute Weighted RMS values
RMS(AWeight(Ch1)) RMS(BWeight(Ch1)) RMS(CWeight(Ch1))
For sine tests with a spectrum source, this computes the A-, B-, or C-Weighted RMS value of channel 1. This is most commonly used with squeak-and-rattle tests for audio readings using a microphone input. You may also use this calculation from random PSD plots, however the averaging in random test mode is usually too high to be able to see any variation in level over time.
31. Compute audio dBA levels from a microphone
dBA(Ch1)
20*log10(RMS(AWeight(Ch1))/20e-6)
For sine tests with a spectrum source, this computes the A-Weighted dB value of channel 1, relative to 20uPa. This is most commonly used with squeak-and-rattle tests for audio readings using a microphone calibrated in Pascals. Note that the two equations are equivalent.
Calculations from histograms (aka PDF)
32. 99th percentile peak acceleration
max( ((2-integ(Ch1+flip(Ch1))) > 0.01) * x)
Computed from the histogram data source in Random test mode, this will return acceleration level which 99% of all acceleration readings are below. For true Gaussian random waveforms, this number should equal 2.6 times the RMS value. The ratio of the 99th percentile value to the RMS is a statistically stable method of computing the crest factor. The percentile can be changed by changing the 0.01 comparison value. For example, using 0.0027 will give 99.73th percentile which corresponds to 3.0 times the RMS value (i.e. the 3-sigma level).
33. Compute and log the maximum value seen prior to current time
max(abs((Ch1>0)*x))
Computed from the histogram data source in Random or FDR test modes, this will return the highest x-axis (“x” variable) value for which there was at least 1 sample measured. Since the histogram accumulates the data over time, this will give the highest value seen up to the current time in the test.
Other calculations
34. Plot any data parameter vs. time
[InsertParameterHere]
Since the report parameters can be inserted using the [ ] operator, if the equation simply gives a single report parameter, then that parameter will be plotted over the duration of the test.
35. Plot percent error vs. time
100*([Control]-[Demand])/[Demand]
This will compute the percent error based on the current Demand and Control readings, and plot that value over the duration of the test.
36. Complex aborts
(RMS(Ch1)>5) * (RMS(Ch2)>5)
+ Abort above 0.5
This will abort the test if both channels 1 and 2 have RMS above 5 at the same time. The logical operators return 0 if False, and 1 if True, so an abort threshold of 0.5 will abort when the comparison is True.
37. Specialized aborts
Max(Ch1) > 10*[Demand]
+ Abort above 0.5
This will abort the test if the peak levels on channel 1 exceed 10 times the demand RMS (in Random or FDR)
38. Plot Aux Output state vs. Time
[Aux8Output]
This will display the time history for the state of auxiliary output 8
39. Plot Field Power or Armature Power vs. time
[Aux1Input]*[Aux2Input]
When the Aux 1 input is configured as field voltage, and the Aux 2 input is configured as field current, this will compute the field power. The same calculation can be made for armature power using the armature RMS voltage and current readings.
40. Separate the DC and AC components of a signal
Mean(Ch1) RMS(Ch1)
For waveform source, the Mean() function gives the current average value (DC component) of the input, and the RMS() function gives the short-duration RMS reading (AC component). Note: For this to work the input must be configured as a “DC Input” on the Input Configuration tab. Inputs that are not configured as “DC Input” have the DC component automatically filtered out by the controller.