USRP2 Spectrum Sensing Help

Hello,

I’ve created a spectrum sensor with the USRP2, my python script uses the
same idea as usrp_spectrum_sense.py found in gnuradio. That is, it
tunes,
takes an FFT, records, retunes, etc.

I have two problems with my data though. In the file attached is some
TV
spectrum (left half) and noise (right half).

My first question is this: why isn’t the spectrum for the TV signal
flat, it
seems to bob up and down. Note that each segment is from a different
FFT,
that is each FFT produces that oval shape. At first I thought this had
something to do with the window I was using but I’ve tried hamming,
blackman-harris, and rectangular windows and they all have this effect.

My second question is why isn’t the transition between TV spectrum and
noise
more smooth? It looks like it could be smooth but the gain seems to jump
for
an FFT right after 566 MHz and then settle down again. I thought this
might
be the AGC but I’ve tried different attack/decay rates, different
reference
levels, etc with the agc2_cc block but the problem remains.

Any help with either of these questions would be appreciated,
Devin

On Fri, Mar 18, 2011 at 10:10 AM, devin kelly [email protected]
wrote:

Hello,

I’ve created a spectrum sensor with the USRP2, my python script uses the
same idea as usrp_spectrum_sense.py found in gnuradio. That is, it tunes,
takes an FFT, records, retunes, etc.

Could you post a flowgraph or tell us what frequencies you are tuning
sweeping across, what step size, any averaging you use, sample rate or
decimation, etc.

I have two problems with my data though. In the file attached is some TV
spectrum (left half) and noise (right half).

My first question is this: why isn’t the spectrum for the TV signal flat, it
seems to bob up and down. Note that each segment is from a different FFT,
that is each FFT produces that oval shape. At first I thought this had
something to do with the window I was using but I’ve tried hamming,
blackman-harris, and rectangular windows and they all have this effect.

The TVRX has a 6MHz bandpass filter, which will add shape to the
spectrum you sense and even if you pick a smaller than 6Msps sample
rate, you will still have several effects to consider:

  • Aliasing of energy inside the 6MHz bandpass
  • Probably 75% of the 6MHz is the flat region
  • TVRX has finite tuning steps, so you may be causing the USRP2 DDC to
    push your IF against the edge of the TVRX bandpass

My second question is why isn’t the transition between TV spectrum and noise
more smooth? It looks like it could be smooth but the gain seems to jump for
an FFT right after 566 MHz and then settle down again. I thought this might
be the AGC but I’ve tried different attack/decay rates, different reference
levels, etc with the agc2_cc block but the problem remains.

I am not familiar with the agc2 block, but I would recommend against
using AGC until you are confident you have handled the bandpass nature
of TVRX properly

Any help with either of these questions would be appreciated,

If you are using UHD, you might consider using the uhd::tune_result_t
returned by set_center_freq() to make sure you are staying centered in
the bandpass filter

Jason

On 18/03/2011 1:10 PM, devin kelly wrote:

flat, it seems to bob up and down. Note that each segment is from a
different FFT, that is each FFT produces that oval shape. At first I
thought this had something to do with the window I was using but I’ve
tried hamming, blackman-harris, and rectangular windows and they all
have this effect.
The CIC decimator in the FPGA necessarily effects a bandpass filtering
effect, whose “skirts” are not infinitely steep, the shape of that
bandpass response is roughly a “rounded hump”. If you take multiple
“snapshots” of spectrum, over multiple tunings, you’ll get a bumpy
effect because the pass-band isn’t flat. One way to “fix” this for
making nicer-looking displays is to invert the “hump” effect in the FFT
magnitudes, prior to “stitching”.

Thanks Jason, Marcus,

I forgot to mention I’m using the WBX, not the TVRX. I’m using the UHD
as
well.

The flowgraph

uhd_single_source → agc2 → streamToVector → fft_vcc →
cmplexToMagitude
→ binStatistics

I added the agc2 block recently, I have similar problems without it.

