[Top][All Lists]

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

[Discuss-gnuradio] Help with Code

From: ish13
Subject: [Discuss-gnuradio] Help with Code
Date: Fri, 3 Dec 2010 10:37:22 -0800 (PST)

Can someone please help and tell me what is wrong with my code.  My idea is
to create a sine wave->modulate->demodulate->display on scope. I get the
following error below.  Can some explain why?  Also is my idea of my flow
graph a correct way to see if I get back the signal that was created?


RuntimeError: iir_filter_ffd(14): insufficient connected output ports (1
needed, 0 connected)

Transmit 1 signal.

Outputs SSB (USB) signals on side A and side B at frequencies
specified on command line.

Side B is 350 + 440 Hz tones.

from gnuradio import gr
from gnuradio.eng_notation import num_to_str, str_to_num
from gnuradio import usrp
from gnuradio import audio
from gnuradio import blks2
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from usrpm import usrp_dbid
from gnuradio.wxgui import stdgui2, scopesink2, form, slider
import wx
import math
import sys

class dialtone_signal1(gr.hier_block2):
    tone (440 Hz).
    def __init__(self, sample_rate):
        gr.hier_block2.__init__(self, "dialtone_signal1",
                                gr.io_signature(0, 0, gr.sizeof_float),         
# Input signature
                                gr.io_signature(1, 1, gr.sizeof_float)) #
Output signature

        src1 = gr.sig_source_f (sample_rate,    # sample rate
                                gr.GR_SIN_WAVE, # waveform type
                                440,            # frequency
                                1.0,            # amplitude
                                0)              # DC Offset


class my_top_block(stdgui2.std_top_block):

    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel

        usage="%prog: [options] side-A-tx-freq side-B-tx-freq"
        parser = OptionParser (option_class=eng_option, usage=usage)
        parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
                          help="select USRP Tx side A or B")
        parser.add_option("-r", "--sample-rate", type="eng_float", 
                          help="set sample rate to RATE (48000)")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or
        parser.add_option("-n", "--frame-decim", type="int", default=1,
                          help="set oscope frame decimation factor to n
        parser.add_option("-v", "--v-scale", type="eng_float", default=1000,
                          help="set oscope initial V/div to SCALE
        parser.add_option("-t", "--t-scale", type="eng_float",
                          help="set oscope initial s/div to SCALE
        (options, args) = parser.parse_args ()

        sample_rate = int(options.sample_rate)
        self.audio_rate = 320e3 // 10
        print "Enter Carrier frequency: (XXX.X)"
        freq= float(raw_input())*1e6
        self.source1 = dialtone_signal1(sample_rate)
        dst = audio.sink (sample_rate, options.audio_output)
        self.modulator = blks2.wfm_tx(self.audio_rate, 320e3)
        self.demodulator = blks2.wfm_rcv(320e3,int(self.audio_rate))

        self.scope = scopesink2.scope_sink_c(panel, sample_rate=48e3,


        vbox.Add(self.scope.win, 10, wx.EXPAND) 

        def set_freq(self, target_freq):
                Set the center frequency we're interested in.

                @param side: 0 = side A, 1 = side B
                @param target_freq: frequency in Hz
                @rtype: bool

                Tuning is a two step process.  First we ask the front-end to
                tune as close to the desired frequency as it can.  Then we use
                the result of that operation and our target_frequency to
                determine the value for the digital up converter.

                print "Tuning side A to %sHz" % num_to_str(target_freq)
                r = self.u.tune(self.subdev.which(), self.subdev, target_freq)
                if r:
                    print "  r.baseband_freq =", num_to_str(r.baseband_freq)
                    print "  r.dxc_freq      =", num_to_str(r.dxc_freq)
                    print "  r.residual_freq =", num_to_str(r.residual_freq)
                    print "  r.inverted      =", r.inverted
                    print "  OK"
                    return True

                    print "  Failed!"
                return False

if __name__ == '__main__':
        app = stdgui2.stdapp(my_top_block, "USRP O'scope", nstatus=1)
    except KeyboardInterrupt:
View this message in context: 
Sent from the GnuRadio mailing list archive at Nabble.com.

reply via email to

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