CycleRMSAverage
Advanced Analysis Library Only
AnalysisLibErrType CycleRMSAverage (double waveform[], ssize_t waveformSize, ssize_t cycleNumber, double highRefLevel, double midRefLevel, double lowRefLevel, int referenceUnits, int method, ssize_t histogramBins, double *cycleAverage, double *cycleRMS, double *startTime, double *endTime, double *lowRefValue, double *midRefValue, double *highRefValue);
Purpose
Returns the average and RMS levels of a waveform in one user-defined cycle.
The distance between the midRefLevel and the highRefLevel must equal the distance between the lowRefLevel and the midRefLevel. If the two distances are not equal, LabWindows/CVI adjusts either the highRefLevel or the lowRefLevel to match the smaller of the two distances. For example, if you specify a highRefLevel of 90%, a midRefLevel of 50%, and a lowRefLevel of 20%, LabWindows/CVI uses 80% instead of 90% for the highRefLevel.
Example Code
/* Generate a sine wave and find the average and RMS levels of the first cycle of the sine wave. */
ssize_t numElements = 512;
double amp = 1.0;
double freq = 5.0/numElements;
double phase=0.0;
double sine[numElements];
double highVal;
double midVal;
double lowVal;
double end;
double start;
double rms;
double cylAvg;
SineWave (numElements, amp, freq, &phase, sine);
CycleRMSAverage (sine, numElements, 1, 90.00, 50.00, 10.00, PERCENTAGE_LEVEL, STATE_LEVELS_AUTO_SELECT, 256, &cylAvg, &rms, &start, &end, &lowVal, &midVal, &highVal);
Parameters
Input | ||
Name | Type | Description |
waveform | double [] | The waveform to measure. |
waveformSize | ssize_t | The size of the waveform to measure, in number of elements. |
cycleNumber | ssize_t | The number of the cycle, or period, of the signal on which to perform the measurement. For example, if you want to analyze the first cycle of the signal, pass 1. |
highRefLevel | double | The high reference level of the waveform in percent or absolute units. After the signal crosses the midRefLevel level in the rising direction, it must cross the highRefLevel level before the next falling midRefLevel level crossing can be counted. |
midRefLevel | double | The middle reference level in percent or absolute units. The interval between consecutive rising midRefLevel level crossings defines one cycle, or period, of the waveform. At least one high/low reference level crossing must separate each midRefLevel level crossing. |
lowRefLevel | double | The low reference level of the waveform in percent or absolute units. After the signal crosses the midRefLevel level in the falling direction, it must cross the lowRefLevel level before the next rising midRefLevel level crossing can be counted. |
referenceUnits | int | Specifies whether LabWindows/CVI interprets highRefLevel, midRefLevel, and lowRefLevel as a percentage of the full range of the waveform or as absolute levels. Specify one of the following values:
|
method | int | The method of calculating the high and low state level of the waveform.
|
histogramBins | ssize_t | The number of bins in the Histogram method that LabWindows/CVI uses to determine the high and low state levels of the waveform. LabWindows/CVI ignores histogramBins if you select Peak method as method. |
Output | ||
Name | Type | Description |
cycleAverage | double | The mean level of one complete period of a periodic input waveform. The average is computed by the following equation.![]() where i indicates the waveform samples that fall in the single period specified by cycleNumber and numPoints is given by the following equation. numPoints = int(period/dt + .5) where dt is the time between two samples and int( ) is a function that returns the integer portion of a floating-point number. The cycle average of a perfect sine wave is zero, while the average level of the entire waveform can be nonzero due to partial periods at the boundaries of the waveform. |
cycleRMS | double | The root mean square value of one complete period of a periodic input waveform. The RMS value is computed by the following equation.![]() where i indicates the waveform samples that fall in the single period specified by cycleNumber and numPoints is given by the following equation. numPoints = int(period/dt + .5) where dt is the time between two points and int( ) is a function that returns the integer portion of a floating-point number. |
startTime | double | The time of the rising midRefLevel crossing that defines the start of the measurement interval. |
endTime | double | The time of the rising midRefLevel level crossing that defines the end of the measurement interval. |
lowRefValue | double | The returned lowRefLevel of the waveform in absolute units. |
midRefValue | double | The returned midRefLevel of the waveform in absolute units. |
highRefValue | double | The returned highRefLevel of the waveform in absolute units. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 8.5 and later