def test_000(self): src_data0 = [ -2 - 2j, -1 - 1j, -2 + 2j, -1 + 1j, 2 - 2j, 1 - 1j, 2 + 2j, 1 + 1j, 0 + 0j ] src_data1 = [ -3 - 3j, -4 - 4j, -3 + 3j, -4 + 4j, 3 - 3j, 4 - 4j, 3 + 3j, 4 + 4j, 0 + 0j ] exp_data = [ 12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 12 + 0j, 8 + 0j, 0 + 0j ] src0 = blocks.vector_source_c(src_data0) src1 = blocks.vector_source_c(src_data1) op = blocks.multiply_conjugate_cc() dst = blocks.vector_sink_c() self.tb.connect(src0, (op, 0)) self.tb.connect(src1, (op, 1)) self.tb.connect(op, dst) self.tb.run() result_data = dst.data() self.assertEqual(exp_data, result_data)
def __init__(self, num_ports=2, n_skip_ahead=8192): gr.hier_block2.__init__( self, "TwinRx Phase Offset Estimate", gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports,gr.sizeof_gr_complex)), gr.io_signaturev(num_ports-1, num_ports-1, gen_sig_io(num_ports-1,gr.sizeof_float)), ) ################################################## # Parameters ################################################## self.n_skip_ahead = n_skip_ahead self.num_ports = num_ports # Create skip head blocks and connect them to the inputs self.skiphead = [] for p in range(0, num_ports): object_name_skiphead = 'blocks_skiphead_'+str(p) self.skiphead.append(blocks.skiphead(gr.sizeof_gr_complex*1, n_skip_ahead)) self.connect((self, p), (self.skiphead[p], 0)) #Create blocks computing subtracted phases and connect the results to the outputs self.multiply_conjugate = [] self.complex_to_arg = [] for p in range(0, num_ports-1): self.multiply_conjugate.append(blocks.multiply_conjugate_cc(1)) self.complex_to_arg.append(blocks.complex_to_arg(1)) self.connect((self.skiphead[0], 0), (self.multiply_conjugate[p], 0)) self.connect((self.skiphead[p+1], 0), (self.multiply_conjugate[p], 1)) self.connect((self.multiply_conjugate[p], 0), (self.complex_to_arg[p], 0)) self.connect((self.complex_to_arg[p], 0), (self, p))
def __init__(self, fft_len, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh): gr.hier_block2.__init__(self, "Coarse Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ''' Constructor @param fft_len - @param freq_sample_delay_samps - @param freq_samps_to_avg - @param mag_samps_to_avg - @param thresh - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(1.0 / (fft_len / 4.0), taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.30,.05,60))) self.fir.declare_sample_delay(0) self.fft_peak = fft_peak(fft_len=fft_len) self.vco = blocks.vco_c(1, 2.0 * pi / fft_len, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fft_peak, 0), (self.s_and_h_detector, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self, 0), (self.fft_peak, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.vco, 0))
def __init__(self, preamble_length): gr.hier_block2.__init__(self, "fqsweep_corr", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(2, 2, gr.sizeof_gr_complex)) despread = self.gen_despread(preamble_length, np.pi * 3.0 / 4.0) # Blocks self.equiv_delay = blocks.delay(gr.sizeof_gr_complex, preamble_length + 2) self.despread_src = blocks.vector_source_c(despread, True, 1, []) self.despread_mul = blocks.multiply_conjugate_cc(1) self.deriv_0_delay = blocks.delay(gr.sizeof_gr_complex, 1) self.deriv_0_mul = blocks.multiply_conjugate_cc(1) self.deriv_1_delay = blocks.delay(gr.sizeof_gr_complex, 1) self.deriv_1_mul = blocks.multiply_conjugate_cc(1) self.avg = blocks.moving_average_cc(preamble_length, 1.0 / preamble_length, 2**16) # Connections # pass output self.connect((self, 0), (self.equiv_delay, 0)) self.connect((self.equiv_delay, 0), (self, 0)) # despread self.connect((self, 0), (self.despread_mul, 0)) self.connect((self.despread_src, 0), (self.despread_mul, 1)) # first phase derivate (frequency) self.connect((self.despread_mul, 0), (self.deriv_0_mul, 0)) self.connect((self.despread_mul, 0), (self.deriv_0_delay, 0)) self.connect((self.deriv_0_delay, 0), (self.deriv_0_mul, 1)) # second phase derivate (change of frequency) self.connect((self.deriv_0_mul, 0), (self.deriv_1_mul, 0)) self.connect((self.deriv_0_mul, 0), (self.deriv_1_delay, 0)) self.connect((self.deriv_1_delay, 0), (self.deriv_1_mul, 1)) # average self.connect((self.deriv_1_mul, 0), (self.avg, 0)) self.connect((self.avg, 0), (self, 1))
def test_multiply_conjugate_cc(): top = gr.top_block() src = blocks.null_source(gr.sizeof_gr_complex) mul = blocks.multiply_conjugate_cc() probe = blocks.probe_rate(gr.sizeof_gr_complex) top.connect((src, 0), (mul, 0)) top.connect((src, 0), (mul, 1)) top.connect(mul, probe) return top, probe
def __init__(self): gr.top_block.__init__(self, "Scanner Grc") ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0/6.0 self.f_900_b = f_900_b = 921.2e6 self.samp_rate = samp_rate = f_symb*4 self.fs = fs = f_900_b self.f_900_e = f_900_e = 959.8e6 self.f_1800_e = f_1800_e = 1879.8e6 self.f_1800_b = f_1800_b = 1805.2e6 self.OSR = OSR = 4 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fs, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(30, 0) self.osmosdr_source_0.set_if_gain(30, 0) self.osmosdr_source_0.set_bb_gain(30, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.threshold_result = blocks.threshold_ff(0, 0.2, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, bias, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, resamp_rate, thresh): gr.hier_block2.__init__(self, "Fine Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ################################################## # Parameters ################################################## self.bias = bias self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.resamp_rate = resamp_rate self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(resamp_rate * 2.0, taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.25,.05,60))) self.fir.declare_sample_delay(0) self.vco = blocks.vco_c(1, 1, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) self.add_const = blocks.add_const_vff((-1.0 * bias * (resamp_rate), )) self.demod = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.demod, 0), (self.s_and_h_detector, 1)) self.connect((self.add_const, 0), (self.vco, 0)) self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.add_const, 0))
def __init__(self, OSR=4): grgsm.hier_block.__init__( self, "FCCH bursts detector", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.OSR = OSR ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0 / 6.0 self.samp_rate = samp_rate = f_symb * OSR ################################################## # Blocks ################################################## self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff( int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb), 0) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int((142) * samp_rate / f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
def __init__(self, samp_rate): gr.hier_block2.__init__(self, 'phase_offset_corrector', gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(2, 2, gr.sizeof_gr_complex)) ## the overlapping parts of the spectra are processed at a lower sampling rate decim = 5 delta_f = float(samp_rate) / 4.0 self._taps = taps = filter.firdes.low_pass(1, samp_rate, 0.05 * samp_rate, 0.02 * samp_rate) self._xlplus = filter.freq_xlating_fir_filter_ccf( decim, (taps), +delta_f, samp_rate) self._xlminus = filter.freq_xlating_fir_filter_ccf( decim, (taps), -delta_f, samp_rate) self._mult_ccA = blocks.multiply_conjugate_cc(1) self._mult_ccB = blocks.multiply_conjugate_cc(1) vlen = int(np.power(2, np.ceil(np.log2(0.1 * samp_rate / decim)))) self._s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, vlen) self._v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, vlen * decim) ## phase offsets depend on the combination of resampling and pfb_synth filter self._pB = phase_estimator(vlen, decim, np.exp( 2j * np.pi * 0.5)) ## phase 1 for num_streams==4, 0.5 for num_streams==6 ## output = conj([conj(#0) * #1]) * #1 self.connect((self, 0), (self._xlplus), (self._mult_ccA, 1)) self.connect((self, 1), (self._xlminus), (self._mult_ccA, 0)) self.connect((self._mult_ccA), (self._s2v), (self._pB), (self._v2s), (self._mult_ccB, 1)) self.connect((self, 1), (self._mult_ccB, 0)) self.connect((self._mult_ccB), (self, 0)) ## phase offsets self.connect((self._v2s), (self, 1))
def __init__(self): gr.hier_block2.__init__( self, "phase_calc_ccf", gr.io_signature(2, 2, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self.block = dict() self.block['mult_conj'] = blocks.multiply_conjugate_cc() self.block['arg'] = blocks.complex_to_arg() self.block['mult_const'] = blocks.multiply_const_ff(180.0 / np.pi) self.connect((self, 0), (self.block['mult_conj'], 0)) self.connect((self, 1), (self.block['mult_conj'], 1)) self.connect((self.block['mult_conj'], 0), (self.block['arg'], 0)) self.connect((self.block['arg'], 0), (self.block['mult_const'], 0)) self.connect((self.block['mult_const'], 0), (self, 0))
def BuildConjMult(self,scope=True): ## Compute angle difference #self.conj = blocks.conjugate_cc() self.mult = blocks.multiply_conjugate_cc() self.connect(self.rx0, blocks.multiply_const_cc(10000), (self.mult,0)) self.connect(self.rx1, blocks.multiply_const_cc(10000), (self.mult,1)) self.histo = qtgui.histogram_sink_f(1000,360,-179,180,"Histogram") #self.histo.enable_autoscale(False) self.histo.enable_accumulate(True) self.histo.enable_grid(True) #self.histo.enable_menu(True) self.connect(self.mult,blocks.complex_to_arg(), blocks.multiply_const_ff(180.0/np.pi),self.histo) self.pyobj = sip.wrapinstance(self.histo.pyqwidget(), QtGui.QWidget) self.pyobj.show()
def __init__(self, OSR=4): gr.hier_block2.__init__( self, "FCCH bursts detector", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.OSR = OSR ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0 / 6.0 self.samp_rate = samp_rate = f_symb * OSR ################################################## # Blocks ################################################## self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff( int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb), 0 ) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142) * samp_rate / f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
def multiply_conjugate_cc(N): try: op = blocks.multiply_conjugate_cc() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb except AttributeError: class s(gr.hier_block2): def __init__(self): gr.hier_block2.__init__(self, "s", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) conj = gr.conjugate_cc() mult = gr.multiply_cc() self.connect((self,0), (mult,0)) self.connect((self,1), conj, (mult,1)) self.connect(mult, self) op = s() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb
def multiply_conjugate_cc(N): try: op = blocks.multiply_conjugate_cc() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb except AttributeError: class s(gr.hier_block2): def __init__(self): gr.hier_block2.__init__(self, "s", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) conj = blocks.conjugate_cc() mult = blocks.multiply_cc() self.connect((self,0), (mult,0)) self.connect((self,1), conj, (mult,1)) self.connect(mult, self) op = s() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1) return tb
def __init__(self, vlen): gr.hier_block2.__init__( self, "xcorrelate_fft_vcf", gr.io_signature(2, 2, gr.sizeof_gr_complex * vlen), # Input signature gr.io_signature(1, 1, gr.sizeof_float * vlen)) # Output signature # Multiply conjugate mult_conj = blocks.multiply_conjugate_cc(vlen) # Reverse FFT, vec_len, Reverse, [1.0,]]*vec_len, no shift rev_fft = fft.fft_vcc(vlen, False, [ 1.0, ] * vlen, False, 1) # Complex to mag - vlen cc_to_mag = blocks.complex_to_mag(vlen) # Vector to stream vec_to_stream = blocks.vector_to_stream(gr.sizeof_float, vlen) # De-interleave deinterleave = blocks.deinterleave(gr.sizeof_float * 1, int(vlen / 2)) # Cross de-interleave into interleave to swap FFT interleave = blocks.interleave(gr.sizeof_float * 1, int(vlen / 2)) # Stream to Vector - vlen stream_to_vec = blocks.stream_to_vector(gr.sizeof_float * 1, vlen) # Make all the connections self.connect((self, 0), (mult_conj, 0)) self.connect((self, 1), (mult_conj, 1)) self.connect(mult_conj, rev_fft, cc_to_mag, vec_to_stream, deinterleave) self.connect((deinterleave, 0), (interleave, 1)) self.connect((deinterleave, 1), (interleave, 0)) self.connect(interleave, stream_to_vec, self)
def test_000 (self): src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j, 2-2j, 1-1j, 2+2j, 1+1j, 0+0j) src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j, 3-3j, 4-4j, 3+3j, 4+4j, 0+0j) exp_data = (12+0j, 8+0j, 12+0j, 8+0j, 12+0j, 8+0j, 12+0j, 8+0j, 0+0j) src0 = blocks.vector_source_c(src_data0) src1 = blocks.vector_source_c(src_data1) op = blocks.multiply_conjugate_cc () dst = blocks.vector_sink_c () self.tb.connect(src0, (op,0)) self.tb.connect(src1, (op,1)) self.tb.connect(op, dst) self.tb.run() result_data = dst.data () self.assertEqual (exp_data, result_data)
def __init__( self, samp_per_sym=4, sync_bandwidth=.6, costas_bandwidth=0.15, agc_time_const=8, sync_phases=32, ): gr.hier_block2.__init__( self, "PSK31 Incoherent Demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex), ) _psk31_sync_base.__init__( self, samp_per_sym, sync_bandwidth, agc_time_const, sync_phases, ) self._multiply = blocks.multiply_conjugate_cc(1) self._reset() self.connect( self._post_sync_agc, (self._multiply, 0), self, ) self.connect( self._post_sync_agc, blocks.delay(gr.sizeof_gr_complex * 1, 1), (self._multiply, 1), )
def __init__(self, num_streams, delta_f_in): gr.hier_block2.__init__(self, 'final_processing', gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) blk_last = (self, 0) if (num_streams % 2) == 0: self._mult_conj = blocks.multiply_conjugate_cc(1) self._carrier = analog.sig_source_c(sampling_freq=8 * delta_f_in, waveform=analog.GR_COS_WAVE, wave_freq=delta_f_in / 2.0, ampl=1.0, offset=0.0) self.connect(blk_last, (self._mult_conj, 0)) self.connect((self._carrier), (self._mult_conj, 1)) blk_last = self._mult_conj if num_streams <= 10: self._final_resamp = filter.rational_resampler_ccf(1, 2) self.connect(blk_last, (self._final_resamp)) blk_last = self._final_resamp self.connect(blk_last, (self, 0))
def test_001_t (self): # set up fg samp_cw = 2**14 samp_up = 2**14 samp_down = samp_up packet_len = samp_cw+samp_up+samp_down min_output_buffer = packet_len*2 test_len = 2*packet_len samp_rate = 10000000 push_power = False center_freq = 5.7e9 Range = 200 velocity = 50 freq_cw = 0 freq_sweep = samp_rate/2 amplitude = 1 src = radar.signal_generator_fmcw_c(samp_rate, samp_up, samp_down, samp_cw, freq_cw, freq_sweep, amplitude) src.set_min_output_buffer(min_output_buffer) head = blocks.head(8,test_len) head.set_min_output_buffer(min_output_buffer) sim = radar.static_target_simulator_cc((Range,),(velocity,),(1e16,),(0,),(0,),samp_rate,center_freq,1,False,False) sim.set_min_output_buffer(min_output_buffer) mult = blocks.multiply_conjugate_cc() mult.set_min_output_buffer(min_output_buffer) decim_fac = 2**4 resamp = filter.rational_resampler_ccc(1,decim_fac) resamp_tag = blocks.tagged_stream_multiply_length(8,'packet_len',1.0/float(decim_fac)) resamp_tag.set_min_output_buffer(min_output_buffer/(decim_fac)) packets = (samp_cw/(decim_fac), samp_up/(decim_fac), samp_down/(decim_fac)) split_cw = radar.split_cc(0,packets) split_up = radar.split_cc(1,packets) split_down = radar.split_cc(2,packets) split_cw.set_min_output_buffer(min_output_buffer/(decim_fac)) split_up.set_min_output_buffer(min_output_buffer/(decim_fac)) split_down.set_min_output_buffer(min_output_buffer/(decim_fac)) fft_cw = radar.ts_fft_cc(samp_cw/(decim_fac)) fft_up = radar.ts_fft_cc(samp_up/(decim_fac)) fft_down = radar.ts_fft_cc(samp_down/(decim_fac)) fft_cw.set_min_output_buffer(min_output_buffer/(decim_fac)) fft_up.set_min_output_buffer(min_output_buffer/(decim_fac)) fft_down.set_min_output_buffer(min_output_buffer/(decim_fac)) threshold = -300 samp_protect = 0 cfar_cw = radar.find_max_peak_c(samp_rate/(decim_fac), threshold, samp_protect, (0,0), False) cfar_up = radar.find_max_peak_c(samp_rate/(decim_fac), threshold, samp_protect, (0,0), False) cfar_down = radar.find_max_peak_c(samp_rate/(decim_fac), threshold, samp_protect, (0,0), False) est = radar.estimator_fmcw(samp_rate/(decim_fac), center_freq, freq_sweep, samp_up/(decim_fac), samp_down/(decim_fac), push_power) res = radar.print_results() debug = blocks.message_debug() self.tb.connect(src,head,(mult,0)) self.tb.connect(head,sim,(mult,1)) self.tb.connect(mult,resamp, resamp_tag) self.tb.connect(resamp_tag,split_cw, fft_cw, cfar_cw) self.tb.connect(resamp_tag,split_up, fft_up, cfar_up) self.tb.connect(resamp_tag,split_down, fft_down, cfar_down) self.tb.msg_connect(cfar_cw,'Msg out',est,'Msg in CW') self.tb.msg_connect(cfar_up,'Msg out',est,'Msg in UP') self.tb.msg_connect(cfar_down,'Msg out',est,'Msg in DOWN') self.tb.msg_connect(est,'Msg out',res,'Msg in') self.tb.msg_connect(est,'Msg out',debug,'store') # run fg self.tb.start() sleep(0.5) self.tb.stop() self.tb.wait() # check data msg = debug.get_message(0) self.assertGreater( velocity/pmt.f32vector_ref(pmt.nth(1,(pmt.nth(1,msg))),0), 0.8 ) # check velocity value self.assertGreater( Range/pmt.f32vector_ref(pmt.nth(1,(pmt.nth(2,msg))),0), 0.8 ) # check range value
def __init__(self): gr.top_block.__init__(self, "Simulator Dual Cw") Qt.QWidget.__init__(self) self.setWindowTitle("Simulator Dual Cw") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "simulator_dual_cw") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5000000 self.packet_len = packet_len = 2**19 self.freq_res = freq_res = samp_rate / float(packet_len) self.freq = freq = (-1000000, 1000000) self.center_freq = center_freq = 2.45e9 self.vel = vel = 50 self.value_range = value_range = 30 self.v_res = v_res = freq_res * 3e8 / 2 / center_freq self.time_res = time_res = packet_len / float(samp_rate) self.range_res = range_res = 3e8 / 2 / float((freq[1] - freq[0])) self.min_output_buffer = min_output_buffer = int(packet_len * 2) self.max_output_buffer = max_output_buffer = 0 self.decim_fac = decim_fac = 2**10 ################################################## # Blocks ################################################## self._vel_range = Range(-50, 50, 0.1, 50, 200) self._vel_win = RangeWidget(self._vel_range, self.set_vel, "vel", "counter_slider", float) self.top_layout.addWidget(self._vel_win) self._value_range_range = Range(0, 100, 1, 30, 200) self._value_range_win = RangeWidget(self._value_range_range, self.set_value_range, 'range', "counter_slider", float) self.top_layout.addWidget(self._value_range_win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len / decim_fac, "packet_len") (self.radar_ts_fft_cc_0_0).set_min_output_buffer(1048576) self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len / decim_fac, "packet_len") (self.radar_ts_fft_cc_0).set_min_output_buffer(1048576) self.radar_trigger_command_0 = radar.trigger_command( "./play_sound beep.mp3", ("range", ), (0, ), (10, ), 500) self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc( (value_range, ), (vel, ), (1e14, ), (0, ), (0, ), samp_rate, center_freq, -10, True, True, "packet_len") (self.radar_static_target_simulator_cc_0 ).set_min_output_buffer(1048576) self.radar_signal_generator_cw_c_0_0 = radar.signal_generator_cw_c( packet_len, samp_rate, (freq[1], ), 1, "packet_len") (self.radar_signal_generator_cw_c_0_0).set_min_output_buffer(1048576) self.radar_signal_generator_cw_c_0 = radar.signal_generator_cw_c( packet_len, samp_rate, (freq[0], ), 1, "packet_len") (self.radar_signal_generator_cw_c_0).set_min_output_buffer(1048576) self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot( 100, 'range', (0, 75), 30, '') self.radar_qtgui_scatter_plot_0 = radar.qtgui_scatter_plot( 100, 'range', 'velocity', (0, 75), (-5, 5), '') self.radar_print_results_0 = radar.print_results(False, "") self.radar_find_max_peak_c_0 = radar.find_max_peak_c( samp_rate / decim_fac, -200, 0, (-1000, 1000), True, "packet_len") self.radar_estimator_fsk_0 = radar.estimator_fsk( center_freq, (freq[1] - freq[0]), False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( packet_len / decim_fac, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim_fac, #bw 'QT GUI Plot', #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) (self.blocks_throttle_0_0).set_min_output_buffer(1048576) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) (self.blocks_throttle_0).set_min_output_buffer(1048576) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0_0 ).set_min_output_buffer(1048576) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0 ).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_0_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0_0).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(1048576) self.blocks_add_xx_1 = blocks.add_vcc(1) (self.blocks_add_xx_1).set_min_output_buffer(1048576) self.blocks_add_xx_0 = blocks.add_vcc(1) (self.blocks_add_xx_0).set_min_output_buffer(1048576) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.5, 0) (self.analog_noise_source_x_0).set_min_output_buffer(1048576) ################################################## # Connections ################################################## self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_print_results_0, 'Msg in')) self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_qtgui_scatter_plot_0, 'Msg in')) self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_qtgui_time_plot_0, 'Msg in')) self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_trigger_command_0, 'Msg in')) self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'), (self.radar_estimator_fsk_0, 'Msg in')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.radar_static_target_simulator_cc_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_find_max_peak_c_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 1)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.radar_static_target_simulator_cc_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 1))
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6-108.00e6)/2+117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6-108.0e6)/2+108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1,rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(com_freq_entry_1,20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface() self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf(5, firdes.low_pass( 1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf(5, firdes.low_pass( 1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf(5, firdes.low_pass( 1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass( 1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff(4, firdes.band_pass( 1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice','VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c(40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.vec_length = vec_length = 65536 self.sinc_sample_locations = sinc_sample_locations = np.arange(-np.pi*4/2.0, np.pi*4/2.0, np.pi/vec_length) self.timenow = timenow = datetime.now().strftime("%Y-%m-%d_%H.%M.%S") self.sinc = sinc = np.sinc(sinc_sample_locations/np.pi) self.prefix = prefix = "/Users/kbandura/grc_data/" self.samp_rate = samp_rate = 2.4e6 self.recfile = recfile = prefix + timenow + ".h5" self.integration_time = integration_time = 2 self.freq = freq = 1420.5e6 self.display_integration = display_integration = 0.5 self.custom_window = custom_window = sinc*np.hamming(4*vec_length) ################################################## # Blocks ################################################## self.radio_astro_hdf5_sink_1 = radio_astro.hdf5_sink(vec_length, recfile, 'testing', freq - samp_rate/2, samp_rate/vec_length, 'testing') self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( vec_length, freq - samp_rate/2, samp_rate/vec_length, "Frequency", "PSD", "Spectrum", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(0, 3000) self.qtgui_vector_sink_f_0.enable_autoscale(True) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("Hz") self.qtgui_vector_sink_f_0.set_y_axis_units("arb") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( vec_length, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(False) self.qtgui_time_sink_x_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fft_vxx_0 = fft.fft_vcc(vec_length, True, (window.rectangular(vec_length)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, vec_length) self.blocks_stream_to_vector_0_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length) self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, vec_length, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((custom_window[-vec_length:])) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((custom_window[2*vec_length:3*vec_length])) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((custom_window[vec_length:2*vec_length])) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((custom_window[0:vec_length])) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(vec_length) self.blocks_integrate_xx_0_0 = blocks.integrate_ff(int(display_integration*samp_rate/vec_length), vec_length) self.blocks_integrate_xx_0 = blocks.integrate_ff(int((integration_time)*samp_rate/vec_length)/int(display_integration*samp_rate/vec_length), vec_length) self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 3*vec_length) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*vec_length) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, vec_length) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(vec_length) self.blocks_add_xx_0 = blocks.add_vcc(vec_length) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_integrate_xx_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_stream_to_vector_0_2, 0)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_stream_to_vector_0_1, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.radio_astro_hdf5_sink_1, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.blocks_stream_to_vector_0_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_2, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
def __init__(self): gr.top_block.__init__(self, "Wwv X310 Corr 1") Qt.QWidget.__init__(self) self.setWindowTitle("Wwv X310 Corr 1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wwv_x310_corr_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.y_min = y_min = -60 self.y_max = y_max = 0 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.samp_rate = samp_rate = 500e3 self.rx_freq = rx_freq = 4.51e6 self.nfft = nfft = 1024*32 self.lpf_cutoff = lpf_cutoff = 50e3 self.delay = delay = 0 self.decim = decim = 1 self.decay_rate = decay_rate = 20e-3 self.c_ms = c_ms = 299792458 ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Main') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'Corr') self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._y_min_tool_bar = Qt.QToolBar(self) self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_min_line_edit = Qt.QLineEdit(str(self.y_min)) self._y_min_tool_bar.addWidget(self._y_min_line_edit) self._y_min_line_edit.returnPressed.connect( lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 5): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._y_max_tool_bar = Qt.QToolBar(self) self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_max_line_edit = Qt.QLineEdit(str(self.y_max)) self._y_max_tool_bar.addWidget(self._y_max_line_edit) self._y_max_line_edit.returnPressed.connect( lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(5, 6): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect( lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect( lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii())))) self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self._decay_rate_options = (100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ('Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(6, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna('A', 1) self.uhd_usrp_source_1.set_auto_dc_offset(True, 1) self.uhd_usrp_source_1.set_auto_iq_balance(True, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 10, #size samp_rate/decim, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( nfft, #size samp_rate/decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Correlation', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3 ) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title("") labels = ['Delay', '', 'Range Delta', '', '', '', '', '', '', ''] units = ['[usec]', '', '[km]', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(3): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2) for r in range(6, 7): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f( 20, 1000, 0, 100e4, "", 1 ) self.qtgui_histogram_sink_x_0_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0_0.enable_grid(False) self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0_0.disable_legend() labels = ['Correlation Magnitude', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 20, 2000, -25*1/(samp_rate/decim) *c_ms / 1000.0, 25*1/(samp_rate/decim) *c_ms / 1000.0, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['Range Delta [km]', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate /decim, #bw "E/W Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "N/S Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(nfft,1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay)) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, )) self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
def test_003_t(self): #print "TEST3: AZIMUTH ESTIMATION" # set up fg packet_len = 2**12 samp_rate = 32000 center_freq = 2.45e9 freq = 0 ampl = 1 Range = (20, ) velocity = (10, ) rcs = (1e9, 0) azimuth = (10, ) position_rx = (0, 0.2) src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl) head = blocks.head(8, packet_len) s2ts = blocks.stream_to_tagged_stream(8, 1, packet_len, 'packet_len') sim = radar.static_target_simulator_cc(Range, velocity, rcs, azimuth, position_rx, samp_rate, center_freq, -10, False, False) s2v0 = blocks.stream_to_vector(8, packet_len) fft0 = fft.fft_vcc(packet_len, 1, ()) v2s0 = blocks.vector_to_stream(8, packet_len) snk0 = blocks.vector_sink_c() s2v1 = blocks.stream_to_vector(8, packet_len) fft1 = fft.fft_vcc(packet_len, 1, ()) v2s1 = blocks.vector_to_stream(8, packet_len) snk1 = blocks.vector_sink_c() mult = blocks.multiply_conjugate_cc(packet_len) v2s2 = blocks.vector_to_stream(8, packet_len) snk2 = blocks.vector_sink_c() self.tb.connect(src, head, s2ts, sim) self.tb.connect((sim, 0), (s2v0, 0)) self.tb.connect(s2v0, fft0, v2s0, snk0) self.tb.connect((sim, 1), (s2v1, 0)) self.tb.connect(s2v1, fft1, v2s1, snk1) self.tb.connect((fft0, 0), (mult, 1)) self.tb.connect((fft1, 0), (mult, 0)) self.tb.connect(mult, v2s2, snk2) self.tb.run() # check ffts data0 und data1 on peak data0 = snk0.data() data1 = snk1.data() data0_abs = [0] * len(data0) data1_abs = [0] * len(data1) for k in range(len(data0)): data0_abs[k] = abs(data0[k]) data1_abs[k] = abs(data1[k]) num0 = np.argmax(data0_abs) # index of max sample (data) num1 = np.argmax(data1_abs) # index of max sample (data) #print "NUM0:", num0, "FREQ:", num0*samp_rate/packet_len, "VELOCITY:", num0*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data0[num0]) #print "NUM1:", num1, "FREQ:", num1*samp_rate/packet_len, "VELOCITY:", num1*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data1[num1]) # check fft data2 on peak data2 = snk2.data() data2_abs = [0] * len(data2) for k in range(len(data0)): data2_abs[k] = abs(data2[k]) num2 = np.argmax(data2_abs) # index of max sample (data) #print "NUM2:", num2, "FREQ:", num2*samp_rate/packet_len, "VELOCITY:", num2*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data2[num2]) # assert phases of rx streams of angle(data1)-angle(data0) and angle(data2) self.assertAlmostEqual( np.angle(data1[num1]) - np.angle(data0[num0]), np.angle(data2[num2]), 4) # assert azimuth angle = np.arcsin( np.angle(data2[num2]) * 3e8 / center_freq / 2 / np.pi / 0.2) / 2 / np.pi * 360 self.assertAlmostEqual(angle / azimuth[0], 1, 0)
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError('Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff(1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect( self, self.band_filter_block) # AM chain self.connect( self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect( self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect( self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self): gr.top_block.__init__(self, "Fm Recv") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Recv") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "FM_RECV") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate_ursp = samp_rate_ursp = 200000 self.samp_rate = samp_rate = 48000 self.gain = gain = 120 self.fc = fc = 15000 self.f_cut_off = f_cut_off = 15000 self.beta = beta = 4 ################################################## # Blocks ################################################## self._gain_range = Range(0, 200, 10, 120, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "Gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._fc_range = Range(0, 15000, 1000, 15000, 200) self._fc_win = RangeWidget(self._fc_range, self.set_fc, "Carrier Frequency", "counter_slider", float) self.top_layout.addWidget(self._fc_win) self._f_cut_off_range = Range(0, 15000, 1000, 15000, 200) self._f_cut_off_win = RangeWidget(self._f_cut_off_range, self.set_f_cut_off, "f_cut_off", "counter_slider", float) self.top_layout.addWidget(self._f_cut_off_win) self._beta_range = Range(0, 4, 1, 4, 200) self._beta_win = RangeWidget(self._beta_range, self.set_beta, "beta", "counter_slider", float) self.top_layout.addWidget(self._beta_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate_ursp) self.uhd_usrp_source_0.set_center_freq(1340e6, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_bandwidth(200e6, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=samp_rate, decimation=samp_rate_ursp, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Recieved Wave Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Complex Wave Signal", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_1_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, f_cut_off, 100, firdes.WIN_HAMMING, beta)) self.low_pass_filter_1 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, f_cut_off, 100, firdes.WIN_HAMMING, beta)) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 62.8e-3, 4, False) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( "/root/SDR_Class/Lab3/test.wav", 1, samp_rate, 8) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, fc, 700e-3, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, fc, 700e-3, 0) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( -70, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self, fm_subcarrier=9960, zero_point=-5): grc_wxgui.top_block_gui.__init__(self, title="VOR Receiver") ################################################## # Parameters ################################################## self.fm_subcarrier = fm_subcarrier self.zero_point = zero_point ################################################## # Variables ################################################## self.rf_rate = rf_rate = 1000000 self.dir_rate = dir_rate = 10 self.channel_rate = channel_rate = 40000 self.audio_rate = audio_rate = 10000 self.vor_freq = vor_freq = 113.9e6 self.volume = volume = 0 self.rf_scale = rf_scale = int(rf_rate/channel_rate) + rf_rate % channel_rate self.offset = offset = fm_subcarrier + 4000 self.dir_scale = dir_scale = int(audio_rate/dir_rate) + audio_rate % dir_rate self.channel = channel = 113.9e6 self.audio_scale = audio_scale = int(channel_rate/audio_rate) + channel_rate % audio_rate ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-10, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._channel_text_box = forms.text_box( parent=self.GetWin(), value=self.channel, callback=self.set_channel, label="Channel (Hz)", converter=forms.float_converter(), ) self.Add(self._channel_text_box) self.zeroer = blocks.add_const_vff((zero_point*(math.pi/180), )) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="deg", minval=-180, maxval=180, factor=180/math.acos(-1), decimal_places=2, ref_level=0, sample_rate=dir_rate, number_rate=dir_rate, average=True, avg_alpha=.25, label="Direction", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=channel, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.25, title="Channel", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self._vor_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq, callback=self.set_vor_freq, label='vor_freq', converter=forms.float_converter(), ) self.Add(self._vor_freq_text_box) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=40, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 10000, 4000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(channel_rate, dir_scale*audio_scale, 30) self.goertzel_fc_0 = fft.goertzel_fc(audio_rate, dir_scale, 30) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, 500, 100, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(rf_scale, (firdes.low_pass(1.0, rf_rate, channel_rate, channel_rate/2, firdes.WIN_HAMMING)), 900, rf_rate) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 1e6) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(volume/10), )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/john/apps/aviation_rx/woodside_vor25.dat", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(channel_rate/30*0.0)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.audio_sink_0 = audio.sink(audio_rate, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0_1_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.zeroer, 0)) self.connect((self.zeroer, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.analog_agc2_xx_0_1, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 14250000 self.packet_len = packet_len = 2**21 self.freq_res = freq_res = samp_rate/float(packet_len) self.freq = freq = (-6000000,6000000) self.center_freq = center_freq = 2.45e9 self.v_res = v_res = freq_res*3e8/2/center_freq self.time_res = time_res = packet_len/float(samp_rate) self.threshold = threshold = -50 self.samp_protect = samp_protect = 1 self.range_time = range_time = 30 self.range_res = range_res = 3e8/2/float((freq[1]-freq[0])) self.range_add = range_add = -1 self.min_output_buffer = min_output_buffer = int(packet_len*2) self.max_output_buffer = max_output_buffer = 0 self.gain_tx = gain_tx = 40 self.gain_rx = gain_rx = 20 self.delay_samp = delay_samp = 28 self.decim_fac = decim_fac = 2**10 self.amplitude = amplitude = 0.5 ################################################## # Blocks ################################################## self._threshold_layout = Qt.QVBoxLayout() self._threshold_tool_bar = Qt.QToolBar(self) self._threshold_layout.addWidget(self._threshold_tool_bar) self._threshold_tool_bar.addWidget(Qt.QLabel("Find peak threshold"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._threshold_counter = qwt_counter_pyslot() self._threshold_counter.setRange(-200, 100, 1) self._threshold_counter.setNumButtons(2) self._threshold_counter.setValue(self.threshold) self._threshold_tool_bar.addWidget(self._threshold_counter) self._threshold_counter.valueChanged.connect(self.set_threshold) self._threshold_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._threshold_slider.setRange(-200, 100, 1) self._threshold_slider.setValue(self.threshold) self._threshold_slider.setMinimumWidth(200) self._threshold_slider.valueChanged.connect(self.set_threshold) self._threshold_layout.addWidget(self._threshold_slider) self.top_grid_layout.addLayout(self._threshold_layout, 1,0) self._samp_protect_layout = Qt.QVBoxLayout() self._samp_protect_tool_bar = Qt.QToolBar(self) self._samp_protect_layout.addWidget(self._samp_protect_tool_bar) self._samp_protect_tool_bar.addWidget(Qt.QLabel("Find peak protected samples"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._samp_protect_counter = qwt_counter_pyslot() self._samp_protect_counter.setRange(0, 10, 1) self._samp_protect_counter.setNumButtons(2) self._samp_protect_counter.setValue(self.samp_protect) self._samp_protect_tool_bar.addWidget(self._samp_protect_counter) self._samp_protect_counter.valueChanged.connect(self.set_samp_protect) self._samp_protect_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._samp_protect_slider.setRange(0, 10, 1) self._samp_protect_slider.setValue(self.samp_protect) self._samp_protect_slider.setMinimumWidth(200) self._samp_protect_slider.valueChanged.connect(self.set_samp_protect) self._samp_protect_layout.addWidget(self._samp_protect_slider) self.top_grid_layout.addLayout(self._samp_protect_layout, 1,1) self._range_add_layout = Qt.QVBoxLayout() self._range_add_tool_bar = Qt.QToolBar(self) self._range_add_layout.addWidget(self._range_add_tool_bar) self._range_add_tool_bar.addWidget(Qt.QLabel("Add range"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._range_add_counter = qwt_counter_pyslot() self._range_add_counter.setRange(-range_res, range_res, 0.1) self._range_add_counter.setNumButtons(2) self._range_add_counter.setValue(self.range_add) self._range_add_tool_bar.addWidget(self._range_add_counter) self._range_add_counter.valueChanged.connect(self.set_range_add) self._range_add_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._range_add_slider.setRange(-range_res, range_res, 0.1) self._range_add_slider.setValue(self.range_add) self._range_add_slider.setMinimumWidth(200) self._range_add_slider.valueChanged.connect(self.set_range_add) self._range_add_layout.addWidget(self._range_add_slider) self.top_grid_layout.addLayout(self._range_add_layout, 2,1) self._gain_tx_layout = Qt.QVBoxLayout() self._gain_tx_tool_bar = Qt.QToolBar(self) self._gain_tx_layout.addWidget(self._gain_tx_tool_bar) self._gain_tx_tool_bar.addWidget(Qt.QLabel("TX gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_tx_counter = qwt_counter_pyslot() self._gain_tx_counter.setRange(0, 100, 1) self._gain_tx_counter.setNumButtons(2) self._gain_tx_counter.setValue(self.gain_tx) self._gain_tx_tool_bar.addWidget(self._gain_tx_counter) self._gain_tx_counter.valueChanged.connect(self.set_gain_tx) self._gain_tx_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_tx_slider.setRange(0, 100, 1) self._gain_tx_slider.setValue(self.gain_tx) self._gain_tx_slider.setMinimumWidth(200) self._gain_tx_slider.valueChanged.connect(self.set_gain_tx) self._gain_tx_layout.addWidget(self._gain_tx_slider) self.top_grid_layout.addLayout(self._gain_tx_layout, 0,0) self._gain_rx_layout = Qt.QVBoxLayout() self._gain_rx_tool_bar = Qt.QToolBar(self) self._gain_rx_layout.addWidget(self._gain_rx_tool_bar) self._gain_rx_tool_bar.addWidget(Qt.QLabel("RX gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_rx_counter = qwt_counter_pyslot() self._gain_rx_counter.setRange(0, 100, 1) self._gain_rx_counter.setNumButtons(2) self._gain_rx_counter.setValue(self.gain_rx) self._gain_rx_tool_bar.addWidget(self._gain_rx_counter) self._gain_rx_counter.valueChanged.connect(self.set_gain_rx) self._gain_rx_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_rx_slider.setRange(0, 100, 1) self._gain_rx_slider.setValue(self.gain_rx) self._gain_rx_slider.setMinimumWidth(200) self._gain_rx_slider.valueChanged.connect(self.set_gain_rx) self._gain_rx_layout.addWidget(self._gain_rx_slider) self.top_grid_layout.addLayout(self._gain_rx_layout, 0,1) self._delay_samp_layout = Qt.QVBoxLayout() self._delay_samp_tool_bar = Qt.QToolBar(self) self._delay_samp_layout.addWidget(self._delay_samp_tool_bar) self._delay_samp_tool_bar.addWidget(Qt.QLabel("Number delay samples"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_samp_counter = qwt_counter_pyslot() self._delay_samp_counter.setRange(0, 100, 1) self._delay_samp_counter.setNumButtons(2) self._delay_samp_counter.setValue(self.delay_samp) self._delay_samp_tool_bar.addWidget(self._delay_samp_counter) self._delay_samp_counter.valueChanged.connect(self.set_delay_samp) self._delay_samp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_samp_slider.setRange(0, 100, 1) self._delay_samp_slider.setValue(self.delay_samp) self._delay_samp_slider.setMinimumWidth(200) self._delay_samp_slider.valueChanged.connect(self.set_delay_samp) self._delay_samp_layout.addWidget(self._delay_samp_slider) self.top_grid_layout.addLayout(self._delay_samp_layout, 2,0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc(samp_rate, center_freq, int(delay_samp), 'addr=192.168.10.4', '', 'internal', 'none', 'J1', gain_tx, 0.1, 0.05, 0, 'addr=192.168.10.6', '', 'mimo', 'mimo', 'J1', gain_rx, 0.1, 0.05, 0, "packet_len") (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0).set_min_output_buffer(4194304) self.radar_tracking_singletarget_0 = radar.tracking_singletarget(300, 0.5, 0.3, 0.1, 0.001, 1, 'particle') self.radar_signal_generator_cw_c_0_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[1], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0_0).set_min_output_buffer(4194304) self.radar_signal_generator_cw_c_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[0], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0).set_min_output_buffer(4194304) self.radar_qtgui_time_plot_1_0 = radar.qtgui_time_plot(100, 'velocity', (-3,3), range_time, 'TRACKING') self.radar_qtgui_time_plot_1 = radar.qtgui_time_plot(100, 'velocity', (-3,3), range_time, "") self.radar_qtgui_time_plot_0_0 = radar.qtgui_time_plot(100, 'range', (0,range_res), range_time, 'TRACKING') self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot(100, 'range', (0,range_res), range_time, "") self.radar_print_results_0 = radar.print_results(False, "") self.radar_msg_manipulator_0 = radar.msg_manipulator(('range',), (range_add, ), (1, )) self.radar_find_max_peak_c_0 = radar.find_max_peak_c(samp_rate/decim_fac, threshold, int(samp_protect), ((-300,300)), True, "packet_len") self.radar_estimator_fsk_0 = radar.estimator_fsk(center_freq, (freq[1]-freq[0]), False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( packet_len/decim_fac, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim_fac, #bw "QT GUI Plot", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0_0).set_min_output_buffer(4194304) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0_0).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(4194304) self.blocks_add_xx_1 = blocks.add_vcc(1) (self.blocks_add_xx_1).set_min_output_buffer(4194304) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_find_max_peak_c_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.radar_usrp_echotimer_cc_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 0)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 1)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.radar_find_max_peak_c_0, "Msg out", self.radar_estimator_fsk_0, "Msg in") self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_msg_manipulator_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_print_results_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_qtgui_time_plot_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_qtgui_time_plot_1, "Msg in") self.msg_connect(self.radar_tracking_singletarget_0, "Msg out", self.radar_qtgui_time_plot_0_0, "Msg in") self.msg_connect(self.radar_tracking_singletarget_0, "Msg out", self.radar_qtgui_time_plot_1_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_tracking_singletarget_0, "Msg in")
def __init__(self, final_decimation=4, gain=21, pllFreqMax=100, pulse_duration=0.015, pulse_freq=146000000, samp_rate=3e6, wnT=math.pi / 4.0 * 0 + 0.635): gr.hier_block2.__init__( self, "Pulsedetectbase", gr.io_signature(0, 0, 0), gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_gr_complex * 1]), ) ################################################## # Parameters ################################################## self.final_decimation = final_decimation self.gain = gain self.pllFreqMax = pllFreqMax self.pulse_duration = pulse_duration self.pulse_freq = pulse_freq self.samp_rate = samp_rate self.wnT = wnT ################################################## # Variables ################################################## self.decimate_1 = decimate_1 = 16 self.samp_rate2 = samp_rate2 = samp_rate / decimate_1 self.decimate_2 = decimate_2 = 16 self.samp_rate3 = samp_rate3 = samp_rate2 / decimate_2 self.taps3 = taps3 = firdes.low_pass_2(1.0, samp_rate3, 1.5e3, 0.3e3, 30.0, firdes.WIN_KAISER, 6.76 / 2) self.taps2 = taps2 = firdes.low_pass_2(1.0, samp_rate2, 1.5e3, 16e3 - 1.5e3, 60.0, firdes.WIN_BLACKMAN_HARRIS, 6.76) self.taps1 = taps1 = firdes.low_pass_2(1.0, samp_rate, 1.5e3, 128e3 - 1.5e3, 60.0, firdes.WIN_BLACKMAN_HARRIS, 6.76) self.decimate_3 = decimate_3 = final_decimation self.taps3_len = taps3_len = len(taps3) self.taps2_len = taps2_len = len(taps2) self.taps1_len = taps1_len = len(taps1) self.samp_rate4 = samp_rate4 = samp_rate3 / decimate_3 self.inter_pulse_duration = inter_pulse_duration = 2 self.fmin = fmin = -pllFreqMax self.fmax = fmax = pllFreqMax ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'airspy=0,sensitivity') self.osmosdr_source_0.set_clock_source('gpsdo', 0) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(pulse_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decimate_1, (taps1), 0, samp_rate) self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccf(decimate_3, (taps3)) self.fir_filter_xxx_0_0_0.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(decimate_2, (taps2)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_cc( int(samp_rate4 * pulse_duration), 1, int(samp_rate4 * inter_pulse_duration / 10.0)) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.analog_pll_refout_cc_0 = analog.pll_refout_cc( wnT, math.pi / (samp_rate4 / 2.0) * fmax, math.pi / (samp_rate4 / 2.0) * fmin) ################################################## # Connections ################################################## self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.fir_filter_xxx_0_0_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Xbee Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Xbee Playback") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "xbee_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 12e6 self.baud = baud = 95.2e3 self.samps_per_symb = samps_per_symb = samp_rate / 30 / baud self.offset = offset = -1500 ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num( str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 9, 0, 1, 1) self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('offset' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 9, 2, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_b( samp_rate, 20, 1000, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0.enable_grid(False) self.qtgui_time_raster_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 30, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-80, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( 30, ([ -0.0009440003777854145, -1.9967922852119293e-18, 0.0011775379534810781, -2.1018872363980166e-18, -0.001785947591997683, 1.104649332765264e-17, 0.0028464579954743385, -4.376348750402665e-18, -0.0044487821869552135, 6.047675863462489e-18, 0.006705658044666052, -7.96089705741242e-18, -0.009772991761565208, 1.0012871595263528e-17, 0.013889657333493233, -1.2092975237025114e-17, -0.019461529329419136, 1.4089067934233976e-17, 0.02725801058113575, -1.589354424254493e-17, -0.0389452800154686, 1.7409121104476838e-17, 0.058897972106933594, -1.855409458220539e-17, -0.10325390845537186, 1.9266737149699424e-17, 0.31760919094085693, 0.500455915927887, 0.31760919094085693, 1.9266737149699424e-17, -0.10325390845537186, -1.855409458220539e-17, 0.058897972106933594, 1.7409121104476838e-17, -0.0389452800154686, -1.589354424254493e-17, 0.02725801058113575, 1.4089067934233976e-17, -0.019461529329419136, -1.2092975237025114e-17, 0.013889657333493233, 1.0012871595263528e-17, -0.009772991761565208, -7.96089705741242e-18, 0.006705658044666052, 6.047675863462489e-18, -0.0044487821869552135, -4.376348750402665e-18, 0.0028464579954743385, 1.104649332765264e-17, -0.001785947591997683, -2.1018872363980166e-18, 0.0011775379534810781, -1.9967922852119293e-18, -0.0009440003777854145 ]), 1.0, 100) self.pfb_channelizer_ccf_0.set_channel_map(([])) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c() self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/xbee/xbee_12MSPS.fc32', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fosphor_glfw_sink_c_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 10), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_delay_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_null_sink_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_null_sink_0, 10)) self.connect((self.pfb_channelizer_ccf_0, 11), (self.blocks_null_sink_0, 11)) self.connect((self.pfb_channelizer_ccf_0, 12), (self.blocks_null_sink_0, 12)) self.connect((self.pfb_channelizer_ccf_0, 13), (self.blocks_null_sink_0, 13)) self.connect((self.pfb_channelizer_ccf_0, 14), (self.blocks_null_sink_0, 14)) self.connect((self.pfb_channelizer_ccf_0, 15), (self.blocks_null_sink_0, 15)) self.connect((self.pfb_channelizer_ccf_0, 16), (self.blocks_null_sink_0, 16)) self.connect((self.pfb_channelizer_ccf_0, 17), (self.blocks_null_sink_0, 17)) self.connect((self.pfb_channelizer_ccf_0, 18), (self.blocks_null_sink_0, 18)) self.connect((self.pfb_channelizer_ccf_0, 19), (self.blocks_null_sink_0, 19)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_null_sink_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 20), (self.blocks_null_sink_0, 20)) self.connect((self.pfb_channelizer_ccf_0, 21), (self.blocks_null_sink_0, 21)) self.connect((self.pfb_channelizer_ccf_0, 22), (self.blocks_null_sink_0, 22)) self.connect((self.pfb_channelizer_ccf_0, 23), (self.blocks_null_sink_0, 23)) self.connect((self.pfb_channelizer_ccf_0, 24), (self.blocks_null_sink_0, 24)) self.connect((self.pfb_channelizer_ccf_0, 25), (self.blocks_null_sink_0, 25)) self.connect((self.pfb_channelizer_ccf_0, 26), (self.blocks_null_sink_0, 26)) self.connect((self.pfb_channelizer_ccf_0, 27), (self.blocks_null_sink_0, 27)) self.connect((self.pfb_channelizer_ccf_0, 28), (self.blocks_null_sink_0, 28)) self.connect((self.pfb_channelizer_ccf_0, 29), (self.blocks_null_sink_0, 29)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_null_sink_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_null_sink_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_null_sink_0, 5)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 6)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 7)) self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 8)) self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 9))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 960e3 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=30, taps=None, fractional_bw=None, ) self.iir_filter_xxx_2 = filter.iir_filter_ffd((10, ), (1, .95), True) self.iir_filter_xxx_1 = filter.iir_filter_ffd((1/(5e3), ), ([1,1]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1,0.95]), ([1,0]), False) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.dc_blocker_xx_0 = filter.dc_blocker_ff(8192, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_xx_2 = blocks.add_vff(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(32000, "", True) self.analog_sig_source_x_3 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_sig_source_x_2_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_sig_source_x_1_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 5000, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 300000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -300000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(5e-6) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.01, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_add_xx_2, 1)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_add_xx_1_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_add_xx_2, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.iir_filter_xxx_2, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.iir_filter_xxx_1, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.iir_filter_xxx_2, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.dc_blocker_xx_0, 0))
def test_003_t (self): #print "TEST3: AZIMUTH ESTIMATION" # set up fg packet_len = 2**12 samp_rate = 32000 center_freq = 2.45e9 freq = 0 ampl = 1 Range = (20,) velocity = (10,) rcs = (1e9,0) azimuth = (10,) position_rx = (0,0.2) src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl) head = blocks.head(8,packet_len) s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,'packet_len') sim = radar.static_target_simulator_cc(Range, velocity, rcs, azimuth, position_rx, samp_rate, center_freq, -10, False, False) s2v0 = blocks.stream_to_vector(8,packet_len) fft0 = fft.fft_vcc(packet_len,1,()) v2s0 = blocks.vector_to_stream(8,packet_len) snk0 = blocks.vector_sink_c() s2v1 = blocks.stream_to_vector(8,packet_len) fft1 = fft.fft_vcc(packet_len,1,()) v2s1 = blocks.vector_to_stream(8,packet_len) snk1 = blocks.vector_sink_c() mult = blocks.multiply_conjugate_cc(packet_len) v2s2 = blocks.vector_to_stream(8,packet_len) snk2 = blocks.vector_sink_c() self.tb.connect(src,head,s2ts,sim) self.tb.connect((sim,0),(s2v0,0)) self.tb.connect(s2v0,fft0,v2s0,snk0) self.tb.connect((sim,1),(s2v1,0)) self.tb.connect(s2v1,fft1,v2s1,snk1) self.tb.connect((fft0,0),(mult,1)) self.tb.connect((fft1,0),(mult,0)) self.tb.connect(mult,v2s2,snk2) self.tb.run() # check ffts data0 und data1 on peak data0 = snk0.data() data1 = snk1.data() data0_abs = [0]*len(data0) data1_abs = [0]*len(data1) for k in range(len(data0)): data0_abs[k] = abs(data0[k]) data1_abs[k] = abs(data1[k]) num0 = np.argmax(data0_abs) # index of max sample (data) num1 = np.argmax(data1_abs) # index of max sample (data) #print "NUM0:", num0, "FREQ:", num0*samp_rate/packet_len, "VELOCITY:", num0*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data0[num0]) #print "NUM1:", num1, "FREQ:", num1*samp_rate/packet_len, "VELOCITY:", num1*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data1[num1]) # check fft data2 on peak data2 = snk2.data() data2_abs = [0]*len(data2) for k in range(len(data0)): data2_abs[k] = abs(data2[k]) num2 = np.argmax(data2_abs) # index of max sample (data) #print "NUM2:", num2, "FREQ:", num2*samp_rate/packet_len, "VELOCITY:", num2*samp_rate/packet_len*3e8/2/center_freq, "PHI:", np.angle(data2[num2]) # assert phases of rx streams of angle(data1)-angle(data0) and angle(data2) self.assertAlmostEqual(np.angle(data1[num1])-np.angle(data0[num0]),np.angle(data2[num2]),4) # assert azimuth angle = np.arcsin(np.angle(data2[num2])*3e8/center_freq/2/np.pi/0.2)/2/np.pi*360; self.assertAlmostEqual(angle/azimuth[0],1,0)
def test_001_t (self): # run full fsk setup on high sample rates test_len = 2**19 packet_len = 2**19 min_output_buffer = packet_len*2 samp_rate = 5000000 center_freq = 2.45e9 Range = 50 velocity = 5 samp_per_freq = 1 blocks_per_tag = packet_len/2 freq_low = 0 freq_high = 1250000 amplitude = 1 samp_discard = 0 src = radar.signal_generator_fsk_c(samp_rate, samp_per_freq, blocks_per_tag, freq_low, freq_high, amplitude) src.set_min_output_buffer(min_output_buffer) head = blocks.head(8,test_len) head.set_min_output_buffer(min_output_buffer) sim = radar.static_target_simulator_cc((Range,),(velocity,),(1e20,),(0,),(0,),samp_rate,center_freq,1,False,False) sim.set_min_output_buffer(min_output_buffer) mult = blocks.multiply_conjugate_cc() mult.set_min_output_buffer(min_output_buffer) fft1 = radar.ts_fft_cc(packet_len/2) fft1.set_min_output_buffer(min_output_buffer) fft2 = radar.ts_fft_cc(packet_len/2) fft2.set_min_output_buffer(min_output_buffer) split = radar.split_fsk_cc(samp_per_freq,samp_discard) split.set_min_output_buffer(min_output_buffer) mult_conj = blocks.multiply_conjugate_cc() mult_conj.set_min_output_buffer(min_output_buffer) cfar = radar.find_max_peak_c(samp_rate/2,-120,0,(),False) cfar.set_min_output_buffer(min_output_buffer) est = radar.estimator_fsk(center_freq,freq_high-freq_low) res = radar.print_results() debug = blocks.message_debug() self.tb.connect(src,head,(mult,1)) self.tb.connect(head,sim,(mult,0)) self.tb.connect(mult,split) self.tb.connect((split,0),fft1) self.tb.connect((split,1),fft2) self.tb.connect(fft1,(mult_conj,0)) self.tb.connect(fft2,(mult_conj,1)) self.tb.connect(mult_conj,cfar) self.tb.msg_connect(cfar,'Msg out',est,'Msg in') self.tb.msg_connect(est,'Msg out',res,'Msg in') self.tb.msg_connect(est,'Msg out',debug,'store') self.tb.start() sleep(0.5) self.tb.stop() self.tb.wait() # check data msg = debug.get_message(0) #print "VELOCITY:", pmt.f32vector_ref(pmt.nth(1,(pmt.nth(1,msg))),0), velocity #print "RANGE:", pmt.f32vector_ref(pmt.nth(1,(pmt.nth(2,msg))),0), Range self.assertAlmostEqual( 1, velocity/pmt.f32vector_ref(pmt.nth(1,(pmt.nth(1,msg))),0), 1 ) # check velocity value self.assertAlmostEqual( 1, Range/pmt.f32vector_ref(pmt.nth(1,(pmt.nth(2,msg))),0), 1 ) # check range value
def __init__(self): gr.top_block.__init__(self, "Usrp Echotimer Dual Cw") Qt.QWidget.__init__(self) self.setWindowTitle("Usrp Echotimer Dual Cw") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "usrp_echotimer_dual_cw") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 14250000 self.packet_len = packet_len = 2**21 self.freq_res = freq_res = samp_rate / float(packet_len) self.freq = freq = (-6000000, 6000000) self.center_freq = center_freq = 2.45e9 self.v_res = v_res = freq_res * 3e8 / 2 / center_freq self.time_res = time_res = packet_len / float(samp_rate) self.threshold = threshold = -50 self.samp_protect = samp_protect = 1 self.range_time = range_time = 30 self.range_res = range_res = 3e8 / 2 / float((freq[1] - freq[0])) self.range_add = range_add = -1 self.min_output_buffer = min_output_buffer = int(packet_len * 2) self.max_output_buffer = max_output_buffer = 0 self.gain_tx = gain_tx = 40 self.gain_rx = gain_rx = 20 self.delay_samp = delay_samp = 28 self.decim_fac = decim_fac = 2**10 self.amplitude = amplitude = 0.5 ################################################## # Blocks ################################################## self._threshold_range = Range(-200, 100, 1, -50, 200) self._threshold_win = RangeWidget(self._threshold_range, self.set_threshold, 'Find peak threshold', "counter_slider", float) self.top_grid_layout.addWidget(self._threshold_win, 1, 0) self._samp_protect_range = Range(0, 10, 1, 1, 200) self._samp_protect_win = RangeWidget(self._samp_protect_range, self.set_samp_protect, 'Find peak protected samples', "counter_slider", float) self.top_grid_layout.addWidget(self._samp_protect_win, 1, 1) self._range_add_range = Range(-range_res, range_res, 0.1, -1, 200) self._range_add_win = RangeWidget(self._range_add_range, self.set_range_add, 'Add range', "counter_slider", float) self.top_grid_layout.addWidget(self._range_add_win, 2, 1) self._gain_tx_range = Range(0, 100, 1, 40, 200) self._gain_tx_win = RangeWidget(self._gain_tx_range, self.set_gain_tx, 'TX gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_tx_win, 0, 0) self._gain_rx_range = Range(0, 100, 1, 20, 200) self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx, 'RX gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rx_win, 0, 1) self._delay_samp_range = Range(0, 100, 1, 28, 200) self._delay_samp_win = RangeWidget(self._delay_samp_range, self.set_delay_samp, 'Number delay samples', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_samp_win, 2, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc( samp_rate, center_freq, int(delay_samp), 'serial=30F4194', '', 'internal', 'none', 'TX/RX', gain_tx, 0.1, 0.05, 0, 'serial=30F4194', '', 'internal', 'none', 'RX2', gain_rx, 0.1, 0.05, 0, "packet_len") (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len / decim_fac, "packet_len") (self.radar_ts_fft_cc_0_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len / decim_fac, "packet_len") (self.radar_ts_fft_cc_0).set_min_output_buffer(4194304) self.radar_signal_generator_cw_c_0_0 = radar.signal_generator_cw_c( packet_len, samp_rate, (freq[1], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0_0).set_min_output_buffer(4194304) self.radar_signal_generator_cw_c_0 = radar.signal_generator_cw_c( packet_len, samp_rate, (freq[0], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0).set_min_output_buffer(4194304) self.radar_print_results_0 = radar.print_results(False, "") self.radar_msg_manipulator_0 = radar.msg_manipulator( ('range', ), (range_add, ), (1, )) self.radar_find_max_peak_c_0 = radar.find_max_peak_c( samp_rate / decim_fac, threshold, int(samp_protect), ((-300, 300)), True, "packet_len") self.radar_estimator_fsk_0 = radar.estimator_fsk( center_freq, (freq[1] - freq[0]), False) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0_0 ).set_min_output_buffer(4194304) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0 ).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0_0).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(4194304) self.blocks_add_xx_1 = blocks.add_vcc(1) (self.blocks_add_xx_1).set_min_output_buffer(4194304) ################################################## # Connections ################################################## self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_msg_manipulator_0, 'Msg in')) self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'), (self.radar_estimator_fsk_0, 'Msg in')) self.msg_connect((self.radar_msg_manipulator_0, 'Msg out'), (self.radar_print_results_0, 'Msg in')) self.connect((self.blocks_add_xx_1, 0), (self.radar_usrp_echotimer_cc_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_find_max_peak_c_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simulator Fsk") Qt.QWidget.__init__(self) self.setWindowTitle("Simulator Fsk") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "simulator_fsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5000000 self.blocks_per_tag = blocks_per_tag = 2**17 self.samp_per_freq = samp_per_freq = 1 self.freq_res = freq_res = samp_rate / 2 / blocks_per_tag self.delta_freq = delta_freq = samp_rate / 4 self.center_freq = center_freq = 2.4e9 self.velocity = velocity = 20 self.value_range = value_range = 10 self.v_res = v_res = freq_res * 3e8 / 2 / center_freq self.samp_discard = samp_discard = 0 self.min_output_buffer = min_output_buffer = 2 * (blocks_per_tag * samp_per_freq * 2) self.decimator_fac = decimator_fac = 2**7 self.R_max = R_max = 3e8 / 2 / delta_freq ################################################## # Blocks ################################################## self._velocity_range = Range(-30, 30, 1, 20, 200) self._velocity_win = RangeWidget(self._velocity_range, self.set_velocity, "velocity", "counter_slider", float) self.top_grid_layout.addWidget(self._velocity_win) self._value_range_range = Range(0, R_max + R_max / 2, 1, 10, 200) self._value_range_win = RangeWidget(self._value_range_range, self.set_value_range, 'range', "counter_slider", float) self.top_grid_layout.addWidget(self._value_range_win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decimator_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decimator_fac, taps=None, fractional_bw=None, ) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc( blocks_per_tag / decimator_fac, "packet_len") self.radar_ts_fft_cc_0 = radar.ts_fft_cc( blocks_per_tag / decimator_fac, "packet_len") self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc( (value_range, ), (velocity, ), (1e16, ), (0, ), (0, ), samp_rate, center_freq, -10, True, True, "packet_len") (self.radar_static_target_simulator_cc_0).set_min_output_buffer(524288) self.radar_split_fsk_cc_0 = radar.split_fsk_cc(samp_per_freq, samp_discard, "packet_len") (self.radar_split_fsk_cc_0).set_min_output_buffer(524288) self.radar_signal_generator_fsk_c_0 = radar.signal_generator_fsk_c( samp_rate, samp_per_freq, blocks_per_tag, -delta_freq / 2, delta_freq / 2, 1, "packet_len") (self.radar_signal_generator_fsk_c_0).set_min_output_buffer(524288) self.radar_print_results_0 = radar.print_results(False, "test.txt") self.radar_os_cfar_c_0 = radar.os_cfar_c(samp_rate / 2 / decimator_fac, 15, 0, 0.78, 30, True, "packet_len") (self.radar_os_cfar_c_0).set_min_output_buffer(524288) self.radar_estimator_fsk_0 = radar.estimator_fsk( center_freq, delta_freq, False) self.qtgui_sink_x_0 = qtgui.sink_c( blocks_per_tag / decimator_fac, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decimator_fac / 2, #bw 'QT GUI Plot', #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) (self.blocks_throttle_0).set_min_output_buffer(524288) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decimator_fac) (self.blocks_tagged_stream_multiply_length_0_0 ).set_min_output_buffer(524288) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decimator_fac) (self.blocks_tagged_stream_multiply_length_0 ).set_min_output_buffer(524288) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(524288) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(524288) self.blocks_add_xx_0 = blocks.add_vcc(1) (self.blocks_add_xx_0).set_min_output_buffer(524288) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.5, 0) (self.analog_noise_source_x_0).set_min_output_buffer(524288) ################################################## # Connections ################################################## self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'), (self.radar_print_results_0, 'Msg in')) self.msg_connect((self.radar_os_cfar_c_0, 'Msg out'), (self.radar_estimator_fsk_0, 'Msg in')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.radar_os_cfar_c_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_split_fsk_cc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) self.connect((self.blocks_throttle_0, 0), (self.radar_static_target_simulator_cc_0, 0)) self.connect((self.radar_signal_generator_fsk_c_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.radar_split_fsk_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.radar_split_fsk_cc_0, 1), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.radar_static_target_simulator_cc_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 9142857.14286 ################################################## # Blocks ################################################## self.blocks_moving_average = blocks.moving_average_cc(1, 1, 4000) self.blocks_delay = blocks.delay(gr.sizeof_gr_complex * 1, 0) self.t2_p1_detector_0 = t2_p1_detector() self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024000, #size 1, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(0, 1) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 50000, 0, "p1_start") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.dvbt2rx_gi_est_decider_0 = dvbt2rx.gi_est_decider(3, 16) self.dvbt2rx_gi_est_control_cc_0 = dvbt2rx.gi_est_control_cc( self.blocks_delay, self.blocks_moving_average) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_1 = blocks.moving_average_ff( 2**12, 1. / 2**24, 4000) (self.blocks_moving_average_1).set_min_output_buffer(500000) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/kmaier/workspace/gr-dvbt2rx/binary_testfiles/ard_multiplex_karlsruhe_rx_sr9142857.14286.iq', True) self.blocks_complex_to_mag_squared_1_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) (self.blocks_complex_to_mag_squared_1).set_min_output_buffer(500000) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, samp_rate / 1024 * 0, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.dvbt2rx_gi_est_decider_0, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_1_0, 0), (self.blocks_moving_average_1, 0)) self.connect((self.blocks_delay, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_moving_average, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.blocks_moving_average_1, 0), (self.dvbt2rx_gi_est_decider_0, 1)) self.connect((self.blocks_moving_average_1, 0), (self.qtgui_time_sink_x_0_0_0, 1)) self.connect((self.blocks_multiply_conjugate_0, 0), (self.blocks_moving_average, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_conjugate_0, 1)) self.connect((self.blocks_tag_gate_0_0, 0), (self.blocks_complex_to_mag_squared_1_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.t2_p1_detector_0, 0)) self.connect((self.dvbt2rx_gi_est_control_cc_0, 0), (self.blocks_delay, 0)) self.connect((self.dvbt2rx_gi_est_control_cc_0, 0), (self.blocks_multiply_conjugate_0, 0)) self.connect((self.dvbt2rx_gi_est_control_cc_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.t2_p1_detector_0, 0), (self.dvbt2rx_gi_est_control_cc_0, 0))
def __init__(self, bfo=1500, callsign='', ip='::', latitude=0, longitude=0, port=7355, recstart=''): gr.top_block.__init__(self, "Nayif-1 decoder") ################################################## # Parameters ################################################## self.bfo = bfo self.callsign = callsign self.ip = ip self.latitude = latitude self.longitude = longitude self.port = port self.recstart = recstart ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 16 self.alpha = alpha = 0.35 self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts) ################################################## # Blocks ################################################## self.sids_submit_0 = sids.submit( 'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 42017, callsign, longitude, latitude, recstart) self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S') self.funcube_telemetry_parser_0 = ao40.funcube_telemetry_parser() self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf( 5, (firdes.low_pass(1, samp_rate, 1300, 500)), bfo, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 0.1, (rrc_taps), nfilts, nfilts / 2, 0.05, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, 0.350, 100, 0.01) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip, port, 1472, False) self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.ao40_fec_decoder_0 = ao40_fec_decoder() self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2) ################################################## # Connections ################################################## self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.funcube_telemetry_parser_0, 'in')) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ao40_fec_decoder_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self, options): gr.top_block.__init__(self, "Top Block") ################################################## # Blocks ################################################## # Calibrating so do not need a sink (empty calibration) if options.mode == 1 or options.mode == 2 or options.mode == 10: # addr0 is of sweeper # Note that mode 2, 1 and 10 require two time-synced USRPs self.usrp_source = uhd.usrp_source( ",".join(("addr0=192.168.10.2,addr1=192.168.20.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) if options.mode == 2: self.usrp_sink = uhd.usrp_sink( ",".join(("addr0=192.168.10.2,addr1=192.168.20.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) elif options.mode == 3 or options.mode == 0 or options.mode == 30: # dev_args is of sweeper self.usrp_source = uhd.usrp_source( ",".join((options.dev_args, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) else: stderr.write("You gave me an option I do not know about\n") exit(1) # Initialization code for controlling the DAC output self.chan = 0 self.unit = uhd.dboard_iface.UNIT_TX self.dac = uhd.dboard_iface.AUX_DAC_A self.iface = self.usrp_source.get_dboard_iface(self.chan) #self.iface.write_aux_dac_config(32) self.iface.write_aux_dac(self.unit, self.dac, 0.2) # Configure frequency band registers (depending on daughter board) # Channel 1 on MIMO cable is the sweeper USRP usrp_info = self.usrp_source.get_usrp_info(0) db_name = usrp_info["rx_subdev_name"] user_reg_1 = 0 user_reg_2 = 0 print("NAME: " + db_name) if (db_name.find("SBX") != -1): # The following two registers can be configured for frequency band # 2.4 GHz comes in 16 and 24 # for all 37 bands, put 4294967295 in reg 1 and 31 in reg 2 stderr.write("Detected SBX DB...\n") user_reg_1 = 48 # frequncy bit array for first 32 bands #32-band6#64-band7 user_reg_2 = 0 # frequency bit array for next 5 bands elif (db_name.find("CBX") != -1): # 2.4 GHz stderr.write("Detected CBX DB...\n") user_reg_1 = options.band1 # frequncy bit array for first 32 bands user_reg_2 = options.band2 # frequency bit array for next 32 bands rf_div = options.rf_div # RfOut divider for VCO else: stderr.write("Error: Unknown daughterboard: %s\n" % db_name) exit(1) # Chirp enable self.usrp_source.set_user_register(3, 1, 0) self.usrp_source.set_user_register(1, user_reg_1, 0) self.usrp_source.set_user_register(2, user_reg_2, 0) self.usrp_source.set_user_register(6, rf_div, 0) #Address 5 -Clk divider self.usrp_source.set_user_register(5, 4, 0) #self.usrp_source.set_user_register(6,1,0) # RF divider to give 400-4.4GHz range. Valid values are 1,2,4,8 and 16. # The following are the new registers that need to be set # for the updated hardware code. # register 4 = jump value - 12 bit number self.usrp_source.set_user_register(4, options.step, 0) # register 7 = start_ramp - 12 bit number self.usrp_source.set_user_register(7, 621, 0) # register 8 = end_ramp - 12 bit number self.usrp_source.set_user_register(8, 3103, 0) self.usrp_source.set_user_register(6, options.rf_div, 0) if len(options.filename) == 0: # No filenames given -- just connect to a null source self.null_sink0 = blocks.null_sink(gr.sizeof_gr_complex * 1) # Connections self.connect((self.usrp_source, 0), (self.null_sink0, 0)) if options.mode == 1: self.null_sink1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.connect((self.usrp_source, 1), (self.null_sink1, 0)) elif len(options.filename) >= 1: if options.mode == 1 or options.mode == 10: # Synchronous reception : creates two time synced files # options.filename[0] is the string containing the ground truth rx samples # options.filename[1] is the string containing the SweepSense rx samples # options.filename[2] is the string containing the name of the calibration file # Setting params for sweeper self.usrp_source.set_gain(options.rgain, 0) self.usrp_source.set_antenna("RX2", 0) self.usrp_source.set_bandwidth(options.samp, 0) # self.usrp_sink.set_gain(options.tgain,0) # self.usrp_sink.set_antenna("TX/RX",0) # self.usrp_sink.set_center_freq(2212e6,0) # self.usrp_sink.set_bandwidth(options.txsamp,0) # Setting params for ground truth self.usrp_source.set_samp_rate(options.samp) self.usrp_source.set_gain(options.rgain, 1) self.usrp_source.set_antenna("TX/RX", 1) self.usrp_source.set_center_freq(options.txfreq, 1) self.usrp_source.set_bandwidth(options.samp, 1) self.usrp_source.set_clock_source("mimo", 1) self.usrp_source.set_time_source("mimo", 1) # Initialize USRP sink # self.usrp_sink.set_samp_rate(options.txsamp) # self.usrp_sink.set_gain(options.tgain,1) # self.usrp_sink.set_antenna("RX2",1) # self.usrp_sink.set_center_freq(options.txfreq,1) # self.usrp_sink.set_bandwidth(options.txsamp,1) # self.usrp_sink.set_clock_source("mimo",1) # self.usrp_sink.set_time_source("mimo",1) # We are using a MIMO cable 2 USRP setup to transmit (but not sure why we need two transmitters) # Null sinks for the slave source # self.null_source_2 = blocks.null_source(gr.sizeof_gr_complex*1) # self.null_source_3 = blocks.null_source(gr.sizeof_gr_complex*1) # Sample blockers # to do, add M in N here self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) # self.blocks_head_2 = blocks.head(gr.sizeof_gr_complex*1,options.maxsamp) # self.blocks_head_3 = blocks.head(gr.sizeof_gr_complex*1,options.maxsamp) # file blocks self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, options.filename[0], False) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_gr_complex * 1, options.filename[1], False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_file_sink_1.set_unbuffered(False) if options.mode == 1: # Mode for compensated self.blocks_file_src_cal = blocks.file_source( gr.sizeof_gr_complex * 1, options.filename[2], True) if options.mode == 10: # Mode for uncompensated self.blocks_file_src_cal = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 1) # conjugate multiplier for compensation self.blocks_mult_conj = blocks.multiply_conjugate_cc(1) # Connections self.connect((self.usrp_source, 1), (self.blocks_head_0, 0)) self.connect((self.usrp_source, 0), (self.blocks_mult_conj, 0)) # sweeper to multiply self.connect((self.blocks_file_src_cal, 0), (self.blocks_mult_conj, 1)) # cal to multiply self.connect((self.blocks_mult_conj, 0), (self.blocks_head_1, 0)) # multiply to head # self.connect((self.null_source_2,0),(self.blocks_head_2,0)) # self.connect((self.null_source_3,0),(self.blocks_head_3,0)) self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_1, 0)) # self.connect((self.blocks_head_2,0),(self.usrp_sink,0)) # self.connect((self.blocks_head_3,0),(self.usrp_sink,1)) elif options.mode == 3 or options.mode == 30: # SweepSense standalone reception : creates a single received file # options.filename[0] is the string containing the name of the file you want to store to # options.filename[1] is the string containing the name of the calibration file # Setting params for sweeper self.usrp_source.set_gain(options.rgain, 0) self.usrp_source.set_antenna("RX2", 0) self.usrp_source.set_bandwidth(options.samp, 0) self.usrp_source.set_samp_rate(options.samp) # Sample blockers self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) self.blocks_skiphead_0 = blocks.skiphead( gr.sizeof_gr_complex * 1, options.skip) # file blocks self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, options.filename[0], False) self.blocks_file_sink_0.set_unbuffered(False) if options.mode == 3: # compensated signal self.blocks_file_src_cal = blocks.file_source( gr.sizeof_gr_complex * 1, options.filename[1], True) if options.mode == 30: # the following is for getting uncompensated stuff self.blocks_file_src_cal = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 1) # conjugate multiplier for compensation self.blocks_mult_conj = blocks.multiply_conjugate_cc(1) # DC Blocker self.dc_blocker_xx_0 = filter.dc_blocker_cc(256, False) # Keep M in N self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n( gr.sizeof_gr_complex, options.sweep_time * options.num_bands, options.sweep_time * options.num_bands * options.inN, 0) # Connections self.connect((self.usrp_source, 0), (self.dc_blocker_xx_0, 0)) # sweeper to DC block self.connect( (self.dc_blocker_xx_0, 0), (self.blocks_mult_conj, 0)) # DC block to multiply conj # self.connect((self.usrp_source,0),(self.blocks_mult_conj,0)) # sweeper to DC block self.connect((self.blocks_file_src_cal, 0), (self.blocks_mult_conj, 1)) # cal to multiply # no realtime calib - just receive: #self.connect((self.dc_blocker_xx_0,0),(self.blocks_head_1,0)) self.connect((self.blocks_mult_conj, 0), (self.blocks_skiphead_0, 0)) # multiply to head #self.connect((self.blocks_skiphead_0,0),(self.blocks_head_1,0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_head_1, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_0, 0)) elif options.mode == 2: # This mode sends pilots on normal USRP & receives through sweeper # Setting params for sweeper self.usrp_source.set_gain(options.rgain, 0) self.usrp_source.set_antenna("RX2", 0) self.usrp_source.set_bandwidth(options.samp, 0) self.usrp_sink.set_gain(options.tgain, 0) self.usrp_sink.set_antenna("TX/RX", 0) self.usrp_sink.set_center_freq( options.txfreq - 100e6, 0 ) # tune to some off band frequency to prevent interference self.usrp_sink.set_bandwidth(options.txsamp, 0) # Initialize USRP sink - transmitter self.usrp_sink.set_samp_rate(options.txsamp) self.usrp_sink.set_gain(options.tgain, 1) self.usrp_sink.set_antenna("TX/RX", 1) self.usrp_sink.set_center_freq(options.txfreq, 1) self.usrp_sink.set_bandwidth(options.txsamp, 1) self.usrp_sink.set_clock_source("mimo", 1) self.usrp_sink.set_time_source("mimo", 1) self.usrp_source.set_samp_rate(options.samp) self.usrp_source.set_gain(options.rgain, 1) self.usrp_source.set_antenna("RX2", 1) self.usrp_source.set_center_freq(options.txfreq, 1) self.usrp_source.set_bandwidth(options.samp, 1) self.usrp_source.set_clock_source("mimo", 1) self.usrp_source.set_time_source("mimo", 1) # Null sinks for the slave source self.null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.null_source_2 = blocks.null_source(gr.sizeof_gr_complex * 1) # Skip heads self.blocks_skiphead_0 = blocks.skiphead( gr.sizeof_gr_complex * 1, options.skip) self.blocks_skiphead_1 = blocks.skiphead( gr.sizeof_gr_complex * 1, options.skip) self.blocks_skiphead_2 = blocks.skiphead( gr.sizeof_gr_complex * 1, options.skip) self.blocks_skiphead_3 = blocks.skiphead( gr.sizeof_gr_complex * 1, options.skip) # Sample blockers self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) self.blocks_head_2 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) self.blocks_head_3 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) # TODO: add squelch to get only good signals from calibration - we need to get the values of the squelch as well # file blocks # options.filename[0] is used to store the received calibration tone # transmitted tone is 10 kHz offset from the actual centre frequency as below: self.blocks_file_source_3 = analog.sig_source_c( options.samp, analog.GR_COS_WAVE, 10000, 1, 0) # using complex cosine self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_gr_complex * 1, options.filename[0], False) self.blocks_file_sink_1.set_unbuffered(False) # Connections self.connect((self.usrp_source, 1), (self.blocks_skiphead_2, 0)) self.connect((self.usrp_source, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_file_source_3, 0), (self.blocks_skiphead_1, 0)) self.connect((self.null_source_2, 0), (self.blocks_skiphead_3, 0)) self.connect((self.blocks_skiphead_2, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_skiphead_3, 0), (self.blocks_head_2, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_1, 0)) self.connect((self.blocks_skiphead_1, 0), (self.blocks_head_3, 0)) self.connect((self.blocks_head_0, 0), (self.null_sink_0, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_head_3, 0), (self.usrp_sink, 1)) self.connect((self.blocks_head_2, 0), (self.usrp_sink, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.vol = vol = 100 self.tau = tau = 50e-6 self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = 20 self.freq = freq = 107.2e6 self.decim = decim = 80 self.b_signal = b_signal = 50e3 ################################################## # Blocks ################################################## _vol_sizer = wx.BoxSizer(wx.VERTICAL) self._vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, label="Volume L", converter=forms.float_converter(), proportion=0, ) self._vol_slider = forms.slider( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, minimum=0, maximum=300, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vol_sizer, 2, 0, 1, 1) _tau_sizer = wx.BoxSizer(wx.VERTICAL) self._tau_text_box = forms.text_box( parent=self.GetWin(), sizer=_tau_sizer, value=self.tau, callback=self.set_tau, label="Zeitkonstante (Tau)", converter=forms.float_converter(), proportion=0, ) self._tau_slider = forms.slider( parent=self.GetWin(), sizer=_tau_sizer, value=self.tau, callback=self.set_tau, minimum=0, maximum=100e-6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tau_sizer, 0, 1, 1, 1) self._samp_rate_text_box = forms.text_box( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sampling Rate", converter=forms.float_converter(), ) self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1) _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, label="Receiver Gain", converter=forms.float_converter(), proportion=0, ) self._rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rx_gain_sizer, 2, 2, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequenz (UKW)", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=80e6, maximum=230e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 0, 0, 1, 1) _b_signal_sizer = wx.BoxSizer(wx.VERTICAL) self._b_signal_text_box = forms.text_box( parent=self.GetWin(), sizer=_b_signal_sizer, value=self.b_signal, callback=self.set_b_signal, label="Signalbandbreite", converter=forms.float_converter(), proportion=0, ) self._b_signal_slider = forms.slider( parent=self.GetWin(), sizer=_b_signal_sizer, value=self.b_signal, callback=self.set_b_signal, minimum=1e3, maximum=400e3, num_steps=399, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_b_signal_sizer, 1, 1, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=500, decimation=480, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rx_gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio L (FFT)") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio R (FFT)") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio L (Scope)") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio R (Scope)") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "MPX-Signal (FFT)") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RX FFT") self.GridAdd(self.notebook_0, 3, 0, 1, 3) self.low_pass_filter_2_1_0_0 = filter.fir_filter_fff(20, firdes.low_pass( 1, samp_rate, 15000, 500, firdes.WIN_HANN, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, b_signal, 2000, firdes.WIN_HANN, 6.76)) self.iir_filter_xxx_0 = filter.iir_filter_ffd(((1.0/(1+tau*2*samp_rate), 1.0/(1+tau*2*samp_rate))), ((1, -(1-tau*2*samp_rate)/(1+tau*2*samp_rate))), True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((vol/100, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.low_pass_filter_2_1_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.low_pass_filter_2_1_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5000000 self.packet_len = packet_len = 2**19 self.freq_res = freq_res = samp_rate/float(packet_len) self.freq = freq = (-1000000,1000000) self.center_freq = center_freq = 2.45e9 self.vel = vel = 50 self.v_res = v_res = freq_res*3e8/2/center_freq self.time_res = time_res = packet_len/float(samp_rate) self.range_res = range_res = 3e8/2/float((freq[1]-freq[0])) self.min_output_buffer = min_output_buffer = int(packet_len*2) self.max_output_buffer = max_output_buffer = 0 self.decim_fac = decim_fac = 2**10 self.Range = Range = 30 ################################################## # Blocks ################################################## self._vel_layout = Qt.QVBoxLayout() self._vel_tool_bar = Qt.QToolBar(self) self._vel_layout.addWidget(self._vel_tool_bar) self._vel_tool_bar.addWidget(Qt.QLabel("vel"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._vel_counter = qwt_counter_pyslot() self._vel_counter.setRange(-50, 50, 0.1) self._vel_counter.setNumButtons(2) self._vel_counter.setValue(self.vel) self._vel_tool_bar.addWidget(self._vel_counter) self._vel_counter.valueChanged.connect(self.set_vel) self._vel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._vel_slider.setRange(-50, 50, 0.1) self._vel_slider.setValue(self.vel) self._vel_slider.setMinimumWidth(200) self._vel_slider.valueChanged.connect(self.set_vel) self._vel_layout.addWidget(self._vel_slider) self.top_layout.addLayout(self._vel_layout) self._Range_layout = Qt.QVBoxLayout() self._Range_tool_bar = Qt.QToolBar(self) self._Range_layout.addWidget(self._Range_tool_bar) self._Range_tool_bar.addWidget(Qt.QLabel("Range"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._Range_counter = qwt_counter_pyslot() self._Range_counter.setRange(0, 100, 1) self._Range_counter.setNumButtons(2) self._Range_counter.setValue(self.Range) self._Range_tool_bar.addWidget(self._Range_counter) self._Range_counter.valueChanged.connect(self.set_Range) self._Range_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._Range_slider.setRange(0, 100, 1) self._Range_slider.setValue(self.Range) self._Range_slider.setMinimumWidth(200) self._Range_slider.valueChanged.connect(self.set_Range) self._Range_layout.addWidget(self._Range_slider) self.top_layout.addLayout(self._Range_layout) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0_0).set_min_output_buffer(1048576) self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0).set_min_output_buffer(1048576) self.radar_trigger_command_0 = radar.trigger_command("python get_pic.py", ("range",), (10, ), (20, ), 500) self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc((Range,), (vel, ), (1e14, ), (0,), (0,), samp_rate, center_freq, -10, True, True, "packet_len") (self.radar_static_target_simulator_cc_0).set_min_output_buffer(1048576) self.radar_signal_generator_cw_c_0_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[1], ), 1, "packet_len") (self.radar_signal_generator_cw_c_0_0).set_min_output_buffer(1048576) self.radar_signal_generator_cw_c_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[0], ), 1, "packet_len") (self.radar_signal_generator_cw_c_0).set_min_output_buffer(1048576) self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot(100, 'range', (0,75), 30, "") self.radar_qtgui_scatter_plot_0 = radar.qtgui_scatter_plot(100, 'range', 'velocity', (0,75), (-5,5), "") self.radar_print_results_0 = radar.print_results(False, "") self.radar_find_max_peak_c_0 = radar.find_max_peak_c(samp_rate/decim_fac, -200, 0, (-1000,1000), True, "packet_len") self.radar_estimator_fsk_0 = radar.estimator_fsk(center_freq, (freq[1]-freq[0]), False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( packet_len/decim_fac, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim_fac, #bw "QT GUI Plot", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) (self.blocks_throttle_0_0).set_min_output_buffer(1048576) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) (self.blocks_throttle_0).set_min_output_buffer(1048576) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0_0).set_min_output_buffer(1048576) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_0_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0_0).set_min_output_buffer(1048576) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(1048576) self.blocks_add_xx_1 = blocks.add_vcc(1) (self.blocks_add_xx_1).set_min_output_buffer(1048576) self.blocks_add_xx_0 = blocks.add_vcc(1) (self.blocks_add_xx_0).set_min_output_buffer(1048576) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.5, 0) (self.analog_noise_source_x_0).set_min_output_buffer(1048576) ################################################## # Connections ################################################## self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_add_xx_1, 0), (self.radar_static_target_simulator_cc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_find_max_peak_c_0, 0)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.radar_static_target_simulator_cc_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_print_results_0, "Msg in") self.msg_connect(self.radar_find_max_peak_c_0, "Msg out", self.radar_estimator_fsk_0, "Msg in") self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_trigger_command_0, "Msg in") self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_qtgui_scatter_plot_0, "Msg in") self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_qtgui_time_plot_0, "Msg in")
def __init__(self, rxPort=52002, txPort=52001): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.rxPort = rxPort self.txPort = txPort ################################################## # Variables ################################################## self.localOscillator = localOscillator = 14070000 self.threshold = threshold = -200 self.samp_rate = samp_rate = 48000 self.rxPhase = rxPhase = .84 self.rxMagnitude = rxMagnitude = 0.854 self.freqFine = freqFine = 0 self.freq = freq = localOscillator self.bandwidth = bandwidth = 50 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope") self.Add(self.notebook_0) _freqFine_sizer = wx.BoxSizer(wx.VERTICAL) self._freqFine_text_box = forms.text_box( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._freqFine_slider = forms.slider( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freqFine_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=localOscillator-samp_rate, maximum=localOscillator+samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, label="Signal Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, minimum=30, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bandwidth_sizer) self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=localOscillator, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76)) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001) self.blocks_transcendental_1 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25) self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25)) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=txPort, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=rxPort, server=False, ) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver") ################################################## # Variables ################################################## self.smux_filt_samprate = smux_filt_samprate = 256e3 self.smux_decim = smux_decim = 8 self.samp_rate = samp_rate = 2.048e6 self.right_gain = right_gain = 3 self.left_gain = left_gain = 3 self.bpf_base = bpf_base = 23e3 self.RF_Gain = RF_Gain = 45 self.CF = CF = 99.3e6 ################################################## # Blocks ################################################## self._samp_rate_text_box = forms.text_box( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M", converter=forms.float_converter(), ) self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1) _right_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._right_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_right_gain_sizer, value=self.right_gain, callback=self.set_right_gain, label="R Audio Gain", converter=forms.float_converter(), proportion=0, ) self._right_gain_slider = forms.slider( parent=self.GetWin(), sizer=_right_gain_sizer, value=self.right_gain, callback=self.set_right_gain, minimum=0, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_right_gain_sizer, 0, 1, 1, 1) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "BB Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Signal") self.GridAdd(self.notebook_0, 2, 0, 1, 2) _left_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._left_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_left_gain_sizer, value=self.left_gain, callback=self.set_left_gain, label="L Audio Gain", converter=forms.float_converter(), proportion=0, ) self._left_gain_slider = forms.slider( parent=self.GetWin(), sizer=_left_gain_sizer, value=self.left_gain, callback=self.set_left_gain, minimum=0, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_left_gain_sizer, 0, 0, 1, 1) _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._RF_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._RF_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, minimum=0, maximum=100, num_steps=45, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Baseband Waterfall", size=(800,100), ) self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3, 0, 1, 2) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=32e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", size=(800,500), ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Difference FFT ", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/8, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Demodulated FFT", peak_hold=False, size=(800,800), ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Baseband FFT", peak_hold=False, size=(800,100), ) self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0, 1, 2) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Sum FFT", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win) self.rfgain = blocks.multiply_const_vcc((RF_Gain, )) self.low_pass_filter_1_0 = filter.fir_filter_fff(smux_decim, firdes.low_pass( 1, smux_filt_samprate, 15e3, 500, firdes.WIN_HAMMING, 1)) self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 2, samp_rate/4, 100e3, 500, firdes.WIN_KAISER, 6.76)) self.iir_filter_xxx_0 = filter.iir_filter_ccf((-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103, -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035, 0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122, 0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634, -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476, 0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960, 0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971, -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052, -0.00663, 0.00136, 0.00309, -0.00504, 0.00266 ), (1 , ), False) self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1,1,1,1)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((right_gain, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((left_gain, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1", True) self.blocks_divide_xx_1 = blocks.divide_cc(1) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex*1, 30) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, )) self.baseband_LPF = filter.fir_filter_fff(smux_decim, firdes.low_pass( 1, smux_filt_samprate, 15e3, 500, firdes.WIN_KAISER, 6.76)) self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, smux_filt_samprate, 18000, 20000, 1000, firdes.WIN_KAISER, 1)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, smux_filt_samprate, bpf_base, bpf_base+30e3, 500, firdes.WIN_KAISER, 6.76)) self.audio_sink_0_0_0_0 = audio.sink(32000, "", True) self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(3.14/100, 0.152*3.14, 0.144*3.14) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6) self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) _CF_sizer = wx.BoxSizer(wx.VERTICAL) self._CF_text_box = forms.text_box( parent=self.GetWin(), sizer=_CF_sizer, value=self.CF, callback=self.set_CF, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._CF_slider = forms.slider( parent=self.GetWin(), sizer=_CF_sizer, value=self.CF, callback=self.set_CF, minimum=80e6, maximum=108e6, num_steps=280, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_CF_sizer, 3, 0, 1, 2) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0, 0), (self.audio_sink_0_0_0_0, 1)) self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_pll_refout_cc_0_0, 0)) self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0)) self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.baseband_LPF, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6 - 108.0e6) / 2 + 108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(com_freq_entry_1, 20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 5, firdes.low_pass(1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff( 4, firdes.band_pass(1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c( 40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): gr.top_block.__init__(self, "Spin Echo") Qt.QWidget.__init__(self) self.setWindowTitle("Spin Echo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "spin_echo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.slave_delay = slave_delay = 0 self.samp_rate = samp_rate = 250000 self.ref_delay = ref_delay = 0 self.readout_delay = readout_delay = 0 self.power = power = 1 self.offset = offset = 0 self.master_delay = master_delay = 0 self.gz_on = gz_on = 0 self.gy_on = gy_on = 0 self.gx_on = gx_on = 0 self.ex_delay = ex_delay = 0 self.TR_clock = TR_clock = 0 self.TR = TR = 1. self.RUN = RUN = 1 self.Gz_delay = Gz_delay = 0 self.Gy_delay = Gy_delay = 0 self.Gx_delay = Gx_delay = 0 self.CF = CF = 21.3e6 #### ADDED FROM GR-MRI ##### f = open('spin_config.txt', 'r') foo = {} for line in f: k, v, bar = [q.strip() for q in line.split(',')] if k == 'leader_ID': self.leader_ID = str("serial = " + v) elif k == 'follower_ID': self.follower_ID = str("serial = " + v) else: pass f.close() ############################ ################################################## # Blocks ################################################## self.delay = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0_0.set_clock_source("external", 0) self.uhd_usrp_source_0_0.set_time_source("external", 0) self.uhd_usrp_source_0_0.set_subdev_spec("B:A B:B", 0) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(0, 0) self.uhd_usrp_source_0_0.set_gain(0, 0) self.uhd_usrp_source_0_0.set_antenna("B:A", 0) self.uhd_usrp_source_0_0.set_center_freq(0, 1) self.uhd_usrp_source_0_0.set_gain(0, 1) self.uhd_usrp_source_0_0.set_antenna("B:B", 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:A B:B", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(CF + offset, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("A:A", 0) self.uhd_usrp_source_0.set_bandwidth(25000, 0) self.uhd_usrp_source_0.set_center_freq(CF + offset, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.uhd_usrp_source_0.set_antenna("B:B", 1) self.syncwin = MRI.triggered_vector_source_f( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 1.0, 0.0, 1, 1) self.sync_data = blocks.vector_sink_c(1) self.signal_out = MRI.gated_vector_sink() self.s_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.s_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(slave_delay)) self.rf_sink = uhd.usrp_sink( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.rf_sink.set_subdev_spec("A:AB B:AB", 0) self.rf_sink.set_samp_rate(samp_rate) self.rf_sink.set_center_freq(CF + offset, 0) self.rf_sink.set_gain(0, 0) self.rf_sink.set_antenna("A:AB", 0) self.rf_sink.set_center_freq(0, 1) self.rf_sink.set_gain(0, 1) self.rf_sink.set_antenna("B:AB", 1) self.ref_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 3000, #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.1) self.qtgui_time_sink_x_0.set_y_axis(-.25, .25) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, .01, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "blue", "red", "green", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 2, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.delay6 = blocks.delay(gr.sizeof_float * 1, Gx_delay) self.delay3_0_1_0 = blocks.delay(gr.sizeof_float * 1, Gy_delay) self.delay3_0_1 = blocks.delay(gr.sizeof_float * 1, Gz_delay) self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay) self.delay1_0 = blocks.delay(gr.sizeof_float * 1, ref_delay) self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay) self.dc_sinc = uhd.usrp_sink( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.dc_sinc.set_clock_source("external", 0) self.dc_sinc.set_time_source("external", 0) self.dc_sinc.set_subdev_spec("B:AB A:AB", 0) self.dc_sinc.set_samp_rate(samp_rate) self.dc_sinc.set_center_freq(0, 0) self.dc_sinc.set_gain(0, 0) self.dc_sinc.set_antenna("B:AB", 0) self.dc_sinc.set_center_freq(0, 1) self.dc_sinc.set_gain(0, 1) self.dc_sinc.set_antenna("A:AB", 1) self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_rms_xx_1 = blocks.rms_cf(1) self.blocks_rms_xx_0_0 = blocks.rms_cf(1) self.blocks_rms_xx_0 = blocks.rms_cf(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((RUN, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff( (gy_on, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (gz_on, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gx_on, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 5. / TR, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.Gz = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gy = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gx = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.Gx, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.Gy, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.Gz, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.syncwin, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.delay, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.s_delay, 0)) self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.s_delay, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.sync_data, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.m_delay, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0_2, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.signal_out, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.s_delay_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_float_to_complex_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blocks_float_to_complex_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0)) self.connect((self.blocks_threshold_ff_0_2, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.delay, 0), (self.m_delay, 0)) self.connect((self.delay1, 0), (self.ex_pulse, 0)) self.connect((self.delay1_0, 0), (self.ref_pulse, 0)) self.connect((self.delay3, 0), (self.readwin, 0)) self.connect((self.delay3_0_1, 0), (self.Gz, 0)) self.connect((self.delay3_0_1_0, 0), (self.Gy, 0)) self.connect((self.delay6, 0), (self.Gx, 0)) self.connect((self.ex_pulse, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.m_delay, 0), (self.rf_sink, 0)) self.connect((self.m_delay, 1), (self.rf_sink, 1)) self.connect((self.readwin, 0), (self.s_delay_0_0_0, 0)) self.connect((self.ref_pulse, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.s_delay, 0), (self.dc_sinc, 0)) self.connect((self.s_delay, 1), (self.s_delay_0, 0)) self.connect((self.s_delay_0, 0), (self.dc_sinc, 1)) self.connect((self.s_delay_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.s_delay_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_rms_xx_0_0, 0))
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError( 'Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff( 1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect(self, self.band_filter_block) # AM chain self.connect(self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect(self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect(self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self): gr.top_block.__init__(self, "VOR Decoder") Qt.QWidget.__init__(self) self.setWindowTitle("VOR Decoder") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vor_playback_sigmf_2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.throttle_rate = throttle_rate = 1 self.lo_cut = lo_cut = 1e3 self.hi_cut = hi_cut = 1050 self.fine = fine = 1e3 self.audio_rate = audio_rate = samp_rate/decim/25*24 self.audio_gain = audio_gain = 1 self.alpha = alpha = .02 ################################################## # Blocks ################################################## self._throttle_rate_tool_bar = Qt.QToolBar(self) self._throttle_rate_tool_bar.addWidget(Qt.QLabel("throttle_rate"+": ")) self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate)) self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit) self._throttle_rate_line_edit.returnPressed.connect( lambda: self.set_throttle_rate(eng_notation.str_to_num(str(self._throttle_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source('/captures/20191228/VOR_2019-12-28T19:07:15Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25*5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024*2, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 2, 4) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 256, #size audio_rate / 3 / 8, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.0010) self.qtgui_time_sink_x_0_0_0.set_y_axis(-180, 180) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, .25, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 6, 4, 2, 4) for r in range(6, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 8192 /2, #size samp_rate / decim /25 * 24, #samp_rate "30 Hz Variable", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.0010) self.qtgui_time_sink_x_0.set_y_axis(-4, 4) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['ref', 'var', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim / 25 * 24, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 3, 4, 1, 4) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 10, samp_rate / decim / 25 *24, 1e3, 500, firdes.WIN_HAMMING, 6.76)) self._lo_cut_tool_bar = Qt.QToolBar(self) self._lo_cut_tool_bar.addWidget(Qt.QLabel("lo_cut"+": ")) self._lo_cut_line_edit = Qt.QLineEdit(str(self.lo_cut)) self._lo_cut_tool_bar.addWidget(self._lo_cut_line_edit) self._lo_cut_line_edit.returnPressed.connect( lambda: self.set_lo_cut(eng_notation.str_to_num(str(self._lo_cut_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._lo_cut_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._hi_cut_tool_bar = Qt.QToolBar(self) self._hi_cut_tool_bar.addWidget(Qt.QLabel("hi_cut"+": ")) self._hi_cut_line_edit = Qt.QLineEdit(str(self.hi_cut)) self._hi_cut_tool_bar.addWidget(self._hi_cut_line_edit) self._hi_cut_line_edit.returnPressed.connect( lambda: self.set_hi_cut(eng_notation.str_to_num(str(self._hi_cut_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._hi_cut_tool_bar, 2, 6, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.goertzel_fc_0_0 = fft.goertzel_fc(int(audio_rate), 1024, 30) self.goertzel_fc_0 = fft.goertzel_fc(int(audio_rate), 1024, 30) self._fine_tool_bar = Qt.QToolBar(self) self._fine_tool_bar.addWidget(Qt.QLabel('Fine [Hz]'+": ")) self._fine_line_edit = Qt.QLineEdit(str(self.fine)) self._fine_tool_bar.addWidget(self._fine_line_edit) self._fine_line_edit.returnPressed.connect( lambda: self.set_fine(eng_notation.str_to_num(str(self._fine_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fine_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate*throttle_rate,True) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((180/math.pi, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, samp_rate / decim / 25 * 24 , 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, samp_rate / decim / 25 * 24 , 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel('vol30'+": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain(eng_notation.str_to_num(str(self._audio_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 1, 7, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 9960, 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(math.pi/200, math.pi/10, -math.pi/10) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=samp_rate / decim / 25 * 24, audio_decim=1, deviation=1e3, audio_pass=100, audio_stop=200, gain=1.0, tau=75e-6, ) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=12000, audio_stop=13000, ) self.analog_agc2_xx_2 = analog.agc2_ff(1e-4, 1e-4, 1, 1.0) self.analog_agc2_xx_2.set_max_gain(65536) self.analog_agc2_xx_1 = analog.agc2_ff(1e-4, 1e-4, 1, 1) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-2, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self._alpha_tool_bar = Qt.QToolBar(self) self._alpha_tool_bar.addWidget(Qt.QLabel('alpha'+": ")) self._alpha_line_edit = Qt.QLineEdit(str(self.alpha)) self._alpha_tool_bar.addWidget(self._alpha_line_edit) self._alpha_line_edit.returnPressed.connect( lambda: self.set_alpha(eng_notation.str_to_num(str(self._alpha_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._alpha_tool_bar, 1, 6, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_fm_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.dc_blocker_xx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.analog_agc2_xx_2, 0)) self.connect((self.goertzel_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self, baudrate, samp_rate, iq, f_offset=None, differential=False, manchester=False, dump_path=None, options=None): gr.hier_block2.__init__( self, "bpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex if iq else gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) options_block.__init__(self, options) if dump_path is not None: dump_path = pathlib.Path(dump_path) if manchester: baudrate *= 2 # prevent problems due to baudrate too high if baudrate >= samp_rate / 4: print( f'Sample rate {samp_rate} sps insufficient for {baudrate} baud BPSK demodulation. Demodulator will not work.', file=sys.stderr) baudrate = samp_rate / 4 sps = samp_rate / baudrate max_sps = 10 if sps > max_sps: decimation = ceil(sps / max_sps) else: decimation = 1 sps /= decimation filter_cutoff = baudrate * 2.0 filter_transition = baudrate * 0.2 if f_offset is None: f_offset = self.options.f_offset if f_offset is None: if iq: f_offset = 0 elif baudrate <= 2400: f_offset = 1500 else: f_offset = 12000 taps = firdes.low_pass(1, samp_rate, filter_cutoff, filter_transition) f = filter.freq_xlating_fir_filter_ccf if iq else filter.freq_xlating_fir_filter_fcf self.xlating = f(decimation, taps, f_offset, samp_rate) agc_constant = 2e-2 / sps # This gives a time constant of 50 symbols self.agc = rms_agc(agc_constant, 1) if dump_path is not None: self.agc_in = blocks.file_sink(gr.sizeof_gr_complex, str(dump_path / 'agc_in.c64'), False) self.agc_out = blocks.file_sink(gr.sizeof_gr_complex, str(dump_path / 'agc_out.c64'), False) self.connect(self.xlating, self.agc_in) self.connect(self.agc, self.agc_out) if not self.options.disable_fll: fll_bw = 2 * pi * decimation / samp_rate * self.options.fll_bw self.fll = digital.fll_band_edge_cc(sps, self.options.rrc_alpha, 100, fll_bw) if dump_path is not None: self.fll_freq = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_freq.f32'), False) self.fll_phase = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_phase.f32'), False) self.fll_error = blocks.file_sink( gr.sizeof_float, str(dump_path / 'fll_error.f32'), False) self.connect((self.fll, 1), self.fll_freq) self.connect((self.fll, 2), self.fll_phase) self.connect((self.fll, 3), self.fll_error) nfilts = 16 rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0 / float(sps), self.options.rrc_alpha, int(ceil(11 * sps * nfilts))) ted_gain = 0.5 # "empiric" formula for TED gain of a PFB MF TED for complex BPSK 0.5 sample^{-1} damping = 1.0 self.clock_recovery = digital.symbol_sync_cc( digital.TED_SIGNAL_TIMES_SLOPE_ML, sps, self.options.clk_bw, damping, ted_gain, self.options.clk_limit * sps, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, rrc_taps) if dump_path is not None: self.clock_recovery_out = blocks.file_sink( gr.sizeof_gr_complex, str(dump_path / 'clock_recovery_out.c64'), False) self.clock_recovery_err = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_err.f32'), False) self.clock_recovery_T_inst = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_T_inst.f32'), False) self.clock_recovery_T_avg = blocks.file_sink( gr.sizeof_float, str(dump_path / 'clock_recovery_T_avg.f32'), False) self.connect(self.clock_recovery, self.clock_recovery_out) self.connect((self.clock_recovery, 1), self.clock_recovery_err) self.connect((self.clock_recovery, 2), self.clock_recovery_T_inst) self.connect((self.clock_recovery, 3), self.clock_recovery_T_avg) self.connect(self, self.xlating, self.agc) if self.options.disable_fll: self.connect(self.agc, self.clock_recovery) else: self.connect(self.agc, self.fll, self.clock_recovery) self.complex_to_real = blocks.complex_to_real(1) if manchester: self.manchester = manchester_sync(self.options.manchester_history) self.connect(self.clock_recovery, self.manchester) else: self.manchester = self.clock_recovery if differential: self.delay = blocks.delay(gr.sizeof_gr_complex, 1) self.multiply_conj = blocks.multiply_conjugate_cc(1) sign = -1 if manchester else 1 self.multiply_const = blocks.multiply_const_ff( sign, 1) # take care about inverion in Manchester self.connect(self.manchester, (self.multiply_conj, 0)) self.connect(self.manchester, self.delay, (self.multiply_conj, 1)) self.connect(self.multiply_conj, self.complex_to_real, self.multiply_const, self) else: costas_bw = 2 * pi / baudrate * self.options.costas_bw self.costas = digital.costas_loop_cc(costas_bw, 2, False) if dump_path is not None: self.costas_out = blocks.file_sink( gr.sizeof_gr_complex, str(dump_path / 'costas_out.c64'), False) self.costas_frequency = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_frequency.f32'), False) self.costas_phase = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_phase.f32'), False) self.costas_error = blocks.file_sink( gr.sizeof_float, str(dump_path / 'costas_error.f32'), False) self.connect(self.costas, self.costas_out) self.connect((self.costas, 1), self.costas_frequency) self.connect((self.costas, 2), self.costas_phase) self.connect((self.costas, 3), self.costas_error) self.connect(self.manchester, self.costas, self.complex_to_real, self)
def __init__(self): gr.top_block.__init__(self, "Usrp Echotimer Fmcw Edited") Qt.QWidget.__init__(self) self.setWindowTitle("Usrp Echotimer Fmcw Edited") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "usrp_echotimer_fmcw_edited") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 40000000 self.sweep_freq = sweep_freq = samp_rate / 2 self.samp_up = samp_up = 2**15 self.wait_to_start = wait_to_start = 0.02 self.tx_gain = tx_gain = 40 self.threshold = threshold = -150 self.rx_gain = rx_gain = 60 self.range_time = range_time = 30 self.range_res = range_res = 3e8 / 2 / sweep_freq self.protect_samp = protect_samp = 0 self.min_output_buffer = min_output_buffer = int((samp_up) * 2) self.max_output_buffer = max_output_buffer = 0 self.freq_res_up = freq_res_up = samp_rate / samp_up self.delay_samp = delay_samp = 79 self.decim_fac = decim_fac = 2**3 self.center_freq = center_freq = 5.2e9 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 100, 1, 40, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 0, 0) self._threshold_range = Range(-150, 0, 1, -150, 200) self._threshold_win = RangeWidget(self._threshold_range, self.set_threshold, "threshold", "counter_slider", float) self.top_grid_layout.addWidget(self._threshold_win, 1, 0) self._rx_gain_range = Range(0, 100, 1, 60, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 1) self._protect_samp_range = Range(0, 100, 1, 0, 200) self._protect_samp_win = RangeWidget(self._protect_samp_range, self.set_protect_samp, "protect_samp", "counter_slider", float) self.top_grid_layout.addWidget(self._protect_samp_win, 1, 1) self._delay_samp_range = Range(0, 100, 1, 79, 200) self._delay_samp_win = RangeWidget(self._delay_samp_range, self.set_delay_samp, 'Number delay samples', "counter_slider", float) self.top_layout.addWidget(self._delay_samp_win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc( samp_rate, center_freq, int(delay_samp), '', '', 'internal', 'none', 'TX/RX', tx_gain, 0.1, wait_to_start, 0, '', '', 'internal', 'none', 'RX2', rx_gain, 0.1, wait_to_start, 0, "packet_len") (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(65536) self.radar_ts_fft_cc_1 = radar.ts_fft_cc(samp_up / decim_fac, "packet_len") self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c( samp_rate, samp_up, 0, 0, -sweep_freq / 2, sweep_freq, 1, "packet_len") (self.radar_signal_generator_fmcw_c_0).set_min_output_buffer(65536) self.radar_my_find_max_peak_c_0 = radar.my_find_max_peak_c( samp_rate / decim_fac, threshold, int(protect_samp), (), False, 44, "packet_len") self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 300, #size samp_rate / decim_fac, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-4, 4) self.qtgui_time_sink_x_1.set_y_label('power', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.epy_block_0 = epy_block_0.blk() self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decim_fac) (self.blocks_tagged_stream_multiply_length_0 ).set_min_output_buffer(65536) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(65536) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/tmatko/Desktop/grstuff/acquired-signals/time13.dat', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/tmatko/Desktop/grstuff/acquired-signals/phase13.dat', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.radar_my_find_max_peak_c_0, 'Msg out'), (self.epy_block_0, 'msg_in')) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.epy_block_0, 1), (self.blocks_file_sink_0_0, 0)) self.connect((self.epy_block_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.epy_block_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.radar_signal_generator_fmcw_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_signal_generator_fmcw_c_0, 0), (self.radar_usrp_echotimer_cc_0, 0)) self.connect((self.radar_ts_fft_cc_1, 0), (self.radar_my_find_max_peak_c_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))