Usually I’m interested in sweeping from 50 MHz to 2.2 GHz, but this scan
was
from 558 MHz to 568 MHz. The FFT size I use is usually 512 or 1024. I
believe the decimation rate here is 256, but both problems persist no
matter
the decimation/sampling rate I select.

On Fri, Mar 18, 2011 at 1:43 PM, Jason A. [email protected] wrote:

decimation, etc.

blackman-harris, and rectangular windows and they all have this effect.
My second question is why isn’t the transition between TV spectrum and
I am not familiar with the agc2 block, but I would recommend against
using AGC until you are confident you have handled the bandpass nature
of TVRX properly

Any help with either of these questions would be appreciated,

If you are using UHD, you might consider using the uhd::tune_result_t
returned by set_center_freq() to make sure you are staying centered in
the bandpass filter

When I do a sweep from 558MHz to 568MHz with my decimation rate of 256
I
get these results from tune_result_t. Note this isn’t all the results,
but
I think you can get the idea from these.

Target Inter Frequency 567277343.75 Actual Inter Frequency
567277167.277
Target DSP Frequency -128.777472496 Actual DSP Frequency
-128.778629005
Target Inter Frequency 567472656.25 Actual Inter Frequency
567472527.473
Target DSP Frequency -81.0821123123 Actual DSP Frequency
-81.0716301203
Target Inter Frequency 567667968.75 Actual Inter Frequency
567667887.668
Target DSP Frequency -33.3867521286 Actual DSP Frequency -33.3879143
Target Inter Frequency 567863281.25 Actual Inter Frequency
567863247.863
Target DSP Frequency -1511.94291818 Actual DSP Frequency
-1511.9323507
Target Inter Frequency 568058593.75 Actual Inter Frequency
568057081.807
Target DSP Frequency -891.903235674 Actual DSP Frequency
-891.904346645
Target Inter Frequency 558097656.25 Actual Inter Frequency
558096764.347

The DSP frequency is all over the place, from -30 to -1500, why is it
always
negative?

Thanks Again,
Devin

On Fri, Mar 18, 2011 at 4:29 PM, Moeller [email protected] wrote:

Typically (NLOS conditions) you will receive multiple paths and they
interfere.
The “frequency selective fading” effect is very strong for wide-band
signals like DVB-T.
NB signals like GSM assume the “flat fading” model, by contrast.

I suppose flat is the wrong word. If you look at the image I provided in
the first email you’ll find that all the FFT outputs have this hump
shape to
them.

My second question is why isn’t the transition between TV spectrum and
noise more smooth? It looks like it could be smooth but the gain seems to
jump
for an FFT right after 566 MHz and then settle down again. I thought
this might be the AGC but I’ve tried different attack/decay rates, different
reference levels, etc with the agc2_cc block but the problem remains.

Can you switch off the AGC? AGC can destroy the whole spectrum measurement.
Single spikes could be spurious mixing products from the receiver itself.

I’ve only started using the AGC block very recently. I started using
because I wanted some way to control the AGC. This makes me think of
the
question, is the AGC on by default? That is, if I don’t have an AGC
block
will the AGC be doing anything? Also, in the first two or three ICs in
the
WBX there is a digitally controlled attenuator and an LNA, those are
part of
the AGC correct?

A global filtering shape is expected from the analog RF filters.
Of course, on the borders of FFT blocks you have incorrect transitions,
depending on the shape within the reception bandwidth.
I assume this could be compensated by scaling the FFT values.

This is going to be the next thing I try.

Btw, did anybody try to write a spectrum sensor with the Funcube USB
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page

Thanks Again,
Devin

On 03/19/2011 11:06 AM, devin kelly wrote:

I’ve only started using the AGC block very recently. I started using
because I wanted some way to control the AGC. This makes me think of
the question, is the AGC on by default? That is, if I don’t have an
AGC block will the AGC be doing anything? Also, in the first two or
three ICs in the WBX there is a digitally controlled attenuator and an
LNA, those are part of the AGC correct?
There is no automatic gain control in the WBX hardware. The step
attenuators are set when you set the hardware RF gain of the
daughter-card.
The AGC block within Gnu Radio simply applies a multiplicative
coefficient to the data stream within Gnu Radio, based on smoothed
historical signal power estimates.

AGC is useful for certain types of signals, and not for others, which is
why there’s no automatic AGC in the hardware. Now various
daughtercards have manual gain control, and you can certainly
implement AGC that’s distributed between software and hardware,
but that’s up to the software. In general, in SDR, you want the
hardware to implement (borrowing from X11 for a second here)
“mechanism, not policy”. Consider precision RF measurement
applications, for example. You don’t want the hardware implementing
an AGC policy of any kind. Just like you don’t want the hardware
implementing “the one, true demodulation mode”.


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium

On 18.03.2011 18:10, devin kelly wrote:

I have two problems with my data though. In the file attached is some TV
spectrum (left half) and noise (right half).
My first question is this: why isn’t the spectrum for the TV signal flat, it
seems to bob up and down. Note that each segment is from a different
FFT, that is each FFT produces that oval shape. At first I thought this had
something to do with the window I was using but I’ve tried hamming,
blackman-harris, and rectangular windows and they all have this effect.

Why should it be flat? On the transmission side OFDM is quite flat.
Typically (NLOS conditions) you will receive multiple paths and they
interfere.
The “frequency selective fading” effect is very strong for wide-band
signals like DVB-T.
NB signals like GSM assume the “flat fading” model, by contrast.

My second question is why isn’t the transition between TV spectrum and noise
more smooth? It looks like it could be smooth but the gain seems to jump
for an FFT right after 566 MHz and then settle down again. I thought this might
be the AGC but I’ve tried different attack/decay rates, different
reference levels, etc with the agc2_cc block but the problem remains.

Can you switch off the AGC? AGC can destroy the whole spectrum
measurement.
Single spikes could be spurious mixing products from the receiver
itself.
A global filtering shape is expected from the analog RF filters.
Of course, on the borders of FFT blocks you have incorrect transitions,
depending on the shape within the reception bandwidth.
I assume this could be compensated by scaling the FFT values.
To get the spectrum more smooth, you have to capture longer signals
within the blocks of measurement bandwidth, for averaging the PSD
estimate.

Any help with either of these questions would be appreciated,
Devin

Do you want to publish the program? I think it would be very interesting
for the examples section of Gnuradio. Surely, you will get support from
the Gnuradio community to improve the sensing function.

Btw, did anybody try to write a spectrum sensor with the Funcube USB
dongle?
This would be a low-cost alternative. The measurement bandwidth is not
high,
but it can scan a broad range of the spectrum.
Possibly, after switching off AGC, compensating within the meas.
bandwidth
and compensating the global filter shape, the result could be quite
useful.
(if there are not too many spurious frequency components within the
receiver itself)

On Mar 19, 2011, at 10:34 AM, “Marcus D. Leech” [email protected]
wrote:

There is no automatic gain control in the WBX hardware. The step attenuators
are set when you set the hardware RF gain of the daughter-card.

There’s AGC on the WBX tx side, but not rx.

-Marc

On 03/19/2011 12:50 PM, Marc E. wrote:

There’s AGC on the WBX tx side, but not rx.

-Marc

Yes, that’s true, and I should have clarified that I was talking about
the RX side.


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium

hello, how you did it, that changed in the sensing spectrum, I’m using
the
module FLEX900?

devin kelly-2 wrote:

My first question is this: why isn’t the spectrum for the TV signal flat,
an FFT right after 566 MHz and then settle down again. I thought this
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page

[email protected]

View this message in context:
http://old.nabble.com/USRP2-Spectrum-Sensing-Help-tp31183192p32206004.html
Sent from the GnuRadio mailing list archive at Nabble.com.