Calculate waveform data minimum, maximum, or average amplitude in the specified array range.
GxFpgaWaveformCalculateAmplitude (nAnalysisType, padData, dwSize, pdwStartIndex, dwEndIndex, pdResult, pnStatus)
Name |
Type |
Comments |
nAnalysisType |
SHORT |
Analysis Type:0. GXFPGA_WAVEFORM_CALCULATE_MIN_AMPLITUDE: calculate waveform minimum amplitude in the specified array range.1. GXFPGA_WAVEFORM_CALCULATE_MAX_AMPLITUDE: calculate waveform maximum amplitude in the specified array range2. GXFPGA_WAVEFORM_CALCULATE_AVERAGE_AMPLITUDE: Calculate waveform average amplitude in the specified array range. |
padData |
PDOUBLE |
Array of double precision waveform data. |
dwSize |
DWORD |
Array of double precision waveform data size. |
pdwStartIndex |
PDWORD |
Waveform data first index to search for amplitude, returns the index where min/max/average was found. |
dwEndIndex |
DWORD |
Waveform data last index to search for amplitude. |
pdResult |
PDOUBLE |
Returns the min/max/average value in the specified array range. |
pnStatus |
PSHORT |
Returned status: 0 on success, negative number on failure. |
General purpose function that calculates waveform data minimum, maximum, or average amplitude in the specified array range.
The function returns the requested amplitude and the array index where it was found.
The following example returns waveform’s first min and max amplitude found in the specified array start and end indexes:
SHORT nStatus;
DOUBLE adData[100];
DWORD dwArraySize, dwWaveformSize;
DWORD dw;
DWORD dwStartIndex, dwEndIndex;
DOUBLE dSampleRate, dMaxNoiseTime;
DOUBLE dResult;
// Waveform Sample Rate =10KHz
dSampleRate = 10E3;
// maximum time in seconds that is considered as a noise (or a spike) that need to be ignored by the measurement.
dMaxNoiseTime = 1e-4;
// Create half a sine waveform starting at index 2, 64 long
dwArraySize = 70;
dwWaveformSize = 64;
for (dw=0; dw<dwWaveformSize; dw++)
adData[dw+2] = 2*sin(dw*M_PI/dwWaveformSize);
// Find Waveform min amplitude
dwStartIndex = 0;
dwEndIndex = dwArraySize-1;
GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_MIN_AMPLITUDE, adData, dwArraySize, &dwStartIndex, dwEndIndex, &dResult, &nStatus);
printf("Min Amplitude=%f", dResult);
// Find Waveform max amplitude
dwStartIndex = 0;
dwEndIndex = dwArraySize-1;
GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_MAX_AMPLITUDE, adData, dwArraySize, &dwStartIndex, dwEndIndex, &dResult, &nStatus);
printf("Max Amplitude=%f", dResult);
// Find Waveform average amplitude
dwStartIndex = 0;
dwEndIndex = dwArraySize-1;
GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_AVERAGE_AMPLITUDE, adData, dwArraySize, &dwStartIndex, dwEndIndex, &dResult, &nStatus);
printf("Average Amplitude=%f", dResult);