# Scanning desired frequenies

**URL:** <https://www.ruby-forum.com/t/scanning-desired-frequenies/242321>\
**Category:** GNU Radio\
**Created:** [June 15, 2015, 6:12pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321 "2015-06-15T18:12:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 15, 2015, 6:12pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/1 "2015-06-15T18:12:28Z")

</div>

I have been trying to make my NI-B200 scan frequencies that I have in a  
text file for a couple days now. I was introduced to this mailing list  
through the GNU website and it has helped me alot these past few day,  
Thank  
you all, but I haven’t completed my task yet so I’m going to be as  
specific  
as possible with what I need help with and with what I have been doing.

I have a list of about 1000+ frequencies and I need to scan all of them  
with my NI-B200 and record their power(dB). I am currently using using  
usrp\_spectrum\_sense.py (  
[https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp\_spectrum\_sense.py](https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp_spectrum_sense.py))  
to scan the frequencies but it scans a range and not the specific  
frequencies I want so I made my own py file that simply loop the  
execution  
of usrp\_spectrum\_sense.py until the end of the list. It is a very crude  
way  
of going about things. Is there a better, much cleaner way I can  
accomplish  
my goal?

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 15, 2015, 6:32pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/2 "2015-06-15T18:32:55Z")

</div>

Hi Ashraf,

thanks for the nice words and the detailed problem description.

Yes, I think there are ways to achieve what you want; you will have to  
write a few GNU Radio blocks, but I think it’s possible to do after  
lecture of the GNU Radio guided tutorials [1]; if you encounter any  
obstacles, the mailing list probably will have an open ear for you 🙂

You could write your own block that passes through samples, and controls  
the USRP. For starters, that could be done in python, if that feels more  
familiar to you than C++. It will have to be a general block.

As a first step, that block would simply wait for a tx\_time tag coming  
in. That tag value contains the time at which tuning happened.  
Use that time to calculate the time at which the next tuning should  
occur.  
Give your block the ability to call your usrp\_source’s  
set\_command\_time() with that time.  
Use message passing to issue the tuning command [2].  
After each tag, pass a fixed amount of samples \<=  
(inter\_tune\_time\*sampling rate), and just consume the rest, until the  
next tag appears. Pass through the rx\_freq tag to the first passed  
sample.

Connect your block’s input to your usrp\_source’s output, and  
message\_connect your block’s message output to the usrp\_source’s message  
input.

Connect the output of your block to a stream to vector; connect that to  
whatever processing you want to do. For example, you can do an FFT.  
After the FFT, you could attach another block that you’d write yourself,  
that would take the rx\_freq tag again,and based on that, would for  
example put the FFT vector into the right position in an array of FFT  
vectors.

Best regards,  
Marcus

[1] [https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided\_Tutorials](https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials)  
[2] [GNU Radio Manual and C++ API Reference: UHD Interface](http://gnuradio.org/doc/doxygen/page_uhd.html#uhd_command_syntax)

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 15, 2015, 10:51pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/3 "2015-06-15T22:51:08Z")

</div>

I’m sorry but this is all too much. I need some help breaking this  
process  
down.  
What do you mean by samples, Is that the frequency list?  
My first block is reading the data from the file, and has an input for  
tx\_tune?  
What is a tag?  
When I do all this I will run it in GRC, correct?

On Mon, Jun 15, 2015 at 12:31 PM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 3:27am UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/4 "2015-06-16T03:27:28Z")

</div>

This scans the B200 through GSM channels, compares to a calibrated  
threshold,  
and logs if it exceeds the threshold. You would just populate the  
Python  
list with your frequencies and iterate through them. Note this uses the  
old  
message queues, which as been deprecated, and I have not figured out a  
way  
around it. The usrp\_spectrum\_sense also uses message queues though, so  
someone will have to update them eventually.

> <https://pastebin.com/ezhTFrVB>

Lou

Ashraf Y. wrote

> I have been trying to make my NI-B200 scan frequencies that I have in a  
> text file for a couple days now.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Scanning-desired-frequenies-tp54189p54199.html](http://gnuradio.4.n7.nabble.com/Scanning-desired-frequenies-tp54189p54199.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 15, 2015, 10:57pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/5 "2015-06-15T22:57:34Z")

</div>

Samples are what comes out of your USRP, and what you process in GNU  
Radio.

What a tag is, how blocks work, and how you can write your own is all  
covered in the guided tutorials; I’d recommend reading those from first  
to 6, because that will cover all these topics, including dealing with  
Hardware like the USRP.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 3:55pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/6 "2015-06-16T15:55:14Z")

</div>

Well googling that error points to something with the B200. I ran it  
last  
night with latest UHD/GR and it runs fine. Python has no issues with  
1000  
length list of floats.  
Lou

Ashraf Y. wrote

> Amazing, this seems to do what I needed. Thank you. It seems my list is  
> too  
> big because I get a RuntimeError: AssertionError: accum\_timeout \<  
> \_timeout.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Scanning-desired-frequenies-tp54189p54210.html](http://gnuradio.4.n7.nabble.com/Scanning-desired-frequenies-tp54189p54210.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 2:58pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/7 "2015-06-16T14:58:34Z")

</div>

Amazing, this seems to do what I needed. Thank you. It seems my list is  
too  
big because I get a RuntimeError: AssertionError: accum\_timeout \<  
\_timeout.

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 3:59pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/8 "2015-06-16T15:59:55Z")

</div>

I see, I will try to update my system and hope that it works. Thank you.

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 4:16pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/9 "2015-06-16T16:16:16Z")

</div>

Dear Ashraf,

that error is not very common. It means that your PC didn’t get an “OK”  
from the USRP in time.  
Did you get “O”, or “U”, or “S” printed to your console?  
If you did, did upgrading UHD help?

If it didn’t, please contact removed\_email\_address@domain.invalid.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 16, 2015, 4:24pm UTC](https://www.ruby-forum.com/t/scanning-desired-frequenies/242321/10 "2015-06-16T16:24:27Z")

</div>

I was not sure how to upgrade the UHD, so I updated my OS and it seemed  
to  
work. Just to be sure we’re talking about the same thing, this is the  
full  
description of the error;  
terminate called after throwing an instance of ‘uhd::assertion\_error’  
what(): AssertionError: accum\_timeout \< \_timeout  
in uint64\_t radio\_ctrl\_core\_3000\_impl::wait\_for\_ack(bool)  
at /home/ashraf/uhd/host/lib/usrp/cores/radio\_ctrl\_core\_3000.cpp:230

On Tue, Jun 16, 2015 at 10:15 AM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
