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
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio