From 54d6b9281dc233e0b2acf26884073d973b7663de Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Tue, 4 Sep 2007 02:43:56 +0000
Subject: Merged r6271:6278 from jcorgan/t182 into trunk.  Implements
 ticket:182.

Created new top-level component, gr-utils, to hold commonly used utility
scripts (originally in gnuradio-examples).  These now install into the
system path, allowing their use from wherever.

Reorganization of gnuradio-examples component:

 * Commonly used utility scripts moved from python/usrp into gr-utils.
 * Examples now install into $(prefix)/share/gnuradio/examples/...
 * Channel coding examples moved into gr-trellis/src/examples, now install
   from there, only if gr-atsc itself is going to built and installed.
 * ATSC example scripts now install into example hierarchy
 * Cruft has been moved into 'limbo' in repository, do not get installed

Trunk passes 'make distcheck'.



git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6279 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gnuradio-examples/python/usrp/limbo/am_rcv.py      | 115 ++++++++++++++
 gnuradio-examples/python/usrp/limbo/ayfabtu.dat    | Bin 0 -> 544640 bytes
 gnuradio-examples/python/usrp/limbo/ayfabtu.py     | 169 +++++++++++++++++++++
 .../python/usrp/limbo/flexrf_debug.py              | 169 +++++++++++++++++++++
 .../python/usrp/limbo/flexrf_siggen.py             | 148 ++++++++++++++++++
 gnuradio-examples/python/usrp/limbo/siggen_min2.py |  62 ++++++++
 .../python/usrp/limbo/test_dft_analysis.py         |  72 +++++++++
 .../python/usrp/limbo/test_dft_synth.py            |  79 ++++++++++
 .../python/usrp/limbo/tvrx_am_rcv_gui.py           | 154 +++++++++++++++++++
 .../python/usrp/limbo/usrp_fft_old.py              | 110 ++++++++++++++
 10 files changed, 1078 insertions(+)
 create mode 100755 gnuradio-examples/python/usrp/limbo/am_rcv.py
 create mode 100644 gnuradio-examples/python/usrp/limbo/ayfabtu.dat
 create mode 100755 gnuradio-examples/python/usrp/limbo/ayfabtu.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/flexrf_debug.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/flexrf_siggen.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/siggen_min2.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/test_dft_analysis.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/test_dft_synth.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/tvrx_am_rcv_gui.py
 create mode 100755 gnuradio-examples/python/usrp/limbo/usrp_fft_old.py

(limited to 'gnuradio-examples/python/usrp/limbo')

diff --git a/gnuradio-examples/python/usrp/limbo/am_rcv.py b/gnuradio-examples/python/usrp/limbo/am_rcv.py
new file mode 100755
index 0000000000..2908dcbf54
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/am_rcv.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, eng_notation
+from gnuradio import audio
+from gnuradio import usrp
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import sys
+import math
+
+from gnuradio.wxgui import stdgui, fftsink
+import wx
+
+class am_rx_graph (stdgui.gui_flow_graph):
+    def __init__(self,frame,panel,vbox,argv):
+        stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv)
+
+        station = parseargs(argv[1:])
+        offset_freq = 30e3
+        IF_freq = offset_freq - station
+
+        adc_rate = 64e6
+        usrp_decim = 250
+        if_rate = adc_rate / usrp_decim               # 256 kHz
+        if_decim = 4
+        demod_rate = if_rate / if_decim        # 64 kHz
+        audio_decimation = 2
+        audio_rate = demod_rate / audio_decimation  # 16 kHz
+        
+        # usrp is data source
+        src = usrp.source_c (0, usrp_decim)
+        src.set_rx_freq (0, IF_freq)
+        actual_IF_freq =src.rx_freq(0)
+        actual_offset = actual_IF_freq + station
+        
+        #print actual_IF_freq
+        #print actual_offset
+ 
+        src.set_pga(0,20)
+        # sound card as final sink
+        audio_sink = audio.sink (int (audio_rate))
+        
+        channel_coeffs = \
+                       gr.firdes.low_pass (1.0,           # gain
+                                           if_rate,   # sampling rate
+                                           9e3,         # low pass cutoff freq
+                                           10e3,         # width of trans. band
+                                           gr.firdes.WIN_HANN)
+
+        ddc =  gr.freq_xlating_fir_filter_ccf (if_decim,channel_coeffs,-actual_offset,if_rate)
+
+        magblock = gr.complex_to_mag()
+        volumecontrol = gr.multiply_const_ff(.003)
+
+        # Deemphasis.  Is this necessary on AM?
+        TAU  = 75e-6  # 75us in US, 50us in EUR
+        fftaps = [ 1 - math.exp(-1/TAU/if_rate), 0]
+        fbtaps= [ 0 , math.exp(-1/TAU/if_rate) ]
+        
+        deemph = gr.iir_filter_ffd(fftaps,fbtaps)
+
+        # compute FIR filter taps for audio filter
+        width_of_transition_band = audio_rate / 8
+        audio_coeffs = gr.firdes.low_pass (1.0,            # gain
+                                           if_rate,      # sampling rate
+                                           9e3,         #audio_rate/2 - width_of_transition_band,
+                                           4e3,         # width_of_transition_band,
+                                           gr.firdes.WIN_HANN)
+        
+        # input: float; output: float
+        audio_filter = gr.fir_filter_fff (audio_decimation, audio_coeffs)
+
+
+
+        
+        print len(channel_coeffs)
+        print len(audio_coeffs)
+        
+        # now wire it all together
+        self.connect (src, ddc)
+        self.connect (ddc, magblock)
+        self.connect (magblock, volumecontrol)
+        self.connect (volumecontrol,deemph)
+        self.connect (deemph,audio_filter)
+        self.connect (audio_filter, (audio_sink, 0))
+
+        if 1:
+            pre_demod = fftsink.fft_sink_c (self, panel, title="Pre-Demodulation", fft_size=128, sample_rate=if_rate)
+            self.connect (src, pre_demod)
+            vbox.Add (pre_demod.win, 1, wx.EXPAND)
+
+        if 0:
+            post_demod = fftsink.fft_sink_c (self, panel, title="Post Demodulation", fft_size=256, sample_rate=demod_rate)
+            self.connect (ddc, post_demod)
+            vbox.Add (post_demod.win, 1, wx.EXPAND)
+
+        if 0:
+            post_filt = fftsink.fft_sink_f (self, panel, title="Post Filter", fft_size=512, sample_rate=audio_rate)
+            self.connect (magblock,post_filt)
+            vbox.Add (post_filt.win, 1, wx.EXPAND)
+        
+def parseargs (args):
+    nargs = len (args)
+    if nargs == 1:
+        freq1 = float (args[0]) * 1e3
+    else:
+        sys.stderr.write ('usage: am_rcv freq1\n')
+        sys.exit (1)
+
+    return freq1
+
+if __name__ == '__main__':
+    app = stdgui.stdapp (am_rx_graph, "AM RX")
+    app.MainLoop ()
+
diff --git a/gnuradio-examples/python/usrp/limbo/ayfabtu.dat b/gnuradio-examples/python/usrp/limbo/ayfabtu.dat
new file mode 100644
index 0000000000..5c65cf4833
Binary files /dev/null and b/gnuradio-examples/python/usrp/limbo/ayfabtu.dat differ
diff --git a/gnuradio-examples/python/usrp/limbo/ayfabtu.py b/gnuradio-examples/python/usrp/limbo/ayfabtu.py
new file mode 100755
index 0000000000..de6c26f58a
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/ayfabtu.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+#
+# Copyright 2005 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+#
+# All Your Frequencies are Belong to Us!
+#
+#   Transmit NBFM message on 25 channels simultaneously!
+#
+
+from gnuradio import gr, gru, eng_notation
+from gnuradio import usrp
+from gnuradio import audio
+from gnuradio import blks
+from gnuradio import optfir
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import math
+import sys
+import random
+
+from gnuradio.wxgui import stdgui, fftsink
+import wx
+
+
+def make_random_complex_tuple(L):
+    result = []
+    for x in range(L):
+        result.append(complex(random.gauss(0, 1),random.gauss(0, 1)))
+                      
+    return tuple(result)
+
+def random_noise_c():
+    src = gr.vector_source_c(make_random_complex_tuple(32*1024), True)
+    return src
+
+
+def plot_taps(taps, sample_rate=2):
+    return gru.gnuplot_freqz (gru.freqz (taps, 1), sample_rate)
+    
+
+class ayfabtu_graph (stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
+
+        parser = OptionParser (option_class=eng_option)
+        parser.add_option ("-c", "--duc-freq", type="eng_float", default=29.325e6,
+                           help="set Tx ddc frequency to FREQ", metavar="FREQ")
+        (options, args) = parser.parse_args ()
+
+        nchan = 25
+        IF_GAIN = 80000
+        AUDIO_GAIN = 100
+        
+        self.dac_rate = 128e6
+        self.usrp_interp = 256
+        self.usrp_rate = self.dac_rate / self.usrp_interp    # 500 kS/s
+        self.audio_rate = 32000                              # 32 kS/s
+
+        self.audio_src = gr.file_source(gr.sizeof_float, "ayfabtu.dat", True)
+
+        ahp_taps = gr.firdes.high_pass(1,     # gain
+                                       32e3,  # Fs
+                                       300,   # cutoff
+                                       600,   # trans width
+                                       gr.firdes.WIN_HANN)
+        self.audio_hp = gr.fir_filter_fff(1, ahp_taps)
+
+        self.audio_gain = gr.multiply_const_ff(AUDIO_GAIN)
+
+        null_src = gr.null_source(gr.sizeof_gr_complex)
+        #noise_src = gr.noise_source_c(gr.GR_UNIFORM, 1, 0)
+        noise_src = random_noise_c()
+
+        if 0:
+            artaps = optfir.low_pass(1,       # gain
+                                     2,       # Fs
+                                     .75/32,  # freq1
+                                     1.0/32,  # freq2
+                                     1,       # pb ripple in dB
+                                     50,      # stopband atten in dB
+                                     2)       # + extra taps
+        else:
+            artaps = gr.firdes.low_pass(1,      # gain
+                                        32e3*15,# Fs
+                                        2.7e3,  # cutoff
+                                         .3e3,  # trans width
+                                        gr.firdes.WIN_HANN)
+        print "len(artaps) =", len(artaps)
+        self.audio_resampler = blks.rational_resampler_fff(self, 15, 32, artaps)
+
+        self.fm_mod = blks.nbfm_tx(self, 15000, 15000, max_dev=4.5e3)
+
+
+        fbtaps = gr.firdes.low_pass(1,                # gain
+                                    25*15e3,          # rate
+                                    13e3,             # cutoff
+                                    2e3,              # trans width
+                                    gr.firdes.WIN_HANN)
+        print "len(fbtabs) =", len(fbtaps)
+        #self.plot = plot_taps(fbtaps, 25*15e3)
+        self.filter_bank = blks.synthesis_filterbank(self, nchan, fbtaps)
+        
+        self.if_gain = gr.multiply_const_cc(IF_GAIN)
+
+        if 0:
+            ifrtaps = optfir.low_pass(1,
+                                      2,       # Fs
+                                      .75/3,   # freq1
+                                      1.0/3,   # freq2
+                                      1,       # pb ripple in dB
+                                      50,      # stopband atten in dB
+                                      2)       # + extra taps
+        else:
+            ifrtaps = gr.firdes.low_pass(1,
+                                         2,       # Fs
+                                         .75/3,   # freq1
+                                         .25/3,   # trans width
+                                         gr.firdes.WIN_HANN)
+
+
+        print "len(ifrtaps) =", len(ifrtaps)
+        self.if_resampler = blks.rational_resampler_ccf(self, 4, 3, ifrtaps)
+
+
+        self.u = usrp.sink_c(0, 256)
+        self.u.set_tx_freq(0, options.duc_freq)
+        self.u.set_pga(0, self.u.pga_max())
+
+        # wire it all together
+        
+        self.connect(self.audio_src, self.audio_hp, self.audio_gain,
+                     self.audio_resampler, self.fm_mod)
+
+        null_sink = gr.null_sink(gr.sizeof_gr_complex)
+
+        for i in range(nchan):
+            if True or i == 0:
+                self.connect(self.fm_mod, (self.filter_bank, i))
+            else:
+                self.connect(null_src, (self.filter_bank, i))
+
+        self.connect(self.filter_bank, self.if_gain, self.if_resampler, self.u)
+        
+
+def main ():
+    app = stdgui.stdapp (ayfabtu_graph, "All Your Frequency Are Belong to Us")
+    app.MainLoop ()
+
+if __name__ == '__main__':
+    main ()
diff --git a/gnuradio-examples/python/usrp/limbo/flexrf_debug.py b/gnuradio-examples/python/usrp/limbo/flexrf_debug.py
new file mode 100755
index 0000000000..13d1db110d
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/flexrf_debug.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+#
+# Copyright 2004 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr, gru
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui, fftsink, scopesink, slider
+from optparse import OptionParser
+import wx
+
+class app_flow_graph (stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
+
+        self.frame = frame
+        self.panel = panel
+        
+        parser = OptionParser (option_class=eng_option)
+        parser.add_option ("-d", "--decim", type="int", default=8,
+                           help="set fgpa decimation rate to DECIM")
+        parser.add_option ("-c", "--ddc-freq", type="eng_float", default=0,
+                           help="set Digital downconverter frequency to FREQ", metavar="FREQ")
+        parser.add_option ("-f", "--freq", type="eng_float", default=950e6,
+                           help="set RF downconverter frequency to FREQ", metavar="FREQ")
+        parser.add_option ("-m", "--mux", type="intx", default=0x32103210,
+                           help="set fpga FR_RX_MUX register to MUX")
+        parser.add_option ("-g", "--gain", type="eng_float", default=0,
+                           help="set Rx PGA gain in dB (default 0 dB)")
+        (options, args) = parser.parse_args ()
+
+        self.u = usrp.source_c (0, options.decim, 1, gru.hexint(options.mux), 0)
+        
+        self.u.set_verbose (0)
+        
+        input_rate = self.u.adc_freq () / self.u.decim_rate ()
+
+        block = fftsink.fft_sink_c (self, panel, fft_size=1024, sample_rate=input_rate)
+        self.connect (self.u, block)
+        vbox.Add (block.win, 10, wx.EXPAND)
+
+	if 0:
+            c2f_1 = gr.complex_to_float ()
+            scope = scopesink.scope_sink_f (self, panel, "Rx Data", input_rate)
+            vbox.Add (scope.win, 6, wx.EXPAND)
+
+            self.connect (self.u,c2f_1)
+            self.connect ((c2f_1, 0), (scope, 0))
+            self.connect ((c2f_1, 1), (scope, 1))
+
+        if 0:
+            rms_complex = gr.rms_cf(.0001)
+            rms_i = gr.rms_ff(.0001)
+            rms_q = gr.rms_ff(.0001)
+            
+            self.connect(self.u,rms_complex)
+            self.connect((c2f_1,0),rms_i)
+            self.connect((c2f_1,1),rms_q)
+            
+            ns1 = gr.null_sink(4)
+            ns2 = gr.null_sink(4)
+            ns3 = gr.null_sink(4)
+            
+            self.connect(rms_complex,ns1)
+            self.connect(rms_i,ns2)
+            self.connect(rms_q,ns3)
+
+        # sliders
+
+        #vbox.Add(slider.slider(panel, 0, 104, self.set_gain), 1, wx.ALIGN_CENTER)
+
+        #vbox.Add(slider.slider(panel, 0, 4095, self.set_gain_gc1), 1, wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, 0, 31, self.set_gain_gc2), 1, wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, 0, 1, self.set_gain_dl), 1, wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, 0, 200, self.set_gain_i), 1, wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, 0, 200, self.set_gain_q), 1, wx.ALIGN_CENTER)
+
+        self.offset = 0
+        #vbox.Add(slider.slider(panel, -200, 200, self.set_offset_i), 1, wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, -200, 200, self.set_offset_q), 1, wx.ALIGN_CENTER)
+
+        vbox.Add(slider.slider(panel, 380, 480, self.set_rf_freq), 1, wx.EXPAND|wx.ALIGN_CENTER)
+        vbox.Add(slider.slider(panel, -32000, +32000, self.set_if_freq), 1, wx.EXPAND|wx.ALIGN_CENTER)
+        vbox.Add(slider.slider(panel, 0, 4095, self.set_gain), 1, wx.EXPAND|wx.ALIGN_CENTER)
+
+        # build small control area at bottom
+        hbox = wx.BoxSizer (wx.HORIZONTAL)
+        hbox.Add ((1, 1), 1, wx.EXPAND)
+        hbox.Add (wx.StaticText (panel, -1, "Set ddc freq: "), 0, wx.ALIGN_CENTER)
+        self.tc_freq = wx.TextCtrl (panel, -1, "", style=wx.TE_PROCESS_ENTER)
+        hbox.Add (self.tc_freq, 0, wx.ALIGN_CENTER)
+        wx.EVT_TEXT_ENTER (self.tc_freq, self.tc_freq.GetId(), self.handle_text_enter)
+        hbox.Add ((1, 1), 1, wx.EXPAND)
+        # add it to the main vbox
+        vbox.Add (hbox, 0, wx.EXPAND)
+
+        self.update_status_bar ()
+
+    def set_rf_freq (self,freq):
+        (success,actual_freq) = self.set_freq(1e6*freq)
+        if not success:
+            print "Failed on ",freq
+    def set_if_freq (self,freq):
+        self.u.set_rx_freq(0,freq*1e3)
+            
+    def set_gain (self,gain):
+        self.rfrx.set_gain(gain)
+
+    def set_gain_i (self,gain):
+        self.u.set_pga(0,gain/10.0)
+    def set_gain_q (self,gain):
+        self.u.set_pga(1,gain/10.0)
+
+    def set_offset_i(self,offset):
+        self.offset = (self.offset & 0x0000ffff) | ((offset&0xffff)<<16)
+        self.u._write_fpga_reg (3,self.offset)
+
+    def set_offset_q(self,offset):
+        self.offset = (self.offset & 0xffff0000) | (offset&0xffff)
+        self.u._write_fpga_reg (3,self.offset)
+
+    def handle_text_enter (self, event):
+        str = event.GetString ()
+        self.tc_freq.Clear ()
+        self.u.set_rx_freq (0, eng_notation.str_to_num (str))
+        self.update_status_bar ()
+
+    def update_status_bar (self):
+        ddc_freq = self.u.rx_freq (0)
+        decim_rate = self.u.decim_rate ()
+        sample_rate = self.u.adc_freq () / decim_rate
+        msg = "decim: %d  %sS/s  DDC: %s" % (
+            decim_rate,
+            eng_notation.num_to_str (sample_rate),
+            eng_notation.num_to_str (ddc_freq))
+            
+        self.frame.GetStatusBar().SetStatusText (msg, 1)
+
+    def set_gain(self,gain):
+        assert gain>=0 and gain<4096
+        self.u.write_aux_dac(0,0,int(gain))
+        
+def main ():
+    app = stdgui.stdapp (app_flow_graph, "USRP FFT")
+    app.MainLoop ()
+
+if __name__ == '__main__':
+    main ()
+
+
diff --git a/gnuradio-examples/python/usrp/limbo/flexrf_siggen.py b/gnuradio-examples/python/usrp/limbo/flexrf_siggen.py
new file mode 100755
index 0000000000..6a59148b88
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/flexrf_siggen.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru
+from gnuradio import usrp
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+from gnuradio.wxgui import stdgui, slider
+import wx
+
+class flex_siggen (stdgui.gui_flow_graph):
+    __slots__ = ['interp', 'waveform_type', 'waveform_ampl',
+                 'waveform_freq', 'waveform_offset', 'fg', 'usrp',
+                 'siggen', 'noisegen', 'src', 'file_sink' ]
+
+    def __init__ (self,frame,panel,vbox,argv):
+        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
+        
+        self.frame = frame
+        self.panel = panel
+
+        parser = OptionParser (option_class=eng_option)
+        parser.add_option ("-a", "--amplitude", type="int", default=32000,
+                           help="amplitude")
+        parser.add_option ("-i", "--interp", type="int", default=64,
+                           help="set fpga interpolation rate to INTERP")
+        parser.add_option ("-n", "--nchannels", type="int", default=1,
+                           help="set number of output channels to NCHANNELS")
+        (options, args) = parser.parse_args ()
+
+        self.waveform_type = gr.GR_CONST_WAVE
+        self.waveform_ampl = options.amplitude
+        self.waveform_freq = 100.12345e3
+        self.waveform_offset = 0
+
+        self.interp = options.interp
+        self._instantiate_blocks ()
+        self.usrp.set_nchannels (options.nchannels)
+        
+        self.dboard=self.usrp.db[0][0]
+        
+        self.set_waveform_type (self.waveform_type)
+        vbox.Add(slider.slider(panel, 390, 510, self.set_rf_freq), 1, wx.EXPAND|wx.ALIGN_CENTER)
+        vbox.Add(slider.slider(panel, -45000, +45000, self.set_if_freq), 1, wx.EXPAND|wx.ALIGN_CENTER)
+        #vbox.Add(slider.slider(panel, 0, 4095, self.set_gain), 1, wx.EXPAND|wx.ALIGN_CENTER)
+        
+    def usb_freq (self):
+        return self.usrp.dac_freq() / self.interp
+
+    def usb_throughput (self):
+        return self.usb_freq () * 4
+        
+    def set_waveform_type (self, type):
+        '''
+        valid waveform types are: gr.GR_SIN_WAVE, gr.GR_CONST_WAVE,
+        gr.GR_UNIFORM and gr.GR_GAUSSIAN
+        '''
+        self._configure_graph (type)
+        self.waveform_type = type
+
+    def set_waveform_ampl (self, ampl):
+        self.waveform_ampl = ampl
+        self.siggen.set_amplitude (ampl)
+        self.noisegen.set_amplitude (ampl)
+
+    def set_waveform_freq (self, freq):
+        self.waveform_freq = freq
+        self.siggen.set_frequency (freq)
+        
+    def set_if_freq (self, freq):
+        self.if_freq = freq
+        self.usrp.set_tx_freq (0,freq*1e3)
+        
+    def set_rf_freq (self, freq):
+        self.rf_freq = freq
+        (success,actual_freq) = self.dboard.set_freq (freq*1e6)
+        if not success:
+            print "Failed on ", freq
+            
+    def set_waveform_offset (self, offset):
+        self.waveform_offset = offset
+        self.siggen.set_offset (offset)
+
+    def set_interpolator (self, interp):
+        self.interp = interp
+        self.siggen.set_sampling_freq (self.usb_freq ())
+        self.usrp.set_interp_rate (interp)
+
+    def set_duc_freq (self, freq):
+        self.usrp.set_tx_freq (0, freq)
+        
+    def _instantiate_blocks (self):
+        self.src = None
+        self.usrp = usrp.sink_c (0, self.interp)
+        
+        self.siggen = gr.sig_source_c (self.usb_freq (),
+                                       gr.GR_SIN_WAVE,
+                                       self.waveform_freq,
+                                       self.waveform_ampl,
+                                       self.waveform_offset)
+
+        self.noisegen = gr.noise_source_c (gr.GR_UNIFORM,
+                                           self.waveform_ampl)
+        print "done"
+        
+    def _configure_graph (self, type):
+        was_running = self.is_running ()
+        if was_running:
+            self.stop ()
+        self.disconnect_all ()
+        if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
+            self.connect (self.siggen, self.usrp)
+            self.siggen.set_waveform (type)
+            self.src = self.siggen
+        elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
+            self.connect (self.noisegen, self.usrp)
+            self.noisegen.set_type (type)
+            self.src = self.noisegen
+        else:
+            raise ValueError, type
+        if was_running:
+            self.start ()
+
+
+if __name__ == '__main__':
+    parser = OptionParser (option_class=eng_option)
+    parser.add_option ("--sine", dest="type", action="store_const", const=gr.GR_SIN_WAVE,
+                       help="generate a complex sinusoid [default]", default=gr.GR_SIN_WAVE)
+    parser.add_option ("--const", dest="type", action="store_const", const=gr.GR_CONST_WAVE, 
+                       help="generate a constant output")
+    parser.add_option ("--gaussian", dest="type", action="store_const", const=gr.GR_GAUSSIAN,
+                       help="generate Gaussian random output")
+    parser.add_option ("--uniform", dest="type", action="store_const", const=gr.GR_UNIFORM,
+                       help="generate Uniform random output")
+    parser.add_option ("-f", "--freq", type="eng_float", default=100e3,
+                       help="set waveform frequency to FREQ")
+    parser.add_option ("-r", "--rf-freq", type="eng_float", default=910e6,
+                       help="set waveform frequency to FREQ")
+    parser.add_option ("-a", "--amplitude", type="eng_float", default=16e3,
+                       help="set waveform amplitude to AMPLITUDE", metavar="AMPL")
+    parser.add_option ("-o", "--offset", type="eng_float", default=0,
+                       help="set waveform offset to OFFSET")
+    parser.add_option ("-c", "--duc-freq", type="eng_float", default=0,
+                       help="set Tx DUC frequency to FREQ", metavar="FREQ")
+    parser.add_option ("-m", "--mux", type="intx", default=0x98,
+                       help="set output mux register")
+    
+    app = stdgui.stdapp (flex_siggen, "USRP FlexRF Siggen")
+    app.MainLoop ()
diff --git a/gnuradio-examples/python/usrp/limbo/siggen_min2.py b/gnuradio-examples/python/usrp/limbo/siggen_min2.py
new file mode 100755
index 0000000000..8709e3373f
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/siggen_min2.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+
+from gnuradio import gr
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+
+
+def build_graph ():
+
+    # interp = 32
+    interp = 64
+    nchan = 2
+    
+    if nchan == 1:
+        mux = 0x0098
+        #mux = 0x9800
+    else:
+        mux = 0xba98
+
+    f0 = 100e3
+    a0 = 16e3
+    duc0 = 5e6
+
+    f1 = 50e3
+    a1 = 16e3
+    duc1 = 7e6
+
+    fg = gr.flow_graph ()
+
+    u = usrp.sink_c (0, interp, nchan, mux)
+    sample_rate = u.dac_freq () / interp
+    print "sample_rate = ", eng_notation.num_to_str (sample_rate)
+    print "usb_sample_rate = ", eng_notation.num_to_str (sample_rate * nchan)
+
+    u.set_tx_freq (0, duc0)
+    u.set_tx_freq (1, duc1)
+
+    interleave = gr.interleave (gr.sizeof_gr_complex)
+    fg.connect (interleave, u)
+
+    src0 = gr.sig_source_c (sample_rate, gr.GR_SIN_WAVE, f0, a0, 0)
+    fg.connect (src0, (interleave, 0))
+
+    if nchan == 2:
+        if 1:
+            src1 = gr.sig_source_c (sample_rate, gr.GR_SIN_WAVE, f1, a1, 0)
+        else:
+            src1 = gr.noise_source_c (gr.GR_UNIFORM, a1)
+        fg.connect (src1, (interleave, 1))
+    
+    return fg
+
+
+if __name__ == '__main__':
+    fg = build_graph ()
+    fg.start ()
+    raw_input ('Press Enter to quit: ')
+    fg.stop ()
+
diff --git a/gnuradio-examples/python/usrp/limbo/test_dft_analysis.py b/gnuradio-examples/python/usrp/limbo/test_dft_analysis.py
new file mode 100755
index 0000000000..a1d9eda46c
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/test_dft_analysis.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, blks
+from gnuradio.wxgui import stdgui, fftsink, slider
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import wx
+
+class test_graph (stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__(self, frame, panel, vbox, argv)
+
+        parser = OptionParser (option_class=eng_option)
+        (options, args) = parser.parse_args ()
+
+        sample_rate = 16e3
+        mpoints = 4
+        ampl = 1000
+        freq = 0
+
+        lo_freq = 1e6
+        lo_ampl = 1
+        
+        vbox.Add(slider.slider(panel,
+                               -sample_rate/2, sample_rate/2,
+                               self.set_lo_freq), 0, wx.ALIGN_CENTER)
+
+
+        src = gr.sig_source_c(sample_rate, gr.GR_CONST_WAVE,
+                              freq, ampl, 0)
+
+        self.lo = gr.sig_source_c(sample_rate, gr.GR_SIN_WAVE,
+                                  lo_freq, lo_ampl, 0)
+
+        mixer = gr.multiply_cc()
+        self.connect(src, (mixer, 0))
+        self.connect(self.lo, (mixer, 1))
+        
+        # We add these throttle blocks so that this demo doesn't
+        # suck down all the CPU available.  Normally you wouldn't use these.
+        thr = gr.throttle(gr.sizeof_gr_complex, sample_rate)
+
+        taps = gr.firdes.low_pass(1,   # gain
+                                  1,   # rate
+                                  1.0/mpoints * 0.4,  # cutoff
+                                  1.0/mpoints * 0.1,  # trans width
+                                  gr.firdes.WIN_HANN)
+        print len(taps)
+        analysis = blks.analysis_filterbank(self, mpoints, taps)
+        
+        self.connect(mixer, thr)
+        self.connect(thr, analysis)
+
+        for i in range(mpoints):
+            fft = fftsink.fft_sink_c(self, frame, fft_size=128,
+                                     sample_rate=sample_rate/mpoints,
+                                     fft_rate=5,
+                                     title="Ch %d" % (i,))
+            self.connect((analysis, i), fft)
+            vbox.Add(fft.win, 1, wx.EXPAND)
+
+    def set_lo_freq(self, freq):
+        self.lo.set_frequency(freq)
+        
+                                     
+
+def main ():
+    app = stdgui.stdapp (test_graph, "Test DFT filterbank")
+    app.MainLoop ()
+
+if __name__ == '__main__':
+    main ()
diff --git a/gnuradio-examples/python/usrp/limbo/test_dft_synth.py b/gnuradio-examples/python/usrp/limbo/test_dft_synth.py
new file mode 100755
index 0000000000..60a49e3b37
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/test_dft_synth.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, blks
+from gnuradio.wxgui import stdgui, fftsink
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import wx
+import random
+
+
+def make_random_complex_tuple(L, gain=1):
+    result = []
+    for x in range(L):
+        result.append(gain * complex(random.gauss(0, 1),random.gauss(0, 1)))
+                      
+    return tuple(result)
+
+def random_noise_c(gain=1):
+    src = gr.vector_source_c(make_random_complex_tuple(32*1024, gain), True)
+    return src
+
+
+class test_graph (stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__(self, frame, panel, vbox, argv)
+
+        parser = OptionParser (option_class=eng_option)
+        (options, args) = parser.parse_args ()
+
+        sample_rate = 16e6
+        mpoints = 16
+        ampl = 1000
+        
+        enable = mpoints * [0]
+        enable[0] = 1
+
+        taps = gr.firdes.low_pass(1,   # gain
+                                  1,   # rate
+                                  1.0/mpoints * 0.4,  # cutoff
+                                  1.0/mpoints * 0.1,  # trans width
+                                  gr.firdes.WIN_HANN)
+
+        synth = blks.synthesis_filterbank(self, mpoints, taps)
+        
+        null_source = gr.null_source(gr.sizeof_gr_complex)
+        
+        if 0:
+            for i in range(mpoints):
+                s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE,
+                                    300e3, ampl * enable[i], 0)
+                self.connect(s, (synth, i))
+
+        else:
+            for i in range(mpoints):
+                if i == 0:
+                    s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE,
+                                        300e3, ampl * enable[i], 0)
+                    #s = random_noise_c(ampl)
+                    self.connect(s, (synth, i))
+                else:
+                    self.connect(null_source, (synth, i))
+            
+
+        # We add these throttle blocks so that this demo doesn't
+        # suck down all the CPU available.  Normally you wouldn't use these.
+        thr = gr.throttle(gr.sizeof_gr_complex, sample_rate)
+        fft = fftsink.fft_sink_c(self, frame, fft_size=1024,
+                                 sample_rate=sample_rate)
+        vbox.Add(fft.win, 1, wx.EXPAND)
+
+        self.connect(synth, thr, fft)
+
+
+def main ():
+    app = stdgui.stdapp (test_graph, "Test DFT filterbank")
+    app.MainLoop ()
+
+if __name__ == '__main__':
+    main ()
diff --git a/gnuradio-examples/python/usrp/limbo/tvrx_am_rcv_gui.py b/gnuradio-examples/python/usrp/limbo/tvrx_am_rcv_gui.py
new file mode 100755
index 0000000000..403cf3fa4d
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/tvrx_am_rcv_gui.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+#
+# Copyright 2004 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+#
+# Demodulate an AM signal from the TVRX or a recorded file.
+# The file format must be 256 ksps, complex data.
+#
+
+from gnuradio import gr, gru, eng_notation
+from gnuradio import audio_oss as audio
+from gnuradio import usrp
+from gnuradio import tv_rx
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import sys
+import math
+from gnuradio.wxgui import stdgui, fftsink, scopesink
+import wx
+
+#
+# return a gr.flow_graph
+#
+class wfm_rx_graph (stdgui.gui_flow_graph):
+  def __init__(self,frame,panel,vbox,argv):
+    stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv)
+    
+    #set rf freq
+    rf_freq = 120.e6
+    
+    # Decimation rate from USRP ADC to IF.
+    usrp_decim = 100
+    
+    # Calculate the sampling rate of the USRP and capture file.
+    # Decimate the IF sampling rate down by 4 to 64 ksps
+    # This is a flow graph that has an input (capture file) and output (audio channel).
+    #self = gr.flow_graph ()
+  
+    # Signal source is assumed to be 256 kspb / complex data stream.
+    which_side = 0
+    # usrp is data source
+    if which_side == 0:
+        src = usrp.source_c (0, usrp_decim, 1, gru.hexint(0xf0f0f0f0), 0)
+    else:
+        src = usrp.source_c (0, usrp_decim, 1, gru.hexint(0xf0f0f0f2), 0)
+
+    if_rate = 640e3 # src.adc_freq() / usrp_decim
+    if_decim = 5
+    demod_rate = if_rate / if_decim
+    
+    audio_decimation = 4
+    audio_rate = demod_rate / audio_decimation
+
+    # set up frontend
+    dboard = tv_rx.tv_rx (src, which_side)
+    self.dboard = dboard
+    (success, actual_freq) = dboard.set_freq(rf_freq)
+    assert success
+
+    if_freq = rf_freq - actual_freq
+    src.set_rx_freq (0, -if_freq)
+
+    print "actual freq ", actual_freq
+    print "IF freq ", if_freq
+        
+    dboard.set_gain(50)
+    
+    #src = gr.file_source (gr.sizeof_gr_complex, "samples/atis_ffz_am_baseband_256k_complex.dat")
+    #src = gr.file_source (gr.sizeof_gr_complex, "samples/garagedoor1.dat", True)
+    
+    #channel_coeffs = gr.firdes.band_pass (
+    #    1.0,    # gain
+    #    if_rate,
+    #    10,   # center of low transition band
+    #    10000,   # center of hi transition band
+    #    200,    # width of transition band
+    #    gr.firdes.WIN_HAMMING)
+    
+    channel_coeffs = gr.firdes.low_pass (1.0, if_rate, 10e3, 4e3, gr.firdes.WIN_HANN)
+    print "len(channel_coeffs) = ", len(channel_coeffs)
+
+    # Tune to the desired frequency.
+    ddc = gr.freq_xlating_fir_filter_ccf (if_decim, channel_coeffs, -20e3, if_rate)
+
+    # Demodule with classic sqrt (I*I + Q*Q)
+    magblock = gr.complex_to_mag()
+
+    # Scale the audio
+    volumecontrol = gr.multiply_const_ff(.1)
+
+    #band-pass
+    audio_coeffs = gr.firdes.band_pass (
+        1.0,    # gain
+        demod_rate,
+        10,   # center of low transition band
+        6000,   # center of hi transition band
+        200,    # width of transition band
+        gr.firdes.WIN_HAMMING)
+    
+    
+    # Low pass filter the demodulator output
+    #audio_coeffs = gr.firdes.low_pass (1.0, demod_rate, 500, 200, gr.firdes.WIN_HANN)
+    print "len(audio_coeffs) = ", len(audio_coeffs)
+
+    # input: float; output: float
+    audio_filter = gr.fir_filter_fff (audio_decimation, audio_coeffs)
+
+    # sound card as final sink
+    audio_sink = audio.sink (int (audio_rate))
+
+    # now wire it all together
+    self.connect (src, ddc)
+    self.connect (ddc, magblock)
+    self.connect (magblock, volumecontrol)
+    self.connect (volumecontrol, audio_filter)
+    self.connect (audio_filter, (audio_sink, 0))
+    
+    d_win = fftsink.fft_sink_c (self, panel, title="RF", fft_size=512, sample_rate=if_rate)
+    self.connect (src,d_win)
+    vbox.Add (d_win.win, 4, wx.EXPAND)
+       
+    p_win = fftsink.fft_sink_c (self, panel, title="IF", fft_size=512, sample_rate=demod_rate)
+    self.connect (ddc,p_win)
+    vbox.Add (p_win.win, 4, wx.EXPAND)
+       
+    r_win = fftsink.fft_sink_f (self, panel, title="Audio", fft_size=512, sample_rate=audio_rate)
+    self.connect (audio_filter,r_win)
+    vbox.Add (r_win.win, 4, wx.EXPAND)
+    
+    #audio_oscope = scopesink.scope_sink_f (self, panel, "Oscope Data", audio_rate)
+    #self.connect (audio_filter, audio_oscope)
+    #vbox.Add (audio_oscope.win, 4, wx.EXPAND) 
+                
+if __name__ == '__main__':
+    
+    app = stdgui.stdapp (wfm_rx_graph, "TVRX AM RX")
+    app.MainLoop ()
diff --git a/gnuradio-examples/python/usrp/limbo/usrp_fft_old.py b/gnuradio-examples/python/usrp/limbo/usrp_fft_old.py
new file mode 100755
index 0000000000..5edb372b98
--- /dev/null
+++ b/gnuradio-examples/python/usrp/limbo/usrp_fft_old.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+#
+# Copyright 2004 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr, gru
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui, fftsink, scopesink
+from optparse import OptionParser
+import wx
+
+class app_flow_graph (stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
+
+        self.frame = frame
+        self.panel = panel
+        
+        parser = OptionParser (option_class=eng_option)
+        parser.add_option ("-d", "--decim", type="int", default=16,
+                           help="set fgpa decimation rate to DECIM")
+        parser.add_option ("-c", "--ddc-freq", type="eng_float", default=0,
+                           help="set Rx DDC frequency to FREQ", metavar="FREQ")
+        parser.add_option ("-m", "--mux", type="intx", default=0x32103210,
+                           help="set fpga FR_RX_MUX register to MUX")
+        parser.add_option ("-g", "--gain", type="eng_float", default=0,
+                           help="set Rx PGA gain in dB (default 0 dB)")
+        (options, args) = parser.parse_args ()
+
+        self.u = usrp.source_c (0, options.decim, 1, gru.hexint(options.mux), 0)
+        self.u.set_rx_freq (0, options.ddc_freq)
+
+        self.u.set_pga (0, options.gain)
+        self.u.set_pga (1, options.gain)
+
+        self.u.set_verbose (0)
+        
+        input_rate = self.u.adc_freq () / self.u.decim_rate ()
+
+        fft = fftsink.fft_sink_c (self, panel, fft_size=1024, sample_rate=input_rate)
+        #fft = fftsink.fft_sink_c (self, panel, fft_size=1024, fft_rate=50, sample_rate=input_rate)
+        self.connect (self.u, fft)
+        vbox.Add (fft.win, 10, wx.EXPAND)
+
+	if 0:
+            c2f_1 = gr.complex_to_float ()
+            scope = scopesink.scope_sink_f (self, panel, "Rx Data", input_rate)
+            vbox.Add (scope.win, 4, wx.EXPAND)
+
+            self.connect (self.u,c2f_1)
+            self.connect ((c2f_1, 0), (scope, 0))
+            self.connect ((c2f_1, 1), (scope, 1))
+
+        # build small control area at bottom
+        hbox = wx.BoxSizer (wx.HORIZONTAL)
+        hbox.Add ((1, 1), 1, wx.EXPAND)
+        hbox.Add (wx.StaticText (panel, -1, "Set ddc freq: "), 0, wx.ALIGN_CENTER)
+        self.tc_freq = wx.TextCtrl (panel, -1, "", style=wx.TE_PROCESS_ENTER)
+        hbox.Add (self.tc_freq, 0, wx.ALIGN_CENTER)
+        wx.EVT_TEXT_ENTER (self.tc_freq, self.tc_freq.GetId(), self.handle_text_enter)
+        hbox.Add ((1, 1), 1, wx.EXPAND)
+        # add it to the main vbox
+        vbox.Add (hbox, 0, wx.EXPAND)
+
+        self.update_status_bar ()
+
+    def handle_text_enter (self, event):
+        str = event.GetString ()
+        self.tc_freq.Clear ()
+        self.u.set_rx_freq (0, eng_notation.str_to_num (str))
+        self.update_status_bar ()
+
+    def update_status_bar (self):
+        ddc_freq = self.u.rx_freq (0)
+        decim_rate = self.u.decim_rate ()
+        sample_rate = self.u.adc_freq () / decim_rate
+        msg = "decim: %d  %sS/s  DDC: %s" % (
+            decim_rate,
+            eng_notation.num_to_str (sample_rate),
+            eng_notation.num_to_str (ddc_freq))
+            
+        self.frame.GetStatusBar().SetStatusText (msg, 1)
+
+        
+
+def main ():
+    app = stdgui.stdapp (app_flow_graph, "USRP FFT")
+    app.MainLoop ()
+
+if __name__ == '__main__':
+    main ()
-- 
cgit v1.2.3