DSPRelated.com
Forums

Newbie FFT normalization question

Started by Yofnik December 29, 2006
Hi All,
I am a software engineer, not a DSP guru. I have been using an open
source FFT algorithm for a project I am working on. As I have seen in a
number of examples, in order to get the results I expect, I need to
"normalize" the FFT results by dividing each value by N/2 (number of
samples / 2).

Can someone please give a little background as to why this is
necessary? I am not satisfied with just getting the expected results.
I'd like to have a better understanding of how they are derived.

Many thanks.

Yofnik

Yofnik skrev:
> Hi All, > I am a software engineer, not a DSP guru. I have been using an open > source FFT algorithm for a project I am working on. As I have seen in a > number of examples, in order to get the results I expect, I need to > "normalize" the FFT results by dividing each value by N/2 (number of > samples / 2).
What do you expect? I assume you have an N length sinusoidal of the form x[n] = A sin(wn) and find a spectrum coefficient of magnitude A*N/2 (provided the frquency w is an integer fraction of the sampling frequency w = m/N, m < N/2). First the factor 1/2. The spectrum of a real-valued signal is conjugate symmetric, meaning one real-valed sinusoidal is represented as two complex-valued sinusoidals according to Eulers formula, A*sin(x) = A*(exp(jx)-exp(-jx))/j2. These two complex-valued sinusoidals have magnitde A/2, so if you plot only the range [0,fs/2] you need to scale by a factor 2 to recover A. Second, the factor N. The DFT is a set of vector products between the input signal x and N complex elements of unit magnitude: X[k] = sum_n=0^N-1 A*exp(j*2*pi*k*n/N)*exp(-j*2*pi*k*n/N) = N*A To recover A, one needs to divide by N. Rune
Thanks Rune! This is exactly what I was looking for.


Rune Allnor wrote:
> Yofnik skrev: > > Hi All, > > I am a software engineer, not a DSP guru. I have been using an open > > source FFT algorithm for a project I am working on. As I have seen in a > > number of examples, in order to get the results I expect, I need to > > "normalize" the FFT results by dividing each value by N/2 (number of > > samples / 2). > > What do you expect? I assume you have an N length sinusoidal of > the form > > x[n] = A sin(wn) > > and find a spectrum coefficient of magnitude A*N/2 (provided > the frquency w is an integer fraction of the sampling frequency > w = m/N, m < N/2). > > First the factor 1/2. The spectrum of a real-valued signal is > conjugate symmetric, meaning one real-valed sinusoidal is > represented as two complex-valued sinusoidals according > to Eulers formula, > > A*sin(x) = A*(exp(jx)-exp(-jx))/j2. > > These two complex-valued sinusoidals have magnitde > A/2, so if you plot only the range [0,fs/2] you need to > scale by a factor 2 to recover A. > > Second, the factor N. The DFT is a set of vector products > between the input signal x and N complex elements of > unit magnitude: > > X[k] = sum_n=0^N-1 A*exp(j*2*pi*k*n/N)*exp(-j*2*pi*k*n/N) > = N*A > > To recover A, one needs to divide by N. > > Rune
Hi Rune,
I have another quick FFT newbie question. You did describe my scenario
accurately. The inputs to the FFT function are a set of voltage
readings sampled from a device. The customer wants the FFT output to be
in Volts RMS. How is that calculated?

Thanks again,

Yofnik

Rune Allnor wrote:
> Yofnik skrev: > > Hi All, > > I am a software engineer, not a DSP guru. I have been using an open > > source FFT algorithm for a project I am working on. As I have seen in a > > number of examples, in order to get the results I expect, I need to > > "normalize" the FFT results by dividing each value by N/2 (number of > > samples / 2). > > What do you expect? I assume you have an N length sinusoidal of > the form > > x[n] = A sin(wn) > > and find a spectrum coefficient of magnitude A*N/2 (provided > the frquency w is an integer fraction of the sampling frequency > w = m/N, m < N/2). > > First the factor 1/2. The spectrum of a real-valued signal is > conjugate symmetric, meaning one real-valed sinusoidal is > represented as two complex-valued sinusoidals according > to Eulers formula, > > A*sin(x) = A*(exp(jx)-exp(-jx))/j2. > > These two complex-valued sinusoidals have magnitde > A/2, so if you plot only the range [0,fs/2] you need to > scale by a factor 2 to recover A. > > Second, the factor N. The DFT is a set of vector products > between the input signal x and N complex elements of > unit magnitude: > > X[k] = sum_n=0^N-1 A*exp(j*2*pi*k*n/N)*exp(-j*2*pi*k*n/N) > = N*A > > To recover A, one needs to divide by N. > > Rune
>The inputs to the FFT function are a set of voltage >readings sampled from a device. The customer wants the FFT output to be >in Volts RMS. How is that calculated?
Your signal would have passed through several stages of processing, both analogue and digital, each with its own transfer characteristics. You have two choices - dead-reckoning, or calibration. If you choose dead-reckoning, you will still have to calibrate to prove your result. Jeff
I am assuming the hardware guys are handling the calibration. They want
to see Volts RMS. Is there anything else I need to calcualte?


