Admin Production ni-theme
Current Publication

SingleToneSignal

LabWindows/CVI

SingleToneSignal

Advanced Analysis Library Only

AnalysisLibErrType SingleToneSignal (double waveform[], ssize_t waveformSize, double samplePeriodInSeconds, SearchType *search, int exportMode, double *frequency, double *amplitude, double *phase, double exportedSignal[], double *exportedSamplePeriod, double exportedSpectrum[], double *startFrequency, double *frequencyResolution);

Purpose

Takes a signal, finds the single tone with the highest amplitude or searches a specified frequency range, and returns the single tone frequency, amplitude, and phase. This function also exports signal and spectrum information specified by exportMode.

If you do not need to export signal and spectrum information, you can use SingleToneInfo instead.

A real tone signal can be expressed as shown in the following equation:

where A, f, and are the amplitude, frequency, and phase of the tone signal, respectively, and Fs is the sample rate in samples per second of the input waveform signal.

For a real signal, the frequency range is (min frequency, max frequency) = (0, Fs/2).

Parameters

Input
Name Type Description
waveform double [] The input waveform to measure.
waveformSize ssize_t The size of the input waveform. This value must be greater than 2.
samplePeriodInSeconds double Sample period of the time-domain signal, in seconds. This value must be greater than 0.
search SearchType * Controls the frequency domain search area, center frequency, and width. Use this parameter to narrow the single tone search range. The SearchType structure is defined as follows:

typedef struct {
   double centerFrequency;
   double frequencyWidth;
} SearchType;


search->centerFrequency is the center frequency used for the frequency domain search of the single tone. This value is in the range of (0, Fs/2), where Fs is the sampling rate, and Fs = 1.0/dt.

search->frequencyWidth is the frequency width, as a percentage of the sampling rate.

If you pass NULL for search or search->centerFrequency is invalid, this function searches the tone in the full frequency range of (0, Fs/2).
exportMode int Selects the source of the exportedSignal and exportedSpectrum to export. You can select one of the following values:

  • TONE_EXPORT_NONE—Does not export any values.
  • TONE_EXPORT_INPUT—Exports the input signal.
  • TONE_EXPORT_DETECTED—Exports the detected single tone signal.
  • TONE_EXPORT_RESIDUAL—Exports the residual signal; residual signal is the input signal minus the detected single tone signal.
Output
Name Type Description
frequency double The frequency of the detected single tone, in hertz. If an error occurs, frequency is set to 0.0.
amplitude double The amplitude of the detected single tone. If an error occurs, amplitude is set to 0.0.
phase double The phase of the detected single tone in degrees. If an error occurs, phase is set to 0.0.
exportedSignal double [] The waveform containing the exported time signal as selected by exportMode. If an error occurs, each element in exportedSignal is set to 0. You must allocate enough memory for exportedSignal.
exportedSamplePeriod double Sample period of the time-domain signal, in seconds. If an error occurs, this value is set to 0.0.
exportedSpectrum double [] The magnitude spectrum of the Hanning windowed input signal, in dB. If an error occurs, each element in exportedSpectrum is set to 0. You must allocate enough memory for exportedSpectrum.
startFrequency double The start frequency, in hertz, of the exportedSpectrum. If an error occurs, this value is set to 0.0.
frequencyResolution double The frequency resolution, in hertz, of the exportedSpectrum. If an error occurs, this value is set to 0.0.

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 2010 and later