[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FFT spectrum analyzer question
From: |
Macy |
Subject: |
Re: FFT spectrum analyzer question |
Date: |
Sun, 18 May 2014 09:18:47 -0700 |
just did some 'side by side' comparisons and could not explain the disparity.
The example shown in the pwelch() works fine and compares somewhat to what I
do, and have been doing, really gross disparity if there is a signal is present
?!
try this:
1Vpk 1MHz cosine wave sampled at 10MS/s with 10nVrms/rtHz noise of packet
length 100000.
>> N=100000; dt=0.1e-6;fc=1e6; vn=10e-9;
>> t=[0:N-1]*dt;BW=1/(N*dt);
>> sig=cos(2*pi()*fc*t)+vn*randn(1,N)/sqrt(dt);
A normal spectrum plot would show a 0 dBV signal with 'fuzz' appearing as a
flat line
when I did
>> pwelch(sig)
did not get near that, ok, needed to insert some 'extra' terms
>> pwelch(sig,N,1/dt)
that produced a plot that kind of looks right, like a peak at 1e6, but the
amplitude was wrong and the noise energy was wrong
If instead I run:
>> [sigf, ford]=time2freq(sig);
>> plot(ford/dt/1e6, 20*log10(abs(sigf)));
I get the EXACT spectrum one should see. with peak of 0 dBV at 1 [1MHz] and the
noise appears as a flat fuzzy line that calculates to almost exactly matching
noise density function of 10 nVrms/rtHz.
Any idea what to do to pwelch to get the 'correct' value for the amplitude? and
noise energy?
PS: the peak in the spectrum is coherent. To get energy multiply by 1/sqrt(2).
The noise is incoherent so multiply by 1/2 and divide by sqrt(BW) to get a
'measured' noise density function in terms of Vrms/rtHz.
--- address@hidden wrote:
From: Francesco Potortì <address@hidden>
To: Macy <address@hidden>
Cc: address@hidden
Subject: Re: FFT spectrum analyzer question
Date: Fri, 16 May 2014 16:42:12 +0200
>Thank you for the 'heads up' on pwelch function. Will look into it.
>
>There are an amazing number of useful functions, that I never seem to
>be alerted to until AFTER I write my own.
Generally speaking, unless you are an expert in a given field, it is
likely that a function exists somewhere that does your job, so start
looking for it before coding, or try asking on this list.
Anyway, this happened to me as well, exactly with the pwelch function,
but at that time I think pwelch was not still available, so I was
justified :)
>Worse, even when I 'know' a function exists, still difficult to find it!
Just install the "signal" package.
Have a look here, too: <http://octave.sourceforge.net/docs.html>, you'll
find pwelch there, together with much more.
--
Francesco Potortì (ricercatore) Voice: +39.050.621.3058
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it