discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Noob questions on transmitting a finite pulse, wa


From: Josh Blum
Subject: Re: [Discuss-gnuradio] Noob questions on transmitting a finite pulse, waiting, and then starting to receive
Date: Mon, 07 Jan 2013 12:35:49 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0


On 01/07/2013 12:25 PM, Bill Peter wrote:
> Thanks, Josh. I looked a bit at those links, and I guess I will have to
> study up a bit more on those topics. The issue with using C++ is that
> everything has to be done in detail, and there are no simple ways to attach
> a TX to (say) a sink object as easily as it can be done in GRC or even
> Python, but maybe I am wrong. That is why I was first looking for a GRC

I suppose the idea is that the complication is hidden in the block. and
grc is just the connections

> example. I thought I saw some kind of "valve" object in someone's GRC code
> (I think it was Sivan Toledo) that turned off and on transmission, but I
> couldn't find any details about that object.

Valve wont actually do the stream tags. If you abruptly stop streaming,
the device just goes into underflow. Its quick and dirty, but you cant
do rapid switching in and out of transmit mode like that.

> 
> The Python example you sent me looks interesting, but it looks like it will
> take some work to figure out how to tag the streams using their library. Do
> you recall if there are any actual examples in GRC or Python that can tag
> streams without installing extra libraries? Are the Pre-Cog libraries the
> only way to do it in Python?
> 

Its using the grextras library for the python support:
https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide

See coding guide
https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide#wiki-stream-tags

Some of this should be available in mainline gnuradio w/o grextras installed

> Finally, what method do you think would be better (assuming I am able to
> figure it out), C++ or Python or GRC (assuming we can do it in GRC).
> 

Python is always faster to prototype in and such. :-)

-josh

> Thanks very much for your help!
> 
> --Bill
> 
> 
> 
> 
> On Mon, Jan 7, 2013 at 1:01 PM, Josh Blum <address@hidden> wrote:
> 
>> Bill,
>>
>> You may want to checkout how stream tags are used to control transmit:
>>
>> http://gnuradio.org/cgit/gnuradio.git/tree/gr-uhd/include/gr_uhd_usrp_sink.h#n52
>>
>> C++ example
>> http://gnuradio.org/cgit/gnuradio.git/tree/gr-uhd/examples/c++/
>>
>> Python examples:
>> https://github.com/jmalsbury/pre-cog/wiki
>>
>> -josh
>>
>> On 01/07/2013 11:53 AM, Bill Peter wrote:
>>> Hi, I am really new to Gnuradio, and I want to play with using the USRP
>>> N210 (or two USRP N210s) for transmission and reception. Basically, I
>> want
>>> to transmit a sinusoidal signal (say at 1 GHz)  for a few seconds, have
>> the
>>> signal interact with an external coil, and then put the system in a
>>> receiver mode to listen to what is sent back. I have a USRP N210, and can
>>> probably get one more.
>>>
>>> What I would really like is some kind of example that does this in GRC,
>> but
>>> as far as I could tell when I make a USRP in GRC, there is no way to turn
>>> off the transmission after a given amount of time or samples (like it
>> seems
>>> you can do in C++ or Python). Does someone have some kind of example in
>> GRC
>>> I can look at of sending a finite pulse from the USRP in transmission
>> mode
>>> and then stopping to wait for any reception?
>>>
>>> Here are some of the things I have done to try to figure out how to do
>>> that. They don't look very promising:
>>>
>>> 1. I changed tx_waveforms.cpp so that it only sends a few samples like
>> this:
>>>
>>>    size_t num_acc_samps = 0 ;  // number of accumulated samples
>>>     size_t total_num_samps = 10 ;
>>>     //send data for a given number of samples
>>>     while(num_acc_samps < total_num_samps){
>>>
>>>         size_t samps_to_send = std::min(total_num_samps - num_acc_samps,
>>> buff.size());
>>>
>>>         //fill the buffer with the waveform
>>>         for (size_t n = 0; n < buff.size(); n++){
>>>             buff[n] = wave_table(index += step);
>>>         }
>>>
>>>         //send the entire contents of the buffer
>>>         //tx_stream->send(buffs, buff.size(), md);
>>>
>>>         //send the "samps_to_send" number of samples in the buffer
>>>   size_t num_tx_samps = tx_stream->send(buffs, samps_to_send, md);
>>>
>>>         md.start_of_burst = false;
>>>         md.has_time_spec = false;
>>>
>>>         if (num_tx_samps < samps_to_send) std::cerr << "Send timeout..."
>> <<
>>> std::endl;
>>>         //if(verbose) std::cout << boost::format("Sent packet: %u
>> samples")
>>> % num_tx_samps << std::endl;
>>>
>>>         num_acc_samps += num_tx_samps;
>>>
>>>     }
>>>
>>>     //send a mini EOB packet
>>>     md.end_of_burst = true;
>>>     tx_stream->send("", 0, md);
>>>
>>> I think this worked (I just bought a cheap scope but haven't used it yet
>> to
>>> really check), but the problem with this is that now I have to figure out
>>> how to stop, and do a receive. I really don't understand all the C++ code
>>> in the repository, and I am afraid it might take me too long.
>>>
>>> 2. As another test, I changed the dial_tone.py example as a very simple
>> way
>>> to start and stop transmission but it didn't seem to work. The usual case
>>> using the method tb.run() worked fine and I heard the dial tone. I
>> thought
>>> I could just change the Python so that it stops, and if it does, I will
>>> replace the audio sink with a USRP. Here is how the audio sink code looks
>>> like:
>>>
>>>  class my_top_block(gr.top_block):
>>>  def __init__(self):
>>>  gr.top_block.__init__(self)
>>>
>>>  sample_rate = 44100
>>> ampl = 0.1
>>>
>>>  src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, ampl)
>>>  src1 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, ampl)
>>>  dst = audio.sink (sample_rate, "")
>>>  # now connect the output of src0 to the first input of dst (audio sink)
>>>  self.connect (src0, (dst, 0))
>>> # now connect the output of src1 to the first input of dst (audio sink)
>>>  self.connect (src1, (dst, 1))
>>>
>>> if __name__ == '__main__':
>>>> try:
>>>>  #my_top_block().run()   # comment this out so as to start and stop
>>>> instead of just running....
>>>>  my_top_block().start()
>>>> time.sleep(10)
>>>> my_top_block().stop()
>>>>  my_top_block().wait()  # if the graph is needed to run again
>>>>        # wait must be called after stop
>>>>  time.sleep(10)
>>>> my_top_block().start()
>>>> time.sleep(10)
>>>>  my_top_block().stop() # since it is assumed the graph will
>>>>       # not be run again, no need for wait()
>>>>  except [[KeyboardInterrupt]]:
>>>> pass
>>>>  I got this idea of starting for ten secs, and then stopping for ten
>>>> seconds, and then continuing from one of the tutorials. So here's the
>>>> problem: I didn't hear the dial tone at all this time. However, the code
>>>> did do the right thing and stopped after 30 seconds (note the three
>>>> 10-second sleeps). So what happened to the dial tone--why couldn't I
>> hear
>>>> it? So this may not work when I substitute the audio sink for a USRP
>> sink,
>>>> correct?
>>>>
>>>
>>>
>>>  Thanks for any help! I am having difficulties in understanding all this
>>> and being able to transmit a sinusoidal wave for a few seconds, and then
>>> wait to receive any response on the RX side.
>>>
>>>
>>> --Bill Peter
>>>
>>>
>>>
>>> _______________________________________________
>>> Discuss-gnuradio mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>
> 
> 
> 



reply via email to

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