Jeff Caunter wrote:
> >The inputs to the FFT function are a set of voltage > >readings sampled from a device. The customer wants the FFT output to be > >in Volts RMS. How is that calculated? > > Your signal would have passed through several stages of processing, both > analogue and digital, each with its own transfer characteristics. You have > two choices - dead-reckoning, or calibration. If you choose dead-reckoning, > you will still have to calibrate to prove your result. > > Jeff
On 16 Jan 2007 22:07:58 -0800, "Yofnik" <yofnik@comcast.net> wrote:

>I am assuming the hardware guys are handling the calibration. They want >to see Volts RMS. Is there anything else I need to calcualte? > > >Jeff Caunter wrote: >> >The inputs to the FFT function are a set of voltage >> >readings sampled from a device. The customer wants the FFT output to be >> >in Volts RMS. How is that calculated? >> >> Your signal would have passed through several stages of processing, both >> analogue and digital, each with its own transfer characteristics. You have >> two choices - dead-reckoning, or calibration. If you choose dead-reckoning, >> you will still have to calibrate to prove your result. >> >> Jeff
Hi, yes there is. Let's assume: * you're using a standard radix-2 FFT. * your FFT input samples are real-only. * FFT size is N = 1024. * a single FFT-input sinewave has a peak amplitude value of A1 = 20. * the sinewave's frequency (as Rune said) is an integer multiple of Fs/N (where Fs is the data sample rate in Hz). OK, the FFT magnitude for that sinewave will be M1 = A1*N/2 = 10240. If the sinewave's peak amplitude were A2 = 40, then the FFT magnitude for that new sinewave will be M2 = A2*N/2 = 20480. So you can see that a sinewave's peak value A (given the above assumptions) can be determined based on the N-point FFT's magnitude value M using: A = 2*M/N So now you have to go to the hardware guys and ask them, "What is the rms voltage of an analog sinewave that will show up at my FFT's input having a peak amplitude of 20?" If they tell you that a 0.7 volt-rms sinewave will show up at your FFT's input having a peak value of 20, then you know an FFT magnitude of M = 10240 represents a 0.7 volt-rms sinewave. Likewise, a 1.4 (2*0.7) volt-rms analog sinewave should yield an FFT magnitude of M = 20480. So there you have it. An analog sinewave's rms voltage will be: Voltage = (M*0.7)/10240 volts-rms OK Yofnik, now you "play it safe". Ask the hardware guys to carefully and precisely generate an analog sinewave whose voltage is 0.7 volts-rms. Now, make sure your FFT magnitude is M = 10240. Next have the hardware guys generate an analog sinewave whose voltage is 1.4 volts-rms and make sure your FFT magnitude is M = 20480. Do *NOT* fail to perform this "calibration" exercise. It will help you to sleep better at night. Good Luck, [-Rick-]
Thanks Rick. This helps a lot. Let me see if I understand this
correctly.

Right now, the software I am developing is displaying the FFT graph. I
am currently plotting the magnitude of each FFT point after I multiply
by 2*M/N (as Rune originally explained why).

So if I understand your reply correctly, I need to take the "known" RMS
value and calibrate my reponse accordingly as you described -
(M*0.7)/10240. (actual value to be determined).

The one thing I still want to understand is how they will be able to
answer the question you provided:
"What is the rms voltage of an analog sinewave that will show up at my
FFT's input having a peak amplitude of 20?"

How is this determined?

Thanks to all for your help.

Yofnik

Rick Lyons wrote:
> On 16 Jan 2007 22:07:58 -0800, "Yofnik" <yofnik@comcast.net> wrote: > > >I am assuming the hardware guys are handling the calibration. They want > >to see Volts RMS. Is there anything else I need to calcualte? > > > > > >Jeff Caunter wrote: > >> >The inputs to the FFT function are a set of voltage > >> >readings sampled from a device. The customer wants the FFT output to be > >> >in Volts RMS. How is that calculated? > >> > >> Your signal would have passed through several stages of processing, both > >> analogue and digital, each with its own transfer characteristics. You have > >> two choices - dead-reckoning, or calibration. If you choose dead-reckoning, > >> you will still have to calibrate to prove your result. > >> > >> Jeff > > Hi, > yes there is. Let's assume: > > * you're using a standard radix-2 FFT. > * your FFT input samples are real-only. > * FFT size is N = 1024. > * a single FFT-input sinewave has a peak > amplitude value of A1 = 20. > * the sinewave's frequency (as Rune said) > is an integer multiple of Fs/N (where > Fs is the data sample rate in Hz). > > OK, the FFT magnitude for that sinewave will > be M1 = A1*N/2 = 10240. If the sinewave's > peak amplitude were A2 = 40, then the > FFT magnitude for that new sinewave will > be M2 = A2*N/2 = 20480. > > So you can see that a sinewave's peak value > A (given the above assumptions) can be > determined based on the N-point FFT's magnitude > value M using: > > A = 2*M/N > > So now you have to go to the hardware guys > and ask them, "What is the rms voltage of an > analog sinewave that will show up at my FFT's > input having a peak amplitude of 20?" If they > tell you that a 0.7 volt-rms sinewave will show > up at your FFT's input having a peak value of 20, > then you know an FFT magnitude of M = 10240 > represents a 0.7 volt-rms sinewave. > > Likewise, a 1.4 (2*0.7) volt-rms analog sinewave > should yield an FFT magnitude of M = 20480. So there > you have it. An analog sinewave's rms voltage > will be: > > Voltage = (M*0.7)/10240 volts-rms > > OK Yofnik, now you "play it safe". Ask the > hardware guys to carefully and precisely generate > an analog sinewave whose voltage is 0.7 volts-rms. > Now, make sure your FFT magnitude is M = 10240. > Next have the hardware guys generate > an analog sinewave whose voltage is 1.4 volts-rms > and make sure your FFT magnitude is M = 20480. > Do *NOT* fail to perform this "calibration" exercise. > It will help you to sleep better at night. > > Good Luck, > [-Rick-]
On 17 Jan 2007 18:46:01 -0800, "Yofnik" <yofnik@comcast.net> wrote:

>Thanks Rick. This helps a lot. Let me see if I understand this >correctly. > >Right now, the software I am developing is displaying the FFT graph. I >am currently plotting the magnitude of each FFT point after I multiply >by 2*M/N (as Rune originally explained why). > >So if I understand your reply correctly, I need to take the "known" RMS >value and calibrate my reponse accordingly as you described - >(M*0.7)/10240. (actual value to be determined). > >The one thing I still want to understand is how they will be able to >answer the question you provided: >"What is the rms voltage of an analog sinewave that will show up at my >FFT's input having a peak amplitude of 20?" > >How is this determined? > >Thanks to all for your help.
Hi, You are welcome. OK Yofnik, the answer to your last question depends on: (1) any analog amplifiers/antenuators at the analog-input of your system, (2) the analog-to-digital converter's (A/D) input voltage range, (3) the number of bits output by the A/D, and (4) the binary number format output by the A/D. The hardware guys on your project will be able to, very quickly, explain the entire situation to you. Good Luck, [-Rick-]
Yofnik skrev:
> Thanks Rick. This helps a lot. Let me see if I understand this > correctly. > > Right now, the software I am developing is displaying the FFT graph. I > am currently plotting the magnitude of each FFT point after I multiply > by 2*M/N (as Rune originally explained why). > > So if I understand your reply correctly, I need to take the "known" RMS > value and calibrate my reponse accordingly as you described - > (M*0.7)/10240. (actual value to be determined).
Correct. First apply a known signal to the system and decide the scaling factor that makes the numbers come out correctly on the screen.
> The one thing I still want to understand is how they will be able to > answer the question you provided: > "What is the rms voltage of an analog sinewave that will show up at my > FFT's input having a peak amplitude of 20?" > > How is this determined?
By trial and error. Use the numbers that popped out of the first calibration run to estimate what voltage you will need to get that number (or another reasonable RMS voltage number) on the screen. Then set the signal source to that value and see if it works. Rune