Esempio n. 1
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="RTTY decoder example")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 44100

		##################################################
		# Blocks
		##################################################
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate/40,
			v_scale=1,
			v_offset=0,
			t_scale=25e-3,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.rtty_decode_ff_0 = rtty.decode_ff(
		  samp_rate=samp_rate/40, 
		  baud_rate=45.45, 
		  polarity=True,
		)
		self.low_pass_filter_0 = gr.fir_filter_fff(40, firdes.low_pass(
			100, samp_rate, 45.45*3, 20, firdes.WIN_HANN, 6.76))
		self.gr_wavfile_source_0 = gr.wavfile_source("/home/nick/Downloads/ksm_rtty.wav", False)
		self.gr_sub_xx_0 = gr.sub_ff(1)
		self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
		self.gr_moving_average_xx_0 = gr.moving_average_ff(5000, 1.0/5000, 20000)
		self.gr_hilbert_fc_0 = gr.hilbert_fc(64)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "/home/nick/Desktop/rtty/test.dat")
		self.gr_file_sink_0.set_unbuffered(False)

		##################################################
		# Connections
		##################################################
		self.connect((self.low_pass_filter_0, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_sub_xx_0, 1))
		self.connect((self.gr_sub_xx_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.gr_sub_xx_0, 0))
		self.connect((self.rtty_decode_ff_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.gr_sub_xx_0, 0), (self.rtty_decode_ff_0, 0))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.gr_hilbert_fc_0, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.gr_wavfile_source_0, 0), (self.gr_hilbert_fc_0, 0))
Esempio n. 2
0
    def __init__(self):
         gr.hier_block2.__init__(self, "HierBlock_data",
                        gr.io_signature(1, 1, gr.sizeof_float),
                        gr.io_signature(1, 1, 1))
 
         fsk = gr.hilbert_fc((AUDIO_RATE/300)+1)
         bp_coeff = gr.firdes.band_pass(1,AUDIO_RATE,BP_START,BP_STOP,100)
         bpf = gr.fir_filter_fff(1,bp_coeff)
       
         quad_demod = gr.quadrature_demod_cf(1.0)
        
         hpf_coeff = gr.firdes.high_pass(10, AUDIO_RATE, 10, 5)
         dc_block = gr.fir_filter_fff (1, hpf_coeff)
       	
         mm = gr.clock_recovery_mm_ff(REPEAT_TIME,0.000625,0.5,0.01,0.05)
       
         slicer = gr.binary_slicer_fb()
       
         sync_corr = gr.correlate_access_code_bb("0100011101111000",0)
         
       
         self.connect(self,bpf,fsk,quad_demod,dc_block,mm,slicer,sync_corr,self)
Esempio n. 3
0
    def __init__(self):
        gr.top_block.__init__(self)
        
        self.rcvd_pktq = gr.msg_queue()
        audio_rate = 48000
         
        
        src = audio.source (audio_rate,"plughw:0,0")
	mult = gr.multiply_const_ff(10)   # multiply
	raw_wave = gr.wavfile_sink(filename, 1, audio_rate,16)
	raw_wave1 = gr.wavfile_sink(filename2, 1, audio_rate,16)
        
        fsk_c = gr.hilbert_fc((audio_rate/300)+1)
	

	


        bp_coeff = gr.firdes.band_pass(1,audio_rate,BandPass,BandStop,100)
        bpf = gr.fir_filter_fff(1,bp_coeff)
        
        quad_demod = gr.quadrature_demod_cf(1)#originally 1
        
       
        hpf_coeff = gr.firdes.high_pass(10, audio_rate, 10, 5)
       
        dc_block = gr.add_const_ff(-2.225)
        mm = gr.clock_recovery_mm_ff(RepeatTime,0.000625,0.5,0.01,0.1)
        
        slicer = gr.binary_slicer_fb()
        
        sync_corr = gr.correlate_access_code_bb("0100011101111000",0)
        
        file_sink = gr.file_sink(1, "decoded-bits.dat")
        sink = goodney.sink2(self.rcvd_pktq)
        self.connect(bpf,raw_wave1)
	self.connect(src,raw_wave)
        self.connect(src,bpf,fsk_c,quad_demod,dc_block,mm,slicer,sync_corr,sink)
        self.watcher = _queue_watcher_thread(self.rcvd_pktq, message_callback)
Esempio n. 4
0
    def test_hilbert (self):
        tb = self.tb
        ntaps = 51
        sampling_freq = 100

        expected_result = (                             -1.4678005338941702e-11j, 
                                                        -0.0011950774351134896j, 
                                                        -0.0019336787518113852j, 
                                                        -0.0034673355985432863j, 
                                                        -0.0036765895783901215j, 
                                                        -0.004916108213365078j, 
                                                        -0.0042778430506587029j, 
                                                        -0.006028641015291214j, 
                                                        -0.005476709920912981j, 
                                                        -0.0092810001224279404j, 
                                                        -0.0095402700826525688j, 
                                                        -0.016060983762145042j, 
                                                        -0.016446959227323532j, 
                                                        -0.02523401565849781j, 
                                                        -0.024382550269365311j, 
                                                        -0.035477779805660248j, 
                                                        -0.033021725714206696j, 
                                                        -0.048487484455108643j, 
                                                        -0.04543270543217659j, 
                                                        -0.069477587938308716j, 
                                                        -0.066984444856643677j, 
                                                        -0.10703597217798233j, 
                                                        -0.10620346665382385j, 
                                                        -0.1852707713842392j, 
                                                        -0.19357112050056458j, 
                            (7.2191945754696007e-09     -0.50004088878631592j), 
                            (0.58778399229049683        -0.6155126690864563j), 
                            (0.95105588436126709        -0.12377222627401352j), 
                            (0.95105588436126709        +0.41524654626846313j), 
                            (0.5877838134765625         +0.91611981391906738j), 
                            (5.8516356205018383e-09     +1.0670661926269531j), 
                            (-0.5877840518951416        +0.87856143712997437j), 
                            (-0.95105588436126709       +0.35447561740875244j), 
                            (-0.95105588436126709       -0.26055556535720825j), 
                            (-0.5877838134765625        -0.77606213092803955j), 
                            (-8.7774534307527574e-09    -0.96460390090942383j), 
                            (0.58778399229049683        -0.78470128774642944j), 
                            (0.95105588436126709        -0.28380891680717468j), 
                            (0.95105588436126709        +0.32548999786376953j), 
                            (0.5877838134765625         +0.82514488697052002j), 
                            (1.4629089051254596e-08     +1.0096219778060913j), 
                            (-0.5877840518951416        +0.81836479902267456j), 
                            (-0.95105588436126709       +0.31451958417892456j), 
                            (-0.95105588436126709       -0.3030143678188324j), 
                            (-0.5877838134765625        -0.80480599403381348j), 
                            (-1.7554906861505515e-08    -0.99516552686691284j), 
                            (0.58778399229049683        -0.80540722608566284j), 
                            (0.95105582475662231        -0.30557557940483093j), 
                            (0.95105588436126709        +0.31097668409347534j), 
                            (0.5877838134765625         +0.81027895212173462j), 
                            (2.3406542482007353e-08     +1.0000816583633423j), 
                            (-0.5877840518951416        +0.80908381938934326j), 
                            (-0.95105588436126709       +0.30904293060302734j), 
                            (-0.95105588436126709       -0.30904296040534973j), 
                            (-0.5877838134765625        -0.80908387899398804j), 
                            (-2.6332360292258272e-08    -1.0000815391540527j), 
                            (0.58778399229049683        -0.80908381938934326j), 
                            (0.95105582475662231        -0.30904299020767212j), 
                            (0.95105588436126709        +0.30904293060302734j), 
                            (0.5877838134765625         +0.80908381938934326j), 
                            (3.218399768911695e-08      +1.0000815391540527j))
        

        src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE,
                                sampling_freq * 0.10, 1.0)

        head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10))
        hilb = gr.hilbert_fc (ntaps)
        dst1 = gr.vector_sink_c ()
        tb.connect (src1, head)
        tb.connect (head, hilb)
        tb.connect (hilb, dst1)
        tb.run ()
        dst_data = dst1.data ()
        self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5)
