Reconfigure flow graph with scope app


#1

Hi -

I have a USRP with 2 RFX2400 daughter cards and need to calibrate the
local oscillator (LO) offset between them. To do this I want to
modify the multi_scope.py example to allow me to reconfigure the flow
graph without stopping. This is based on some external measurement I
will do followed by a keypress and possibly an input using raw_input().

After studying the example Python code fragment taken from the
“Controlling flow graphs” section of
http://gnuradio.org/trac/wiki/Tutorials/WritePythonApplicationshttp://gnuradio.org/trac/wiki/Tutorials/WritePythonApplications
I was able to run the code below.

#!/usr/bin/env python

from gnuradio import gr
from gnuradio import audio
import time

class my_top_block(gr.top_block):

 def __init__(self):

     gr.top_block.__init__(self)

     sampling_freq = 48000
     ampl = 0.1

     self.src0 = gr.sig_source_f(sampling_freq, gr.GR_SIN_WAVE, 350, 

ampl)
self.src1 = gr.sig_source_f(sampling_freq, gr.GR_SIN_WAVE, 440,
ampl)

     self.adder = gr.add_ff()
     self.sink = audio.sink(sampling_freq)

     self.amp = gr.multiply_const_ff(1) # Define multiplier block

     self.connect(self.src0, (self.adder, 0))
     self.connect(self.src1, (self.adder, 1))

     self.connect(self.adder, self.amp, self.sink) # Connect all 

blocks

 def set_volume(self, volume):
     self.amp.set_k(volume)
     print "volume changed to", volume

if name == ‘main’:

 app = my_top_block()
 app.start()
 raw_input ('Press Enter to change volume: ')
 app.set_volume(2) # Pump up the volume (by factor 2)
 raw_input ('Press Enter to stop: ')
 app.stop()

end of simple code

I need help because the statements in the multi_scope.py script are
more complicated. They are:

def main ():
app = stdgui2.stdapp(my_top_block, “Multi Scope”, nstatus=1)
app.MainLoop()

if name == ‘main’:
main ()

How can I run the scope app with a keypress and possibly an input
using raw_input()?

Thank you in advance for your help.

  • Larry Wagner

#2

On Sun, Jan 25, 2009 at 11:34:34PM -0800, Larry Wagner wrote:

Hi -

I have a USRP with 2 RFX2400 daughter cards and need to calibrate the
local oscillator (LO) offset between them. To do this I want to modify
the multi_scope.py example to allow me to reconfigure the flow graph
without stopping. This is based on some external measurement I will do
followed by a keypress and possibly an input using raw_input().

Larry,

If the 2 RFX2400 cards are attached to the same USRP, there will be no
LO offset between them. They are driven by a common ref clock provided
by the USRP motherboard.

Eric


#3

Hi Eric -

Thank you for your reply. I incorrectly used the wording offset
between the 2 daughter cards where I meant to say that the absolute
offset (of the 2 daughter cards) is unknown at the start of a run.
This has been observed after many experiments so far with my
interferometer like project and causes a run to run inconsistency.

I have worked out a calibration procedure where I begin with a known
geometry (transmitter to receiver placement) and observe the scope;
and then reconfigure the flow graph by a keypress without stopping
the app. This will be accomplished by use of “app.set_volume()” in
the main program and a “def set_volume(self, volume):” in the flow
graph that includes the scope as a sink.

The modifications to the main part of multi_scope.py that I have
tried are below. When I run this I get a scope but do not get the
prompt in the terminal window. When I click on the close window of
the scope window I do get the prompt.

def main ():
app = stdgui2.stdapp (test_top_block, “O’Scope Test App”)
app.MainLoop ()
raw_input (‘Press Enter to end CALIBRATE and start RUN (amplify x
now):’)
raw_input ('Press Enter to stop: ')
app.stop()

if name == ‘main’:
main ()

----------------------------------------------------------------

Take care,

  • Larry