GxFpgaWaveformCalculateTiming

Purpose

Calculate the waveform pulse rise, fall, and width time in seconds between the specified start amplitude to the specified end amplitude and specified array start and end index.

Syntax

GxFpgaWaveformCalculateTiming (nMeasurement, padData, dwSize, dStartAmplitude, dEndAplitude, dSampleRate, dMaxNoiseTime, pdwStartIndex, pdwEndIndex, pdResult, pnStatus)

Parameters

Name
Type
Comments
nMeasurement
SHORT
Measurement can be as followed:
0.      GXFPGA_WAVEFORM_CALCULATE_PULSE_RISE_TIME:  Calculate Pulse rise time: the time in seconds for the pulse to rise from the user’s specified start amplitude to the user’s specified end amplitude.
1.      GXFPGA_WAVEFORM_CALCULATE_PULSE_FALL_TIME: Calculate Pulse fall time: the time in seconds for the pulse to fall from the user’s specified start amplitude to the user’s specified end amplitude.
2.    GXFPGA_WAVEFORM_CALCULATE_PULSE_WIDTH_TIME: Calculate Pulse width time: the time in seconds between the user specified start amplitude to the user’s specified end amplitude.
padData
PDOUBLE
Array of double precision waveform data.
dwSize
DWORD
Array of double precision waveform data size.
dStartAmplitude
DOUBLE
Start amplitude to signal start of measurement.
dEndAplitude
DOUBLE
End amplitude to signal end of measurement.
dSampleRate
DOUBLE
Waveform sample rate in Samples/Sec.
dMaxNoiseTime
DOUBLE
Maximum time in seconds that is considered as a noise (or a spike) that need to be ignored by the measurement.
pdwStartIndex
PDWORD
Waveform data first index to search for amplitude change returns the actual founded value index in the array.
pdwEndIndex
PDWORD
Waveform data last index to search for amplitude change, returns the actual founded value index in the array.
pdResult
PDOUBLE
Returns the specified measurement.
pnStatus
PSHORT
Returned status: 0 on success, negative number on failure.

Comments

The function calculates the waveform pulse rise, fall, and width time in seconds between the specified start amplitude to the specified end amplitude and specified array start and end index.

Example

The following example returns waveform’s first wave width in sec:

 

SHORT  nStatus;

DOUBLE adData[100];

DWORD  dwArraySize, dwWaveformSize;

DWORD  dw;

DWORD  dwStartIndex, dwEndIndex;

DOUBLE dSampleRate, dMaxSpikeTime;

DOUBLE dResult, dMaxAmplitude;

 

// 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 start - min amplitude

dwStartIndex = 0;

dwEndIndex = dwArraySize-1;

GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_MIN_AMPLITUDE, adData, dwArraySize, &dwStartIndex, &dwEndIndex, &dResult, &nStatus);

printf("Min Amplitude Index=%lu", dwStartIndex);

printf("Min Amplitude =%f", dResult);

dwStartIndex=dwEndIndex;

 

// Find Waveform max amplitude

dwStartIndex = dwEndIndex+1;

dwEndIndex = dwArraySize-1;

GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_MAX_AMPLITUDE, adData, dwArraySize, &dwStartIndex, &dwEndIndex, &dMaxAmplitude, &nStatus);

printf("Max Amplitude Index=%lu", dwStartIndex);

printf("Max Amplitude =%f", dMaxAmplitude);

 

// Find end of Waveform, next min amplitude

dwStartIndex = dwEndIndex+1;

dwEndIndex = dwArraySize-1;

GxFpgaWaveformCalculateAmplitude(GXFPGA_WAVEFORM_CALCULATE_MIN_AMPLITUDE, adData, dwArraySize, &dwStartIndex, &dwEndIndex, &dResult, &nStatus);

// Find Waveform Width

GxFpgaWaveformCalculateTiming(GXFPGA_WAVEFORM_CALCULATE_PULSE_WIDTH_TIME, adData, dwArraySize, dMaxAmplitude*0.5, dMaxAmplitude*0.5, dSampleRate, dMaxSpikeTime, &dwStartIndex, &dwEndIndex, &dResult, &nStatus);

printf("Waveform Width=%f Sec", dResult);

printf("Waveform array rising edge amplitude = %lu", dwStartIndex);printf("Waveform array falling edge amplitude = %lu", dwEndIndex);

 

See Also

GxFpgaWaveformCalculateAmplitude , GxFpgaGetErrorString