help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do YOU handle this disparity in fft?


From: Macy
Subject: How do YOU handle this disparity in fft?
Date: Mon, 10 Feb 2014 19:07:49 -0800

I'm using fft and want to model everything. To do that, everything needs to be 
consistent else all falls apart.

My 'difficulty' is making apples compare to apples. Let's assume a system that 
acquires data at the rate of 100kS/s, where we'll only use smaller chunks of 
that data, streaming in at ten times a second, 10000 samples each chunk.

These are always real waveforms so the spectrum will always be 'symmetrical' 
about the Nyquist rate of the fft, but there are two places in the fft cause me 
a problem, one at DC and the other at the Nyquist rate [EVEN sample packets].

What I mean is if I adjust everything to make the 'tones' rms, and then appear 
correct in the fft, while only using the lower half the spectrum; the DC value 
is wrong. And the value at exatly the Nyquist rate, samplepacketlength/2, is 
wrong:

Do the exercise for yourself and see:

Assume 100kS/s ADC with packet lengths of 10000. 

To make a 1 Vrms 100Hz tone starting at t=0 is:
Sr=100000; p=10000;
t=([1:p]-1)/Sr;
f=100;
sig=sqrt(2)*cos(2*pi()*f*t);
%real wave so need only lower half of solution:
b=sqrt(2)*fft(sig)/p;
% note the resolution is 10Hz per index, so index of 100 is 10 + 1
b(11)

the answer you get is 1, which is indeed the rms value of the 100Hz tone
you will ALWAYS get that answer no matter what the frequency of the tone is. 

But now try that with a DC value of 1 and the answer for b(0) becomes 1.414, 
not right! and if you happen to have any tones at the Nyquist rate of 5kHz, 
then at 5001, that 1 Vrms 'looks' like 2

So far I have ignored the Nyquist rate because I've just assumed some amount of 
low pass filtering. And the DC has been no problem, because the DC has been 
zero, everything is either AC coupled.

Now how to add Noise Density Function. Which has NO low pass filtering?  
If I use the NDF*sqrt(Sr/2); all turns out copacetic in appearance.
note that the average of randn(1,p) is very close to zero and the rms value is 
1 
arbitrarily use density function of 1uV/rtHz 

sn=sig+1e-6*sqrt(Sr/2)*randn(1,p);
bn=sqrt(2)*fft(sn)/p;
% if you do a true rms value on resulting bn noise floor, you get the expected 
1uVrms*sqrt(10)
bnlog=20*log10(abs(bn(1:round(p/2))));
plot(bnlog)
% or add the true frequency ordinate, remember the first is DC and is zero freq
ford=([1:round(p/2)]-1)*Sr/p;
plot(ford,bnlog);

The first thing that caught my eye is that even though the total signal plus 
noise has an average of zero there is 'energy' at DC?  Am I missing something 
here? 

for example, just take a very long random signal, randn(1,1e6), which has an 
average of zero, no DC then take the energy preserving fft:
n=sqrt(2)*fft(randn(1,1e6))/1e6;abs(n(1:5))
the magnitude of n representing the DC value is NOT zero as expected but rather 
almost equal to the adjacent value(s) ??

The next thing is *if* thesignal is DC of 1 Vdc, the fft predicts that it is 
only .707, not 1 Vrms as expected. 

and the last thing is if the signal f is allowed to go to 5kHz it suddenly 
looks like 2 Vrms, again wrong.

However if the tone is anywhere between 10Hz and 4990Hz, the value appears 
EXACTLY equal to 1 Vrms as expected, but oddly there is NO 'bump' in the middle 
from the noise through 5kHz.  plot spectrum is flat through the 5kHz and at DC 

So far I've been ignoring all this, but have NO  'automatic' way to get around 
it. 
I can kind of understand how noise density can fill in a non-existant DC level, 
the the rest has me wondering.

[This was a bit long and may have some errors as I presented the question, so 
hoepfull you can see through those errors and understand my question.]

For the DC level I should not multiply by 1/sqrt(2), or should I? 

For an errant tone that has not been LPF'd out, how to handle that 'bump' in 
the spectrum at p/2+1 ??























reply via email to

[Prev in Thread] Current Thread [Next in Thread]