Noob questions on transmitting a finite pulse, waiting, and then starting to receive

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.

  1. 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’:

time.sleep(10)
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

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 T.) 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:

See coding guide

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. :slight_smile:

-josh