Forum: GNU Radio reconfigure flow graph with scope app

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
746d0b72b95b0d1a0b620ab0e472836f?d=identicon&s=25 Larry Wagner (Guest)
on 2009-01-26 20:21
(Received via mailing list)
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/WritePytho...
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
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-01-27 00:51
(Received via mailing list)
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
746d0b72b95b0d1a0b620ab0e472836f?d=identicon&s=25 Larry Wagner (Guest)
on 2009-01-27 07:22
(Received via mailing list)
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
This topic is locked and can not be replied to.