USRP Software Radio

cancel
Showing results for 
Search instead for 
Did you mean: 

Two-way-ranging using USRP n210

Solved!
Go to solution

Hi all,

I'm trying to do a two-way-ranging using the USRP n210. To be able to do that, I will need to know the exact time that the samples were sent and the time that I received it back.
Trying to implement that I want to use 2 USRPs connected together.
(USRP A)              (USRP B)
tx <----------------- rx
rx -----------------> tx

For testing porpuses firstly I used a single USRP connecting the RX and TX together. Using a simple flow graph in the GRC I output an impulse (using the vector source) and at the same time I stored everything from the USRP input in a file (using the File Sink block). To compare the results I also used a File Sink block in the output.

Testing again and again the difference between the moment where I start the code and the moment where the impulse arrives at the RX looks like there is some kind of random delay. The difference between sending and receiving back the impulse fluctuates around 8000 ~ 10000 samples. Because I'm using just one USRP with RX and TX connected together I though that this delay should be almost zero.

There is any better way to implement this in which I can get a better accuracy in the time-stamping?

0 Kudos
Message 1 of 7
(6,504 Views)

Hi Rafael,

 

Can you post some of the code you are using to perform this action.  Maybe including some results as well.  It would greatly help in troubleshooting.

 

-Jim B
Applications Engineer, National Instruments
CLD, CTD
0 Kudos
Message 2 of 7
(6,481 Views)

Here are my results.

 

One of the files is my flow graph using GNU Radio Companion.
The other one is the plot of the files that I stored using "File Sink" (The blue line is the data that I'm sending, the red line is the data that I'm receiving).

The difference between the first 2 impulses are  19662 samples.

I'm using a sampling rate of 10M.

USRP connection:


|------------------|

|                  rx |<--,

|  USRP         |     |

|                  tx |----'

|------------------|

Download All
0 Kudos
Message 3 of 7
(6,476 Views)

Hey Rafael,

 

Since you are using an Ettus USRP with GNU Radio Companion, it might be easier for you to reach out to Ettus support here:

http://www.ettus.com/support

 

There are members of this forum that have experience with this kind of thing, but I am not one of them.  Maybe one of them will chime in.

-Jim B
Applications Engineer, National Instruments
CLD, CTD
0 Kudos
Message 4 of 7
(6,463 Views)
Solution
Accepted by topic author rafael.acurcio

One solution that helped me to solve my problem was using the following code in the python code generated by the GNU companion:

        now = self.uhd_usrp_sink_0.get_time_now()                                    #Store the actual time of the FPGA
        self.uhd_usrp_source_0.set_start_time(uhd.time_spec_t(1) + now)    #Set the source to start 1 second after the actual time of the FPGA
        self.uhd_usrp_sink_0.set_start_time(uhd.time_spec_t(1) + now)        #Set the sink to start 1 second after the actual time of the FPGA

 

That way both, tx and rx, will start at the same moment.

Message 5 of 7
(6,407 Views)

Hey, Thanks for posting your code. I am trying to utilize SDRs to implement two-way ranging as well. How much progress has you been able to make? Specifically, are you able to transmit a signal at a specific time after you receive the signal?

0 Kudos
Message 6 of 7
(3,357 Views)

You are the man!!!

0 Kudos
Message 7 of 7
(449 Views)