# About the latest submission of usrp\_spectrum\_sense.py

**URL:** <https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954>\
**Category:** GNU Radio\
**Created:** [July 25, 2013, 11:13pm UTC](https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954 "2013-07-25T23:13:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 25, 2013, 11:13pm UTC](https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954/1 "2013-07-25T23:13:22Z")

</div>

Dear all,

I checked your latest submission of “usrp\_spectrum\_sense.py” and I don’t  
understand why there is a division of the value of each bin by the  
sampling  
rate. Also I don’t understand why there is a subtraction of the noise  
floor from the power db value to calculate an actual db value.

Kindly explain those modifications.

I am working with a USRP N210 and when I run uhd\_fft to display an  
analog  
TV channel I get values around -60’s db for the central frequencies of  
both  
the audio and video signals. When I used the latest version of  
“usrp\_spectrum\_sense.py”, I got positive values for power\_db and when I  
removed the deduction of the noise floor, I got readings almost near the  
noise floor for all bins (including the ones at the central frequency of  
the audio and video signals). I hope you can point me to the right  
direction and correct my misunderstanding of the code.

Thank you for your time.

## Kind regards, Ahmed Saeed.

Ahmed Saeed  
Research Assistant  
Department of Computer Science and Engineering  
Egypt-Japan University of Science and Technology (E-JUST)

email: removed\_email\_address@domain.invalid  
mobile: +201112389430  
web: [http://wrc.ejust.edu.eg/people/saeed](http://wrc.ejust.edu.eg/people/saeed)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@Ahmed\_Saeed](https://www.ruby-forum.com/u/Ahmed_Saeed)\
**Post date:** [July 27, 2013, 2:10pm UTC](https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954/2 "2013-07-27T14:10:41Z")

</div>

Hi Ahmed,

Dividing the bin power by the sample rate in the calculation for  
noise\_floor\_db and power\_db (lines 286 and 287 of  
[uhd: enhanced version of usrp\_spectrum\_sense.py · gnuradio/gnuradio@cc12277 · GitHub](https://github.com/gnuradio/gnuradio/commit/cc12277f64207ff79a40094268c843e6b3e2d2d3#L0R286))  
was done so that the power level stays constant if the sample rate is  
increased. This is required because the bin statistics function sums  
together more samples if the usrp\_rate is increased and therefore  
increases  
the bin value result.

The noise\_floor\_db value is subtracted from the power\_db value to give  
a  
relative signal strength above the noise floor to make it easier to set  
the  
squelch and catch signals:

noise\_floor\_db = 10_math.log10(min(m.data)/tb.usrp\_rate)  
power\_db = 10_math.log10(m.data[i\_bin]/tb.usrp\_rate) - noise\_floor\_db

Regards,

Mike

–  
Mike J. M0MIK BSc MIET  
Email: removed\_email\_address@domain.invalid  
Web: [http://scanoo.com](http://scanoo.com)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@Ahmed\_Saeed](https://www.ruby-forum.com/u/Ahmed_Saeed)\
**Post date:** [July 27, 2013, 2:13pm UTC](https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954/3 "2013-07-27T14:13:37Z")

</div>

Hi Mike,

Thank you for your reply.

So what if I want to sense with the sensing threshold set by the FCC for  
white spaces at -114 dBm or -107 dBm. How does the value of “power\_db”  
relates to the value I should compare against given the FCC thresholds ?

Kind regards,  
Ahmed Saeed.

On Sat, Jul 27, 2013 at 1:35 PM, Mike J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## The noise\_floor\_db value is subtracted from the power\_db value to give a
> 
> > understand why there is a division of the value of each bin by the sampling  
> > noise floor for all bins (including the ones at the central frequency of  
> > Department of Computer Science and Engineering

–  
Ahmed Saeed  
Research Assistant  
Department of Computer Science and Engineering  
Egypt-Japan University of Science and Technology (E-JUST)

email: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
mobile: +201112389430  
web: [http://wrc.ejust.edu.eg/people/saeed](http://wrc.ejust.edu.eg/people/saeed)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@Ahmed\_Saeed](https://www.ruby-forum.com/u/Ahmed_Saeed)\
**Post date:** [July 27, 2013, 2:39pm UTC](https://www.ruby-forum.com/t/about-the-latest-submission-of-usrp-spectrum-sense-py/235954/4 "2013-07-27T14:39:19Z")

</div>

Hi Ahmed,

You will need to use a calibrated rf source to compare your USRP N210  
SDR  
receiver against and adjust the power\_db result (without subtracting the  
noise floor result from it) to match. I assume it will be a simple case  
of  
adding or subtracting ‘X’ db’s to the power\_db result for each  
calibration  
power level tested against. Unfortunately I haven’t any calibrated rf  
signal sources to hand so am unable to confirm how easy it will be to  
calibrate.

Regards,

Mike

–  
Mike J. M0MIK BSc MIET  
Email: removed\_email\_address@domain.invalid  
Web: [http://scanoo.com](http://scanoo.com)
