Re: [Discuss-gnuradio] Some usrp_spectrum_sense.py code Explanation

2008-12-30 Thread Firas Abbas
Hi,

> --- On Tue, 12/30/08, Ling Huang  wrote:
> Hi, Firas
> In my opinion the ouput Y[i] has the same dimension with
> the power. If we square root the output, and divide it with the fft bin
> numbers, then we get  the voltage magnitude. Am I right? 
> 
> Best Regards,
> Ling

Yes, If we square root the output, and divide it with the fft size, then we 
will get the voltage magnitude.
Calculating 20 Log10 this value will give us the power.


Best Regards,


Firas


___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Some usrp_spectrum_sense.py code Explanation

2008-12-30 Thread Ling Huang


Interrupting Output Spectrum
-

The actual mapping from the levels at the daughterboard antenna input port
to the output analysis values depends on a lot of factors including the used
daughterboard RF gain and decimation specific gain in the digital down
converter. You'll need to calibrate the system if you need something that
maps to dBm.Currently, the output of usrp_spectrum_sense is the magnitude
squared of the FFT output.  That is, for each FFT bin[i], the output is Y[i]
= re[X[i]]*re[X[i]] + im[X[i]]*im[X[i]]. If you want power, take the square
root of the output. 


Hi, Firas
In my opinion the ouput Y[i] has the same dimension with the power. If we
square root the output, and divide it with the fft bin numbers, then we get
the voltage magnitude.
Am I right? 

Best Regards,
Ling


-- 
View this message in context: 
http://www.nabble.com/Some-usrp_spectrum_sense.py-code-Explanation-tp21209623p21214158.html
Sent from the GnuRadio mailing list archive at Nabble.com.



___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


[Discuss-gnuradio] Some usrp_spectrum_sense.py code Explanation

2008-12-29 Thread Firas A.

Hi Everybody,

and Merry Christmas

I received many emails requesting some explanation for
usrp_spectrum_sense.py gnuradio example program. The following link contains
the code with some explanation and one bug fix (in self.max_center_freq
equation):

http://rapidshare.com/files/177960860/usrp_spectrum_sense.py





usrp_spectrum_sense.py Explanation :
===

Introduction:
-

1) This program can be used as a basic code for implementing wideband
spectrum analyzer.
2) As we know, the USRP cannot examine more than 8 MHz of RF spectrum due to
USB bus limitations.
3) So, to scan across a wide RF spectrum band (bigger than 8 MHz) we have to
tune USRP RF front end in suitable steps so that we can examine a lot of
spectrum, although not all at the same instant. 
4) The usrp_spectrum_sense shows the way how it can be done.It steps across
the spectrum and make the RF measurements. This application can
sense a large bandwidth, but not in real time, and it can do the frequency
sweep over the required frequency range, 



Theory:
---

1) To use N points complex FFT X(W) analysis, we have to get N time samples
x(t) which are sampled at Fs.
2) These N time samples must be time windowed using a known window function
to reduce spectral leakage.
3) Performing N points complex FFT analysis.
4) The output of the complex FFT will represent the frequency spectrum
contents as follows:

a) The first value of the FFT output (bin 0 == X[0]) is the passband center
frequency.
b) The first half of the FFT (X[1] to X[N/2-1] contains the positive
baseband frequencies,which corresponds to the passband spectrum from the
center frequency out to the maximum passband frequency (from center
frequency to +Fs/2).
c) The second half of the FFT (X[N/2] to X[N-1]) contains the negative
baseband frequencies,which correspond to the lowest passband frequency up to
the passband center frequency (from -Fs/2 to center frequency).


Example
---

Let us assume that we have 1024 (I and Q) samples gathered using a tuner
centered at 20MHz. And let us assume that the sampling frequency was 8MHz.
Doing 1024 points complex FFT means:

1) FFT Frequency resolution is : 8MHz / 1024 = 7812.5 KHz
2) The output of the FFT X[0] represents the spectrum at 20MHz.
3) The output of the FFT X[1] to X[511] represents the frequencies from
20.0078125 MHz to 23.9921875 MHz (about 4MHz above center frequency).
4) The output of the FFT X[512] to X[1023] represents the frequencies from
16.0078125 MHz to 19.9921875 MHz (about 4MHz bellow center frequency).




RF Frequency Sweeping
-

1) Let us suppose that we want to scan RF spectrum band from 10MHz to 52
MHz.
2) Let us remember that USRP can analyze 8MHz of frequency at a time.
3) So theoretically we have to step our RF center frequency as follows:

First step is 14MHz (it will cover frequency band from 10MHz to 18MHz),
Second step is 22MHz (it will cover frequency band from 18MHz to 26MHz),
Third step is 30MHz (it will cover frequency band from 26MHz to 34MHz),
Fourth step is 38MHz (it will cover frequency band from 34MHz to 42MHz),
Fifth step is 46MHz (it will cover frequency band from 42MHz to 50MHz),
and finally the Sixth step is 54MHz (it will cover frequency band from 50MHz
to 58MHz). Remember that we want the frequencies up to 52MHz only, so we
have to discard some FFT points from the Sixth analysis.


4) Paralytically we have to use FFT overlapping to reduce the non linearity
response of the Digital Down Converter (the DDC frequency response is not
Flat from -Fs/2 to + Fs/2) and to fill the frequency holes that will be
present at the FFT analysis edges (10MHz, 18MHz, 26MHz, 34MHz, 42MHz, 50
MHz).

So if we choose to use an overlap of 25%, this means that our step size will
be 6MHz (8MHz*(1-.25)), thus practically we have to step our RF center
frequency as follows:

First step is 13MHz (it will cover frequency band from 9MHz to 17MHz),
Second step is 19MHz (it will cover frequency band from 15MHz to 23MHz),
Third step is 25MHz (it will cover frequency band from 21MHz to 29MHz),
Fourth step is 31MHz (it will cover frequency band from 27MHz to 35MHz),
Fifth step is 37MHz (it will cover frequency band from 33MHz to 41MHz),
Sixth step is 43MHz (it will cover frequency band from 39MHz to 47MHz),
and Finally the Seventh step is 49MHz (it will cover frequency band from
45MHz to 53MHz),





Changing RF center Frequency


1) To change USRP RF center frequency we have to send a tunning command to
the USRP every time we complete the analysis of the current frequency chunk.
2) Before gnuradio revision [10165], all USRP RF daughterboards tunning were
done using Python functions and classes. After that revision, tunning the
USRP daughterboards from withen C++ code is possible.
3) In usrp_spectrum_sense.py, the DSP C++ written code is allowed to
transparently invoke Python code USRP tune