Esempio n. 5
0
    def __init__(self, frame, panel, vbox, argv):
        # Graphical part
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        # Config_____
        tx_frequency = 14085000
        usrp_interpolation = 400
        usrp_tx_rate = 128000000
        tx_side = 0
        tx_dev = 0
        audio_rate = 32000

        tx_subdev = (tx_side, tx_dev)
        usrp_tx_sample_rate = usrp_tx_rate / usrp_interpolation

        def rtty_gen_f(samplerate, speed, textdata):
            bitsamples = samplerate / speed
            mark = 900
            shift = 170
            space = mark + shift

            wavedata = []

            letters = "_E\nA SIU\rDRJNFCKTZLWHYPQOBG_MXV_"
            figures = "_3\n- '87\r_4_,!:(5+)2$6019?&_./;_"
            keyshift = 0

            for c in textdata:
                chartable = letters
                baudotdata = ''
                shiftdata = ''

                if ((c >= '!') and (c <= '9')):
                    if (not keyshift):
                        shiftdata = '[MMSMM]'
                    keyshift = 1
                else:
                    if (keyshift):
                        shiftdata = '[MMMMM]'
                    keyshift = 0

                baudotdata = ']' + baudotdata
                if (keyshift):
                    chartable = figures
                baudotval = chartable.find(c)
                for b in (16, 8, 4, 2, 1):
                    if (baudotval >= b):
                        baudotdata = 'M' + baudotdata
                        baudotval = baudotval - b
                    else:
                        baudotdata = 'S' + baudotdata
                baudotdata = shiftdata + '[' + baudotdata

                for bit in baudotdata:
                    if (bit == 'M'):
                        bitval = mark
                        bitlen = 1
                    if (bit == 'S'):
                        bitval = space
                        bitlen = 1
                    if (bit == '['):
                        bitval = space
                        bitlen = 1
                    if (bit == ']'):
                        bitval = mark
                        bitlen = 1.5

                    for s in range(0, bitlen * bitsamples):
                        wavedata.append(bitval)

            return gr.vector_source_f(wavedata, True)

        ryry = "RYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRY\r\n"
        callsign = "ZCZC DE PA3FKM PA3FKM -- RUNNING GNURADIO -- \r\n"
        fox = "+-- THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG --+\r\n "
        rttymsg = ryry + ryry + callsign + fox + "(0123456789)\r\n"

        callgever = rtty_gen_f(audio_rate, 45, rttymsg)

        lpf_coeffs = gr.firdes.low_pass(1, audio_rate, 5000, 200)

        lpf = gr.fir_filter_fff(1, lpf_coeffs)

        fsk_f = gr.vco_f(audio_rate, 2 * pi, 0.5)

        fsk_c = gr.hilbert_fc(audio_rate / 300)

        # IF low pass filter
        lpf_tx_coeffs = gr.firdes.low_pass(32000, audio_rate, 2000, 1000)

        # Interpolation to usrp sample frequency
        fsk_resample = blks2.rational_resampler_ccc(usrp_tx_sample_rate /
                                                    audio_rate,
                                                    1,
                                                    taps=lpf_tx_coeffs)

        usrp_tx = usrp.sink_c(0, usrp_interpolation)
        self.usrp_tx = usrp_tx

        speaker = audio.sink(audio_rate, "plughw:0,0")

        self.connect(callgever, lpf, fsk_f)
        self.connect(fsk_f, fsk_c, fsk_resample, usrp_tx)
        #self.connect(fsk_f, speaker)

        # Set Multiplexer
        mux = usrp.determine_tx_mux_value(usrp_tx, tx_subdev)
        usrp_tx.set_mux(mux)

        # Select subdevice
        usrp_tx_subdev = usrp.selected_subdev(usrp_tx, tx_subdev)

        # Tune subdevice
        usrp_tx.tune(usrp_tx_subdev._which, usrp_tx_subdev, tx_frequency)

        # Enable Transmitter (Required if using one of the Flex boards)
        usrp_tx_subdev.set_enable(True)
    def __init__(self, options, input_filename):
        gr.top_block.__init__(self)

        gr.enable_realtime_scheduling()

        if options.real:
            sizeof_input_samples = gr.sizeof_float
        else:
            sizeof_input_samples = gr.sizeof_gr_complex

        self.src = gr.file_source(sizeof_input_samples,
                                  input_filename,
                                  repeat = options.loop)
        self.u = generic_usrp_sink_c(interface = options.interface,
                                     mac_addr = options.mac_addr,
                                     subdev_spec = options.tx_subdev_spec)
        print 'Using %s' % str(self.u)
        print 'Possible tx frequency range: %s - %s' % \
            (n2s(self.u.freq_range()[0]), n2s(self.u.freq_range()[1]))

        # we need to find the closest decimation rate the USRP can handle
        # to the input file's sampling rate
        try:
            ideal_interp = self.u.dac_rate() / options.rate
            # pick the closest interpolation rate
            interp = [x for x in self.u.get_interp_rates()
                      if x <= ideal_interp][-1]
            self.u.set_interp(interp)
        except IndexError:
            sys.stderr.write('Failed to set USRP interpolation rate\n')
            raise SystemExit, 1

        output_rate = self.u.dac_rate() / interp
        resamp_ratio = output_rate / options.rate 

        # since the input file sample rate may not be exactly what our
        # output rate of the USRP (as determined by the interpolation rate),
        # we need to resample our input to the output rate
        num_filters = 32
        cutoff = 0.99 * options.rate / 2.
        transition = 0.1 * options.rate / 2.
        resamp_taps = gr.firdes_low_pass(num_filters * 1.0,
                                         num_filters * options.rate,
                                         cutoff,
                                         transition)
        self.resamp = gr.pfb_arb_resampler_ccf(resamp_ratio,
                                               resamp_taps,
                                               num_filters)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.gain_range()
            options.gain = float(g[0]+g[1])/2
        self.u.set_gain(options.gain)

        res = self.u.set_center_freq(options.freq)
        if not res:
            sys.stderr.write('Failed to set frequency\n')
            raise SystemExit, 1

        if options.real:
            # our samples are real
            # we need to convert them to complex without a hilbert filter
            self.hilbert = gr.hilbert_fc(64)
            self.connect(self.src, self.hilbert, self.resamp, self.u)
        else:
            # our samples are complex
            self.connect(self.src, self.resamp, self.u)
