# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Extract Single Tone Information - How the equation works?

Hi,

is there a detailed or step-by-step explanation on how the equation used by Extract Single Tone works?

The equation is this:

I want to know/understand how the frequency, amplitude, and phase are being calculated. Also what is x(n)?

Thank you.

Message 1 of 4
(3,712 Views)
Solution
Accepted by JersonJose

## Re: Extract Single Tone Information - How the equation works?

In that equation x(n) represents the series of samples of the sinusoidal input signal. Samples are taken at time intervals spaced 1/Fs seconds apart. So, n/Fs refers the the nth sample in the series.

Internally the VI takes an FFT of the time domain signal. It then uses an interpolation process to find the frequency, amplitude, and phase of the input signal. Intermpolation is used because the highest peak of the FFT output may not be exactly on the signal frequency.  This is caused by the signal frequency and the sampling frequency in general not being exactly harmonically related.  I think It fits a second order polynomial (quadratic) to the FFT output peak and determines the outputs from the values of the polynomial.

Lynn

Message 2 of 4
(3,694 Views)

## Re: Extract Single Tone Information - How the equation works?

The nice thing about this function is the fact that it is a plain subVI, so you can just double-click it and dig into the LabVIEW code itself. 😄

(A lot of the inner code seems quite ancient, with liberal use of stacked sequences and sequence locals, but there are plenty of diagram comments. Just follow the wires!)

Message 3 of 4
(3,680 Views)

## Re: Extract Single Tone Information - How the equation works?

Fourier (the French mathematician) showed that any periodic function of N points could be expressed as a sum of sines and cosines whose frequencies were integral multiples of the frequency of the periodic signal.  That is, if you have an arbitrary signal that repeats, say, every second, you can approximate it to however close you wish using a suitable sum of the form a(n) cos (2pi n) + b(n) sin (2pi n) (I chose the period of 1 second to simplify the math, so the frequencies will be 0 Hz = DC, 1 Hz, 2 Hz, ...).

If you have a finite number, N of equally sampled points in your (periodic) waveform, then your best approximation will have N/2 sines and cosines.  Instead of writing the sum as a(n) cos (f(n)) + b(n) sin (f(n)), where f(n) is the frequency, you could also write it g(n) cos (f(n) + p(n)), where g(n) is the "gain" of the component and p(n) is the "phase".

It is possible to compute a Fourier Transform of N data points by multiplying the waveform (of N points) by N/2 sines and cosines of frequencies f(n) (the "harmonics" of the fundamental, given by the period of the waveform), but this is slow going, taking about N-squared operations.  However, if N can be factored, and especially if N is a power of 2, there is a Fast method of taking the Fourier Transform (called, appropriately, the Fast Fourier Transform, or FFT for those "in the know") that takes N lg N (lg N = log base 2 of N) steps, much faster.