Transmission time control from python level

I have three USRP’s and I want them to transmit a continuous stream of
repeated GLFSR source in non-overlapping manner. In other words, each
transmitter will transmit the source for 1 second and then pause for 5
seconds. All transmitters will transmit during the ‘odd’ seconds so that
there is a 1 second gap between the sources. This process should
continue
for ever.

Currently, I am controlling the starting and stopping time of the flow
graphs to achieve my goals. Unfortunately, the code/flowgraph sometimes
hangs after 15-20 starts. I am using the following code:


tb = GLFSR_transmitter() # The Tx flowgraph : GLFSR source (float) -->
RRC filter --> USRP Sink

var = 1

while var == 1: # This process should run forever

 time.sleep(1-time.time() + int(time.time()))

 condition = ((int(time.time())%6) == 0)       # The transmitter 

will
transmit after every 6 seconds

 if (condition):

      print time.time()

      tb.start()

      sleep(1)      # The transmitter runs for 1 second

      tb.stop()

      tb.wait()

My USRP’s don’t seem to like this frequent starting and stopping of flow
graphs, especially when I am transmitting at 15-20 MS/s rate. I am using
USRP N210 (SBX daughterboards) and the latest gnuradio images. What
other
things can I do to achieve this timing control? I am looking for options
in
python level since my C++ OOP background is not strong. Josh talked
about
some python based blocks (
ttps://github.com/guruofquality/gnuradio/tree/python_blocks2https://github.com/guruofquality/gnuradio/tree/python_blocks2)
in
(http://old.nabble.com/How-to-implement-a-TDMA-system-td33727749.html).
They seem to be merged to the master (
http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/f8581fb475267e1a97eaab962e423559fb4bfce2)
but I can’t find the blocks.

Any suggestion will be appreciated.

Thanks,

Nazmul


Muhammad Nazmul I.

Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.

On 07/07/2012 09:30 AM, Nazmul I. wrote:

 condition = ((int(time.time())%6) == 0)       # The transmitter will
      tb.stop()

      tb.wait()

You really dont want to stop and start the flow graph. TX streams can be
controlled with stream tags. Links to header docs and example here:
http://code.ettus.com/redmine/ettus/projects/uhd/wiki/GNU_Radio_UHD#Using-UHD-with-GNU-Radio

but I can’t find the blocks.

All that stuff + instructions and coding guide can be found here
https://github.com/guruofquality/grextras/wiki

-josh

Hi Josh,

Thanks a lot for your reply. Can I control the TX stream from the GRC
generated python code? In other words, can I change the UHD:USRP
source/sink parameters to set up the time stamps or controlling the
scheduling?

Thanks,

Nazmul

On Sun, Jul 8, 2012 at 12:30 AM, Josh B. [email protected] wrote:

Currently, I am controlling the starting and stopping time of the flow

https://github.com/guruofquality/gnuradio/tree/python_blocks2>)
https://github.com/guruofquality/grextras/wiki

-josh


Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Muhammad Nazmul I.

Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.

Sorry for the previous email. I mistakenly hit the sent button before
completing the mail. Here is the complete mail:

Is it possible to see the time through USRP GPSDO with
microsecond/millisecond granularity? I want to synchronize the timing of
my
computers and run gnuradio codes based on the synchronized timing.

For example, if I have ethernet based internet connection, I can use ntp
servers to synchronize the computers and read the time (using
“time.time()”) with milisecond granularity. I am trying attain the same
thing using GPSDO. I am using the following python code.


class TimeFind :


self.uhd_usrp_source_0 = uhd.usrp_source(
device_addr="",
stream_args=uhd.stream_args(
cpu_format=“fc32”,
args=“peak=0.5”,
channels=range(1),
),
)


if name == ‘main’:

tb = TimeFind()

print “current time :” , tb.uhd_usrp_source_0.get_time_now()
print “last pps time :” , tb.uhd_usrp_source_0.get_time_last_pps()
print "GPS Time: " ,
tb.uhd_usrp_source_0.get_mboard_sensor(“gps_time”).to_int()
tb.Run(True)


I have the following issues:

  1. The current time and last pps time show the following output:

current time : <gnuradio.uhd.uhd_swig.time_spec_t; proxy of <Swig Object
of
type ‘uhd::time_spec_t *’ at 0x331fcf0> >
last pps time : <gnuradio.uhd.uhd_swig.time_spec_t; proxy of <Swig
Object
of type ‘uhd::time_spec_t *’ at 0x331fcf0> >

How can I get the time value?

  1. "GPS Time: " shows the time with 1 second granularity. Can I get
    higher
    resolution that 1 second? Is there an option that allows to see the
    exact
    time instead of the integer time?

I am sorry if these questions were asked before. I am trying to do these
from GRC based python codes.

Any help will be appreciated.

Thanks,

Nazmul

On Fri, Jul 27, 2012 at 1:15 PM, Nazmul I.
[email protected]wrote:

thing using GPSDO. I am using the following python code.
channels=range(1),

IIRC, one of the stream tags examples already implements the
[email protected]n.invalid] *On Behalf

repeated GLFSR source in non-overlapping manner. In other words, each

will
tb.stop()


Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.****


Muhammad Nazmul I.

Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.

Timestamps (tx_time), start-of-burst (tx_sob) and end-of-burst (tx_eob)
tags have to be affixed to samples in the work function of an upstream
block (before the UHD sink block). The UHD sink block interprets these
stream tags and controls the USRP accordingly, but it doesn’t implement
the scheduling itself. Your upstream block needs to know how many
samples per 1-second burst (which obviously depends on your USRP sample
rate) and affix tx_time, tx_sob, and tx_eob tags to the correct samples.

IIRC, one of the stream tags examples already implements the
aforementioned algorithm. You just need to lift it and perhaps put it in
a new block in line with your GR/GRC processing chain.

Sean

From: [email protected]n.invalid
[mailto:[email protected]n.invalid] On
Behalf Of Nazmul I.
Sent: Thursday, July 12, 2012 7:00 AM
To: [email protected]
Cc: [email protected]
Subject: Re: [Discuss-gnuradio] Transmission time control from python
level

Hi Josh,

Thanks a lot for your reply. Can I control the TX stream from the GRC
generated python code? In other words, can I change the UHD:USRP
source/sink parameters to set up the time stamps or controlling the
scheduling?

Thanks,

Nazmul
On Sun, Jul 8, 2012 at 12:30 AM, Josh B.
<[email protected]mailto:[email protected]> wrote:

On 07/07/2012 09:30 AM, Nazmul I. wrote:

 condition = ((int(time.time())%6) == 0)       # The transmitter will
      tb.stop()

      tb.wait()

You really dont want to stop and start the flow graph. TX streams can be
controlled with stream tags. Links to header docs and example here:
http://code.ettus.com/redmine/ettus/projects/uhd/wiki/GNU_Radio_UHD#Using-UHD-with-GNU-Radio

but I can’t find the blocks.

All that stuff + instructions and coding guide can be found here
https://github.com/guruofquality/grextras/wiki

-josh


Discuss-gnuradio mailing list
[email protected]mailto:[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Muhammad Nazmul I.

Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.

On 07/27/2012 10:24 AM, Nazmul I. wrote:

Sorry for the previous email. I mistakenly hit the sent button before
completing the mail. Here is the complete mail:

Is it possible to see the time through USRP GPSDO with
microsecond/millisecond granularity? I want to synchronize the timing of my
computers and run gnuradio codes based on the synchronized timing.

When synchronized to a common clock reference and time, a group of USRPs
can perform actions simultaneously with accuracy down the the jitter of
GPSDO ref clock + clock synthesizer chain.

For example, if I have ethernet based internet connection, I can use ntp
servers to synchronize the computers and read the time (using
“time.time()”) with milisecond granularity. I am trying attain the same
thing using GPSDO. I am using the following python code.

the “magic” of the GPSDO and time synchronization is that there is a
shared “pulse” aka PPS. This pulse is used to latch a time value into
the FPGA at a very specific moment. From that point on, a group of usrps
share the same concept of time.

            channels=range(1),

print “current time :” , tb.uhd_usrp_source_0.get_time_now()

current time : <gnuradio.uhd.uhd_swig.time_spec_t; proxy of <Swig Object of
type ‘uhd::time_spec_t *’ at 0x331fcf0> >
last pps time : <gnuradio.uhd.uhd_swig.time_spec_t; proxy of <Swig Object
of type ‘uhd::time_spec_t *’ at 0x331fcf0> >

How can I get the time value?
see member functions:
http://files.ettus.com/uhd_docs/doxygen/html/classuhd_1_1time__spec__t.html

  1. "GPS Time: " shows the time with 1 second granularity. Can I get higher
    resolution that 1 second? Is there an option that allows to see the exact
    time instead of the integer time?

GPS time in seconds is actually a blocking call that waits until the
seconds increments to return you the time. That way you know very
precisely that the next pulse will be time_read + 1 seconds.

-josh

Thanks a lot, Josh. I tried to use the time_spec_t class in the GRC
generated python code through the following way:

class TimeFind(grc_wxgui.top_block_gui):

self.time_spec_t = uhd.time_spec_t(0)

if name == ‘main’:

tb = TimeFind()
var = 1
tb.start()
while var == 1:
sleep(0.1)
print “current fractional time :” ,
tb.time_spec_t.get_frac_secs()
print "System time: " , tb.time_spec_t.get_system_time()
print "full sec: " , tb.time_spec_t.get_full_secs()
print "real second: " , tb.time_spec_t.get_real_secs()
tb.stop()


Basically, My code produces the following output:

current fractional time : 0.0
System time: <gnuradio.uhd.uhd_swig.time_spec_t; proxy of <Swig Object
of
type ‘uhd::time_spec_t *’ at 0x34fbe10> >
full sec: <Swig Object of type ‘time_t *’ at 0x34fbe10>swig/python
detected a memory leak of type ‘time_t *’, no destructor found.

real second: 0.0

Unfortunately, this same output is displayed repeatedly. I am not sure
why
the time does not change. Is there any other command that will keep
printing/pulling the recent time after 10 ms (1 ms)?

Thanks,

Nazmul

On Fri, Jul 27, 2012 at 2:07 PM, Josh B. [email protected] wrote:


of type ‘uhd::time_spec_t *’ at 0x331fcf0> >


Muhammad Nazmul I.

Graduate Student
Electrical & Computer Engineering
Wireless Information & Networking Laboratory
Rutgers, USA.

Unfortunately, this same output is displayed repeatedly. I am not sure why
the time does not change. Is there any other command that will keep
printing/pulling the recent time after 10 ms (1 ms)?

time_spec is a stuct that holds integer time and fractional time for
high precision. Nothing more. So uhd.time_spec_t(0) will always be zero.

-josh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs