discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] underrun occurs when frequency changing


From: Marcus D. Leech
Subject: Re: [Discuss-gnuradio] underrun occurs when frequency changing
Date: Sun, 11 Dec 2011 13:39:20 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 12/09/2011 03:42 PM, Yan Nie wrote:
Dear all,

I am trying to transmit a sequence at various frequencies on USRP N200 with 
LFTX.

When I use the uhd.single_usrp_source.set_center_freq() to change the frequency 
then insert the the sequence as a message in the msgq buffer in another thread 
other than top_block, underrun occurs. The amplitude of the transmitting signal 
on oscilloscope varies some, some of the signal have the full amplitude that I 
set, some of them only reach half amplitude. The following is the thread that I 
open for the sequence transmitting.

The mgq are created by:
data=gr.message_source(gr.sizeof_char, msg_limit)  #where msg_limit is defined 
as 2;
msgq = data.msgq()
transmit_loop(tb)

     repeat = 40
     payload_13barker = repeat * '\x01'
     payload_13barker += repeat * '\x01'
     payload_13barker += repeat * '\x01'
     payload_13barker += repeat * '\x00'
     payload_13barker += repeat * '\x00'

     stop_sign = 5*repeat*'\x02'
     i = 0
     while(i<5):
           payload_13barker += stop_sign
       i += 1
msg_13bit = gr.message_from_string(payload_13barker)
     tb._ls.msgq.insert_tail(msg_13bit)
     time.sleep(1.0)
     print "info inserted"
     while 1:
           freq_cnt = 4
           while (freq_cnt<  7):
                     i += 1
                     if i==40:     #this counter is used to slow down the rate 
the transmission frequency changes
                         i = 0
                         tx_freq = freq_cnt * 10e6
                         tb.set_freq_tx(tx_freq,0.0)
                         tb._ls.msgq.insert_tail(msg_13bit)
                         time.sleep(1.0)            # suspend to wait for the 
payload insert into buffer
                         freq_cnt += 1

I am curious
1. what causes the underrun and how to avoid the underrun?
2. How to defined the msgq_limit? Is the underrun cause by the wrongly set of 
the msgq_limit, as I already set to let the program to wait for buffering?

Really appreciate any of your suggestion!

Underrun is caused by your flow-graph not being able to provide samples to the hardware at the specified rate. It looks to me like in your flow-graph above, your message-queue can easily get starved for new bits, and so the entire flow-graph stalls. But that's just after a superficial inspection. Since you actually *go to sleep* for an entire second, it seems like it would be pretty easy for the flow-graph
  to stall.




--
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org





reply via email to

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