discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] GNURadio Help


From: CEL
Subject: Re: [Discuss-gnuradio] GNURadio Help
Date: Wed, 13 Jun 2018 14:52:44 +0000

I don't understand what you mean with "do the FFT and then transfer […]
to the host machine": GNU Radio runs on the host machine, so whatever
processing you do already happens on the host machine.

Assuming this is just a small problem in expression, and you're doing
all this on the same machine:
Well, you'll need to send messages to the USRP source to re-tune with
timed commands, and to "sort" the samples coming out of the source by
the timestamp they have so that you know which FFT-length vectors
belong to which frequency (and drop the samples that were taken while
you were re-tuning). Note that the capability to tune on timed commands
is not given in all USRPs to the same degree at all.

It's a relatively complex application that you're planning. There's an
old GNU Radio example that does exactly that, but was written long
before timed commands were introduced, and is hence incredibly
inefficient (has to throw away most of the samples, because it never
knows when exactly tuning has happpened). I wouldn't recommend using it
for this reason, but it still works, and that without much custom
blocks (but with ugly and slow python code that noone would write
similarly today). It's in gnuradio/gr-uhd/examples/python and is called
usrp_spectrum_sense. Again, this is basically obsolete technologically,
but it still works. Please don't write the 400th thesis about this
piece of software!

Best regards,
Marcus

On Wed, 2018-06-13 at 17:42 +0300, Ivan Zahartchuk wrote:
> I need to rebuild the frequency, do fft and then transfer the whole array 
> from 70 to 6GHz to the host machine. I do not quite imagine how you can do 
> this with standard blocks in gnuradio.
> 
> 
> 2018-06-13 17:32 GMT+03:00 Müller, Marcus (CEL) <address@hidden>:
> > Dear Ivan,
> > 
> > you don't pass data to a block yourself. 
> > 
> > You write a block that does a clearly-limited signal processing job,
> > and use GNU Radio to connect that to other blocks:
> > 
> > https://tutorials.gnuradio.org
> > 
> > In your case, instantiating a USRP source in your block makes
> > absolutely no sense, for example. You'd build a flow graph containing
> > the USRP source, and your custom-written block, and you'd connect these
> > two.
> > 
> > It's sadly not really clear what you want to achieve, so I'm afraid I'm
> > not able to help you here.
> > 
> > Generally, GNU Radio pretty much takes the idea of "draw a block
> > diagram of what you want to achieve with your signal processing", and
> > directly translates it to "using existing blocks and writing new ones,
> > and letting GNU Radio take care of how the data gets around".
> > 
> > Also, wideband signal processing and implementing a sync_block in
> > Python... do not work well together.
> > 
> > So, I think you might really be a bit confused about the architecture
> > of GNU Radio – I really hope the tutorials explain that better than I
> > could.
> > 
> > Best regards,
> > Marcus
> > 
> > On Wed, 2018-06-13 at 17:16 +0300, Ivan Zahartchuk wrote:
> > > Hello. I'm trying to write a block in gnuradio for broadband reception.
> > >  The main problem at the moment is to transfer data to the fft block. 
> > > I'm new to python and so it's hard for me to figure this out.import numpy 
> > > as np
> > > 
> > > I need an array of data to pass to the gnuradio.fft.fft.vcc block
> > > 
> > > from gnuradio import gr
> > > from gnuradio import uhd
> > > from gnuradio import fft
> > > 
> > > class blk(gr.sync_block):  # other base classes are basic_block, 
> > > decim_block, interp_block
> > >     """Embedded Python Block example - a simple multiply const"""
> > > 
> > >     def __init__(self, 
> > > gain=1.0,start_freq=70e6,stop_freq=6000e6,samp_rate=30e6):  # only 
> > > default arguments here
> > >         """arguments to this function show up as parameters in GRC"""
> > >         gr.sync_block.__init__(
> > >             self,
> > >             name='Python Block',   # will show up in GRC
> > >             in_sig=None,
> > >             out_sig=[np.complex64,np.complex64]
> > >         )
> > >         # if an attribute with the same name as a parameter is found,
> > >         # a callback is registered (properties work, too).
> > >         self.gain = gain
> > >         self.start_freq=start_freq
> > >         self.stop_freq=stop_freq
> > >         self.samp_rate=samp_rate
> > >         self.uhd_usrp_source_0 = uhd.usrp_source(",".join(("", "")),
> > >                                                  uhd.stream_args(
> > >                                                      cpu_format="fc32",
> > >                                                      otw_format="sc16",
> > >                                                      chanels=range(1),
> > >                                                  ),
> > >                                                  )
> > > 
> > > 
> > >         self.uhd_usrp_source_0.set_clock_rate(30e6, uhd.ALL_MBOARDS)
> > >         self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
> > >         self.uhd_usrp_source_0.set_gain(self.gain, 0)
> > >         self.uhd_usrp_source_0.set_antenna("RX2", 0)
> > >         self.uhd_usrp_source_0.set_bandwidth(30e6, 0)
> > >         self.range_freq=(self.stop_freq-self.start_freq)/self.samp_rate
> > > 
> > >     def work(self, input_items, output_items):
> > >         """example: multiply with constant"""
> > >         for i in np.range(self.range_freq):
> > >             
> > > self.uhd_usrp_source_0.set_center_freq(self.start_freq+self.samp_rate*i)
> > >             data=np.array(self.uhd_usrp_source_0.finite_acquisition(8192))
> > >         output_items[0][:] = input_items[0] * self.example_param
> > >         return len(output_items[0])
> > > _______________________________________________
> > > Discuss-gnuradio mailing list
> > > address@hidden
> > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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