discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Change frequency in USRP source automatically


From: Yan Huang
Subject: Re: [Discuss-gnuradio] Change frequency in USRP source automatically
Date: Wed, 16 Mar 2016 17:06:01 +0000

Hi Timothée,

Thank you so much, I’ve got the frequency sweeper with your advice.

 

It’s not the problem about GNU Radio, I added “work” function in my code but actually it’s a message block which do not need a IO stream ports.

 

Many thanks,

Yan

 

From: Timothée COCAULT [mailto:address@hidden
Sent: 15 March 2016 20:12
To: Yan Huang
Cc: Martin Braun; address@hidden
Subject: Re: [Discuss-gnuradio] Change frequency in USRP source automatically

 

I know I had some problems with older versions of GNU Radio with Python block and message ports breaking my flowgraph. I don't know for sure if it's the same problem though.

Try to install the latest GNU Radio in a new prefix, or you could re-code this blocks in C++ in an OOT module.

 

Cheers,

Timothée.

 

2016-03-15 18:58 GMT+01:00 Yan Huang <address@hidden>:

Hi Timothée,

 

Thank you very much, I have built a python block as you suggested and then put it between the strobe and the USRP source, but it come up error like:

   

 File "/home/mint/Documents/test_sensor/scan/scan.py", line 154, in <module>tb = scan()

 File "/home/mint/Documents/test_sensor/scan/scan.py", line 123, in __init__

    self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.freq_sweeper_frequency_sweeper_0, 'in'))    

 File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py", line 60, in wrapped

    func(self, src.to_basic_block(), srcport, dst.to_basic_block(), dstport)

 File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py", line 132, in msg_connect

    self.primitive_msg_connect(*args)

 File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/runtime_swig.py", line 4472, in primitive_msg_connect

    return _runtime_swig.top_block_sptr_primitive_msg_connect(self, *args)

RuntimeError: invalid msg port in connect() or disconnect()

 

 File "   The GNU Radio version is GNU Radio Companion v3.7.6.1-65-g500517ac, do you know where is the problem?

 

             Many thanks,

Yan

 

From: Timothée COCAULT [mailto:address@hidden]
Sent: 15 March 2016 16:24


To: Yan Huang
Cc: Martin Braun; address@hidden
Subject: Re: [Discuss-gnuradio] Change frequency in USRP source automatically

 

The easiest way would be to create a simple Python block between the strobe and the USRP source :

 

###

 

class frequency_sweeper(gr.sync_block):

    def __init__(self, initial_freq=2.37e9, step=2e6):  # only default arguments here

        gr.sync_block.__init__(

            self,

            name='Frequency sweeper',

            in_sig=[],

            out_sig=[]

        )

        self.message_port_register_in(pmt.intern('clock'))

        self.set_msg_handler(pmt.intern('clock'), self.handler)

        self.message_port_register_out(pmt.intern('sync'))

        self.freq = initial_freq

        self.step = step

 

    def handler(self, pdu):

        self.message_port_pub(pmt.intern('sync'), pmt.cons(pmt.intern("freq"), pmt.to_pmt(self.freq)))

        self.freq += self.step

 

###

 

Cheers,

Timothée.

 

2016-03-15 16:52 GMT+01:00 Yan Huang <address@hidden>:

Hi Timothée,

 

Thank you for your advice. But if I want to change the center frequency from 2.37GHz-2.43GHz with each time stepping 2MHz, how can I realize it by” Message Strobe”?

 

Many thanks,

Yan

 

From: Timothée COCAULT [mailto:address@hidden]
Sent: 15 March 2016 15:44
To: Yan Huang
Cc: Martin Braun; address@hidden


Subject: Re: [Discuss-gnuradio] Change frequency in USRP source automatically

 

Hi Yan,

 

You should only pass only one value in the second member. Try :

 

pmt.cons(pmt.intern("freq"), pmt.to_pmt(2.4e9))

 

 

Cheers,

Timothée.

 

 

2016-03-15 12:14 GMT+01:00 Yan Huang <address@hidden>:

Hi Martin,

Thank you, it works well. But I want to change the frequency automatically, so I change the frequency to array like:

pmt.cons(pmt.string_to_symbol("freq"),pmt.to_pmt(numpy.array([2.4e9,2.45e9],dtype=numpy.float32)))

and I also import numpy in GNU Radio, but it comes up with error :

thread[thread-per-block[10]: <block gr uhd usrp source (1)>]: pmt_to_double: wrong_type : #[2.4e+09 2.44999987e+09]

Thanks,

Yan


-----Original Message-----
From: discuss-gnuradio-bounces+eexyh22=address@hidden [mailto:discuss-gnuradio-bounces+eexyh22=address@hidden] On Behalf Of Martin Braun
Sent: 15 March 2016 00:43
To: address@hidden
Subject: Re: [Discuss-gnuradio] Change frequency in USRP source automatically

Yan,

simply convert "freq" and your frequency to a PMT before passing into cons().

Cheers,
Martin

On 03/14/2016 03:44 PM, Yan Huang wrote:
> Hi Martin,
>
> Thank you for your kind reply. But I'm still comfused that I already have to input in pmt::cons("freq",2.4e9), cause in the manual it said:
>
> pmt::cons(KEY, VALUE): This format is useful for commands that take a single value. Think of KEY and VALUE as the argument name and value, respectively. For the case of the QT GUI Frequency Sink, KEY would be "freq" and VALUE would be the new center frequency in Hz.
>
> Could you please give me an exmaple about it?
>
> Thank you a lot,
>
> Yan
> ________________________________________
> From: discuss-gnuradio-bounces+eexyh22=address@hidden
> [discuss-gnuradio-bounces+eexyh22=address@hidden] on behalf
> of Martin Braun [address@hidden]
> Sent: 14 March 2016 17:18
> To: address@hidden
> Subject: Re: [Discuss-gnuradio] Change frequency in USRP source
> automatically
>
> Yan,
>
> check the PMT manuals. cons() takes 2 PMTs as input.
>
>
> Cheers,
> Martin
>
> On 03/14/2016 09:09 AM, Yan Huang wrote:
>> Hi all,
>>
>>
>>
>> I want to change the frequency in "USRP source" automatically, for
>> example 2.37GHz-2.43GHz with each time stepping 2MHz.
>>
>>
>>
>> 1. As you know, the USRP source has an input message port, so I want
>> to connect it to a "Message strobe" to control the frequency change.
>> But  after I see [1][2], I write PMT type commands  in "Message PMT"
>> in "Message Strobe" as:
>>
>> pmt::cons("freq",2.4e9)
>>
>> it comes up error "invalid syntax(<string>,line 1)", so I don't know
>> how to further stepping the frequency.
>>
>> 2. If I use the "Message Strobe" to define frequency, what can I put
>> in the "frequency" in "USRP source" block? Put it as 0?
>>
>>
>>
>> [1] https://gnuradio.org/doc/doxygen/page_uhd.html#uhd_command_syntax
>>
>> [2]
>> https://gnuradio.org/doc/doxygen/page_msg_passing.html#msg_passing_co
>> mmands
>>
>>
>>
>> Many thanks ,
>>
>>
>>
>> Yan
>>
>>
>>
>>
>>
>> This message and any attachment are intended solely for the addressee
>> and may contain confidential information. If you have received this
>> message in error, please send it back to me, and immediately delete it.
>>
>> Please do not use, copy or disclose the information contained in this
>> message or in any attachment.  Any views or opinions expressed by the
>> author of this email do not necessarily reflect the views of the
>> University of Nottingham.
>>
>> This message has been checked for viruses but the contents of an
>> attachment may still contain software viruses which could damage your
>> computer system, you are advised to perform your own checks. Email
>> communications with the University of Nottingham may be monitored as
>> permitted by UK legislation.
>>
>>
>>
>> _______________________________________________
>> Discuss-gnuradio mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
>
>
> This message and any attachment are intended solely for the addressee
> and may contain confidential information. If you have received this
> message in error, please send it back to me, and immediately delete it.
>
> Please do not use, copy or disclose the information contained in this
> message or in any attachment.  Any views or opinions expressed by the
> author of this email do not necessarily reflect the views of the
> University of Nottingham.
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses which could damage your
> computer system, you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation.
>


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio




This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it.

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

 

 
 
This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 
 
Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.
 
This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

 

 
 
This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 
 
Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.
 
This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

 



This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]