Esempio n. 7
0
    def test_hilbert(self):
        tb = self.tb
        ntaps = 51
        sampling_freq = 100

        expected_result = (-1.4678005338941702e-11j, -0.0011950774351134896j,
                           -0.0019336787518113852j, -0.0034673355985432863j,
                           -0.0036765895783901215j, -0.004916108213365078j,
                           -0.0042778430506587029j, -0.006028641015291214j,
                           -0.005476709920912981j, -0.0092810001224279404j,
                           -0.0095402700826525688j, -0.016060983762145042j,
                           -0.016446959227323532j, -0.02523401565849781j,
                           -0.024382550269365311j, -0.035477779805660248j,
                           -0.033021725714206696j, -0.048487484455108643j,
                           -0.04543270543217659j, -0.069477587938308716j,
                           -0.066984444856643677j, -0.10703597217798233j,
                           -0.10620346665382385j, -0.1852707713842392j,
                           -0.19357112050056458j, (7.2191945754696007e-09 -
                                                   0.50004088878631592j),
                           (0.58778399229049683 - 0.6155126690864563j),
                           (0.95105588436126709 - 0.12377222627401352j),
                           (0.95105588436126709 + 0.41524654626846313j),
                           (0.5877838134765625 + 0.91611981391906738j),
                           (5.8516356205018383e-09 + 1.0670661926269531j),
                           (-0.5877840518951416 +
                            0.87856143712997437j), (-0.95105588436126709 +
                                                    0.35447561740875244j),
                           (-0.95105588436126709 -
                            0.26055556535720825j), (-0.5877838134765625 -
                                                    0.77606213092803955j),
                           (-8.7774534307527574e-09 -
                            0.96460390090942383j), (0.58778399229049683 -
                                                    0.78470128774642944j),
                           (0.95105588436126709 -
                            0.28380891680717468j), (0.95105588436126709 +
                                                    0.32548999786376953j),
                           (0.5877838134765625 +
                            0.82514488697052002j), (1.4629089051254596e-08 +
                                                    1.0096219778060913j),
                           (-0.5877840518951416 +
                            0.81836479902267456j), (-0.95105588436126709 +
                                                    0.31451958417892456j),
                           (-0.95105588436126709 -
                            0.3030143678188324j), (-0.5877838134765625 -
                                                   0.80480599403381348j),
                           (-1.7554906861505515e-08 -
                            0.99516552686691284j), (0.58778399229049683 -
                                                    0.80540722608566284j),
                           (0.95105582475662231 -
                            0.30557557940483093j), (0.95105588436126709 +
                                                    0.31097668409347534j),
                           (0.5877838134765625 +
                            0.81027895212173462j), (2.3406542482007353e-08 +
                                                    1.0000816583633423j),
                           (-0.5877840518951416 +
                            0.80908381938934326j), (-0.95105588436126709 +
                                                    0.30904293060302734j),
                           (-0.95105588436126709 -
                            0.30904296040534973j), (-0.5877838134765625 -
                                                    0.80908387899398804j),
                           (-2.6332360292258272e-08 -
                            1.0000815391540527j), (0.58778399229049683 -
                                                   0.80908381938934326j),
                           (0.95105582475662231 -
                            0.30904299020767212j), (0.95105588436126709 +
                                                    0.30904293060302734j),
                           (0.5877838134765625 +
                            0.80908381938934326j), (3.218399768911695e-08 +
                                                    1.0000815391540527j))

        src1 = gr.sig_source_f(sampling_freq, gr.GR_SIN_WAVE,
                               sampling_freq * 0.10, 1.0)

        head = gr.head(gr.sizeof_float, int(ntaps + sampling_freq * 0.10))
        hilb = gr.hilbert_fc(ntaps)
        dst1 = gr.vector_sink_c()
        tb.connect(src1, head)
        tb.connect(head, hilb)
        tb.connect(hilb, dst1)
        tb.run()
        dst_data = dst1.data()
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
Esempio n. 8
0
	def __init__(self, frame, panel, vbox, argv):
		# Graphical part
		stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

		# Config_____          
		tx_frequency = 14085000
 		usrp_interpolation = 400
		usrp_tx_rate = 128000000
		tx_side = 0
		tx_dev = 0
		audio_rate = 32000

		tx_subdev=(tx_side,tx_dev)
		usrp_tx_sample_rate = usrp_tx_rate / usrp_interpolation

		def rtty_gen_f(samplerate,speed,textdata):
			bitsamples=samplerate/speed
			mark = 900
			shift = 170
			space = mark+shift

			wavedata=[]

			letters = "_E\nA SIU\rDRJNFCKTZLWHYPQOBG_MXV_" 
			figures = "_3\n- '87\r_4_,!:(5+)2$6019?&_./;_"
			keyshift = 0

			for c in textdata:
				chartable = letters
				baudotdata=''
				shiftdata=''

				if((c >= '!') and  (c <='9')):
					if(not keyshift):
						shiftdata = '[MMSMM]'
                                        keyshift=1
				else:
					if(keyshift):
						shiftdata='[MMMMM]'
					keyshift=0	

				baudotdata = ']' + baudotdata
				if(keyshift):
					chartable = figures;
				baudotval=chartable.find(c)
                                for b in (16,8,4,2,1):
					if(baudotval>=b):
						baudotdata = 'M' + baudotdata
						baudotval = baudotval-b
					else:
						baudotdata = 'S' + baudotdata
                                baudotdata = shiftdata + '[' + baudotdata

				for bit in baudotdata:
 					if(bit == 'M'):
						bitval = mark
						bitlen = 1
 					if(bit == 'S'):
						bitval = space
						bitlen = 1
					if(bit == '['):
						bitval = space
						bitlen = 1
					if(bit == ']'):
						bitval = mark
						bitlen = 1.5

					for s in range(0,bitlen*bitsamples):
						wavedata.append(bitval)

			return gr.vector_source_f(wavedata, True)

		ryry = "RYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRY\r\n"
		callsign = "ZCZC DE PA3FKM PA3FKM -- RUNNING GNURADIO -- \r\n"
		fox = "+-- THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG --+\r\n "
		rttymsg = ryry+ryry+callsign+fox+"(0123456789)\r\n" 

		callgever = rtty_gen_f(audio_rate,45,rttymsg)

		lpf_coeffs = gr.firdes.low_pass(1,
                                                   audio_rate,
                                                   5000,
                                                   200)

                lpf = gr.fir_filter_fff (1, lpf_coeffs)

		fsk_f = gr.vco_f(audio_rate, 2*pi,0.5)

		fsk_c = gr.hilbert_fc(audio_rate/300)


		# IF low pass filter
                lpf_tx_coeffs  = gr.firdes.low_pass(32000,
                                                 audio_rate,
                                                 2000,
                                                 1000
                                                 )

                # Interpolation to usrp sample frequency
                fsk_resample = blks2.rational_resampler_ccc(
                                  usrp_tx_sample_rate / audio_rate,
				  1,
                                  taps=lpf_tx_coeffs
                               )


		usrp_tx = usrp.sink_c(0,usrp_interpolation)
                self.usrp_tx = usrp_tx

		speaker = audio.sink(audio_rate, "plughw:0,0");

		self.connect(callgever, lpf, fsk_f)
		self.connect(fsk_f, fsk_c, fsk_resample, usrp_tx)
		#self.connect(fsk_f, speaker)

		# Set Multiplexer
                mux = usrp.determine_tx_mux_value(usrp_tx,tx_subdev)
                usrp_tx.set_mux(mux)

		# Select subdevice
                usrp_tx_subdev = usrp.selected_subdev(usrp_tx,tx_subdev)

		# Tune subdevice                                               
                usrp_tx.tune(usrp_tx_subdev._which,usrp_tx_subdev, tx_frequency)

		# Enable Transmitter (Required if using one of the Flex boards) 
                usrp_tx_subdev.set_enable(True)