def __init__(self): gr.top_block.__init__(self) input_sample_rate = 1e6 symbol_rate = 152.34e3 output_samples_per_symbol = 5 output_sample_rate = output_samples_per_symbol * symbol_rate # least common multiple lcm = gru.lcm(input_sample_rate, output_sample_rate) intrp = int(lcm // input_sample_rate) decim = int(lcm // output_sample_rate) print intrp print decim resampler = blks2.rational_resampler_ccc(intrp, decim, None, None) src = gr.file_source(gr.sizeof_gr_complex, "infile") sink = gr.file_sink(gr.sizeof_float, "outfile") f2c = gr.float_to_complex() c2r = gr.complex_to_real() #ddc_coeffs = \ #gr.firdes.low_pass (1.0, # gain #input_sample_rate, # sampling rate #2e3, # low pass cutoff freq #6e3, # width of trans. band #gr.firdes.WIN_HANN) # just grab the lower sideband: #ddc = gr.freq_xlating_fir_filter_ccf(1,ddc_coeffs,-111.5e3,input_sample_rate) qdemod = gr.quadrature_demod_cf(1.0) lp_coeffs = \ gr.firdes.low_pass (1.0, # gain output_sample_rate, # sampling rate symbol_rate, # low pass cutoff freq symbol_rate, # width of trans. band gr.firdes.WIN_HANN) lp = gr.fir_filter_fff(1, lp_coeffs) self.connect(src, resampler, qdemod, lp, sink)
def setUp (self): self.tb = gr.top_block () print "qa_block_tests" fftl = 512 I = 768 D = 1000 #mod=scipy.io.loadmat('/home/demel/exchange/matlab_mat_t.mat') #mat_u1=tuple(mod['mat_t'].flatten()) #mat_d=range(len(mat_u1)) #for idx, val in enumerate(mat_u1): # mat_d[idx]=val #intu1=tuple(mat_d) #print len(intu1)/fftl # source and conversion from float to char #self.src = gr.vector_source_c(intu1,False,fftl) #self.fft = gr.fft_vcc(fftl,True,window.rectangular(fftl),False,1) #self.snk = gr.vector_sink_c(fftl)Messung_LTE_2012-05-23_12:49:57_xae self.src = gr.file_source(gr.sizeof_gr_complex,'/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:49:57_xae.dat', False) self.resample = blks2.rational_resampler_ccc(I, D) self.snk = gr.file_sink(gr.sizeof_gr_complex, '/home/demel/Dokumente/LTE_Resample_test.dat') self.tb.connect(self.src,self.resample,self.snk)
def __init__(self): gr.top_block.__init__(self, "Resample measured data") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:47:32.dat", False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/home/demel/gr-lte/data/Messung_Resampled_3072MSps.dat") self.gr_file_sink_0.set_unbuffered(False) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=3072, decimation=1000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, which=''): gr.top_block.__init__(self, "Filter Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=3, decimation=7, taps=None, fractional_bw=None, ) self.fir_filter_xxx_0 = filter.fir_filter_ccc(7, ([.7]*23)) if which == 'dfir': self.filter = self.fir_filter_xxx_0 if which == 'resamp': self.filter = self.blks2_rational_resampler_xxx_0 ################################################## # Connections ################################################## self.connect((self.filter, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_null_source_0, 0), (self.filter, 0))
def __init__(self): gr.top_block.__init__(self) input_sample_rate = 1e6 symbol_rate = 152.34e3 output_samples_per_symbol = 5 output_sample_rate = output_samples_per_symbol * symbol_rate # least common multiple lcm = gru.lcm(input_sample_rate, output_sample_rate) intrp = int(lcm // input_sample_rate) decim = int(lcm // output_sample_rate) print intrp print decim resampler = blks2.rational_resampler_ccc(intrp, decim, None, None) src = gr.file_source(gr.sizeof_gr_complex, "infile") sink = gr.file_sink(gr.sizeof_float, "outfile") f2c = gr.float_to_complex() c2r = gr.complex_to_real() #ddc_coeffs = \ #gr.firdes.low_pass (1.0, # gain #input_sample_rate, # sampling rate #2e3, # low pass cutoff freq #6e3, # width of trans. band #gr.firdes.WIN_HANN) # just grab the lower sideband: #ddc = gr.freq_xlating_fir_filter_ccf(1,ddc_coeffs,-111.5e3,input_sample_rate) qdemod = gr.quadrature_demod_cf(1.0) lp_coeffs = \ gr.firdes.low_pass (1.0, # gain output_sample_rate, # sampling rate symbol_rate, # low pass cutoff freq symbol_rate, # width of trans. band gr.firdes.WIN_HANN) lp = gr.fir_filter_fff (1,lp_coeffs) self.connect(src,resampler,qdemod,lp,sink)
def __init__(self): gr.top_block.__init__(self, "LTE hierarchical Flowgraph") ################################################## # Variables ################################################## self.style = style = "tx_diversity" self.samp_rate = samp_rate = 7.68e6 self.fftlen = fftlen = 512 self.N_rb_dl = N_rb_dl = 6 ################################################## # Blocks ################################################## self.ext = lte_pbch_extraction( N_rb_dl=6, style=style, ) self.eq = demod_and_eq( fftlen=512, N_rb_dl=6, ) self.daemon = lte.cell_id_daemon(self.eq.eq.eq, self.ext.demux, self.ext.descr) self.synchronization_0 = synchronization( fftlen=512, daemon="daemon", ) self.lte_mib_unpack_vb_0 = lte.mib_unpack_vb() self.lte_bch_decode_0 = lte_bch_decode() self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_file_source_0 = gr.file_source( gr.sizeof_gr_complex * 1, "/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:47:32.dat", False) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=768, decimation=1000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.eq, 2), (self.ext, 2)) self.connect((self.eq, 1), (self.ext, 1)) self.connect((self.eq, 0), (self.ext, 0)) self.connect((self.synchronization_0, 0), (self.eq, 0)) self.connect((self.ext, 0), (self.lte_bch_decode_0, 0)) self.connect((self.lte_bch_decode_0, 1), (self.lte_mib_unpack_vb_0, 1)) self.connect((self.lte_bch_decode_0, 0), (self.lte_mib_unpack_vb_0, 0)) self.connect((self.gr_throttle_0, 0), (self.synchronization_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500e3 ################################################## # Blocks ################################################## self.blks2_nbfm_tx_0 = blks2.nbfm_tx( audio_rate=25000, quad_rate=100000, tau=75e-6, max_dev=5e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, 6.9e3, 1, 0) self.gr_wavfile_source_0 = gr.wavfile_source("classical.wav", True) self.uhd_single_usrp_sink_0 = uhd.single_usrp_sink( device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_single_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_single_usrp_sink_0.set_center_freq(462.5625e6, 0) self.uhd_single_usrp_sink_0.set_gain(30, 0) ################################################## # Connections ################################################## self.connect((self.gr_wavfile_source_0, 0), (self.blks2_nbfm_tx_0, 0)) self.connect((self.blks2_nbfm_tx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.uhd_single_usrp_sink_0, 0))
def __init__(self,Freq): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 195.312e3 self.FM_freq = FM_freq = Freq.value self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((30e-6, )) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "/home/kranthi/documents/sound_cognition/test.raw", True) self.blks2_wfm_tx_0 = blks2.wfm_tx( audio_rate=32000, quad_rate=800000, tau=75e-6, max_dev=75e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=2, taps=None, fractional_bw=None, ) # print "#####Start of transmitter########" ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_wfm_tx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_file_source_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_wfm_tx_0, 0))
def __init__(self, app, samp_rate, inter, dec, filename): ''' in: - app = object of type RXApp - samp_rate = sample rate in Hertz - inter = interpolation factor - dec = decimation factor - filename output - port 0 = MF ''' gr.hier_block2.__init__(self, "RXData", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) # instance variables self.filename = filename self.isRecording = False self.app = app # "bandpass" to new sample rate # cleaning the out-of-band interferences, low pass filter around the shape lowPassTaps = firdes.low_pass(1, samp_rate, samp_rate/2, samp_rate/20, firdes.WIN_HAMMING, 6.76) self.lowPass = gr.multiply_const_vcc([1, ]) #gr.fir_filter_ccc(1, lowPassTaps) #Matched Filter # self.matched = gr.multiply_const_cc(1) #RXMatchedFilter(1, 20, 1, 0.8, 10) # resampler after Matched-filter self.resampler = blks2.rational_resampler_ccc( interpolation=inter, decimation=dec, taps=None, fractional_bw=None, ) # saving the IQ samples self.fileSink = gr.file_sink(gr.sizeof_gr_complex*1, self.filename) if(self.filename <> None and len(self.filename) > 0) else None #EO instance variables self.__makeConnections()
def __init__(self,StartAdr,SizeCU,Level,kbps): grc_wxgui.top_block_gui.__init__(self, title="Top Block") TabPunct = [[ 32, 5, 3, 4, 17, 0, 5, 3, 2, 1, 0], # Tabelle fuer Depuncturing ETSI EN 300 401 Seite 134 [ 32, 4, 3, 3, 18, 0, 11, 6, 5, 1, 0], [ 32, 3, 3, 4, 14, 3, 15, 9, 6, 8, 0], [ 32, 2, 3, 4, 14, 3, 22, 13, 8, 13, 0], [ 32, 1, 3, 5, 13, 3, 24, 17, 12, 17, 4], [ 48, 5, 4, 3, 26, 3, 5, 4, 2, 3, 0], [ 48, 4, 3, 4, 26, 3, 9, 6, 4, 6, 0], [ 48, 3, 3, 4, 26, 3, 15, 10, 6, 9, 4], [ 48, 2, 3, 4, 26, 3, 24, 14, 8, 15, 0], [ 48, 1, 3, 5, 25, 3, 24, 18, 13, 18, 0], [ 56, 5, 6, 10, 23, 3, 5, 4, 2, 3, 0], [ 56, 4, 6, 10, 23, 3, 9, 6, 4, 5, 0], [ 56, 3, 6, 12, 21, 3, 16, 7, 6, 9, 0], [ 56, 2, 6, 10, 23, 3, 23, 13, 8, 13, 8], [ 64, 5, 6, 9, 31, 2, 5, 3, 2, 3, 0], [ 64, 4, 6, 9, 33, 0, 11, 6, 5, 1, 0], [ 64, 3, 6, 12, 27, 3, 16, 8, 6, 9, 0], [ 64, 2, 6, 10, 29, 3, 23, 13, 8, 13, 8], [ 64, 1, 6, 11, 28, 3, 24, 18, 12, 18, 4], [ 80, 5, 6, 10, 41, 3, 6, 3, 2, 3, 0], [ 80, 4, 6, 10, 41, 3, 11, 6, 5, 6, 0], [ 80, 3, 6, 11, 40, 3, 16, 8, 6, 7, 0], [ 80, 2, 6, 10, 41, 3, 23, 13, 8, 13, 8], [ 80, 1, 6, 10, 41, 3, 24, 17, 12, 18, 4], [ 96, 5, 7, 9, 53, 3, 5, 4, 2, 4, 0], [ 96, 4, 7, 10, 52, 3, 9, 6, 4, 6, 0], [ 96, 3, 6, 12, 51, 3, 16, 9, 6, 10, 4], [ 96, 2, 6, 10, 53, 3, 22, 12, 9, 12, 0], [ 96, 1, 6, 13, 50, 3, 24, 18, 13, 19, 0], [112, 5, 14, 17, 50, 3, 5, 4, 2, 5, 0], [112, 4, 11, 21, 49, 3, 9, 6, 4, 8, 0], [112, 3, 11, 23, 47, 3, 16, 8, 6, 9, 0], [112, 2, 11, 21, 49, 3, 23, 12, 9, 14, 4], [128, 5, 12, 19, 62, 3, 5, 3, 2, 4, 0], [128, 4, 11, 21, 61, 3, 11, 6, 5, 7, 0], [128, 3, 11, 22, 60, 3, 16, 9, 6, 10, 4], [128, 2, 11, 21, 61, 3, 22, 12, 9, 14, 0], [128, 1, 11, 20, 62, 3, 24, 17, 13, 19, 8], [160, 5, 11, 19, 87, 3, 5, 4, 2, 4, 0], [160, 4, 11, 23, 83, 3, 11, 6, 5, 9, 0], [160, 3, 11, 24, 82, 3, 16, 8, 6, 11, 0], [160, 2, 11, 21, 85, 3, 22, 11, 9, 13, 0], [160, 1, 11, 22, 84, 3, 24, 18, 12, 19, 0], [192, 5, 11, 20, 110, 3, 6, 4, 2, 5, 0], [192, 4, 11, 22, 108, 3, 10, 6, 4, 9, 0], [192, 3, 11, 24, 106, 3, 16, 10, 6, 11, 0], [192, 2, 11, 20, 110, 3, 22, 13, 9, 13, 8], [192, 1, 11, 21, 109, 3, 24, 20, 13, 24, 0], [224, 5, 12, 22, 131, 3, 8, 6, 2, 6, 4], [224, 4, 12, 26, 127, 3, 12, 8, 4, 11, 0], [224, 3, 11, 20, 134, 3, 16, 10, 7, 9, 0], [224, 2, 11, 22, 132, 3, 24, 16, 10, 15, 0], [224, 1, 11, 24, 130, 3, 24, 20, 12, 20, 4], [256, 5, 11, 24, 154, 3, 6, 5, 2, 5, 0], [256, 4, 11, 24, 154, 3, 12, 9, 5, 10, 4], [256, 3, 11, 27, 151, 3, 16, 10, 7, 10, 0], [256, 2, 11, 22, 156, 3, 24, 14, 10, 13, 8], [256, 1, 11, 26, 152, 3, 24, 19, 14, 18,4], [320, 5, 11, 26, 200, 3, 8, 5, 2, 6,4], [320, 4, 11, 25, 201, 3, 13, 9, 5, 10,8], [320, 2, 11, 26, 200, 3, 24, 17, 9, 17,0], [384, 5, 11, 27, 247, 3, 8, 6, 2, 7,0], [384, 3, 11, 24, 250, 3, 16, 9, 7, 10,4], [384, 1, 12, 28, 245, 3, 24, 20, 14, 23,8]] for x in range(64): # Werte aus Tabelle herauslesen if (TabPunct[x][0]==kbps) and (TabPunct[x][1]==Level): L1 = TabPunct[x][2] L2 = TabPunct[x][3] L3 = TabPunct[x][4] L4 = TabPunct[x][5] PI1 = TabPunct[x][6] PI2 = TabPunct[x][7] PI3 = TabPunct[x][8] PI4 = TabPunct[x][9] ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 fftsize = 2048 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) # Quelle self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(227360000, 0) # 194064000,227360000 self.uhd_usrp_source_0.set_gain(31.5, 0) self.throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*1) # Resampler fuer 2.000 MS/s -> 2.048 MS/s self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=128, decimation=125, taps=None, fractional_bw=None, ) # Framestarts detektieren self.framestart_detecter_cc = howto.framestart_detecter_cc(fftsize,504,76) # OFDM Symbole herausarbeiten self.ofdm_symbole = howto.ofdm_symbol_cutter_cc(196608,fftsize,504,76,150) # FFT des Symbols bilden self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, 2048) # FFT eines Symbols self.fft_vcc = gr.fft_vcc(fftsize, # FFT groesse True, # forward FFT [], # Window True) # Shift # Symbol-Differenz bilden self.diff = howto.de_diff_mod_vcc(fftsize,256) # Anzeige der Modulation self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=791, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.freq_interl = howto.de_freq_interleaver_vcf(2048,1536) # FFT Size = 2048, Subcarrier = 1536 self.null_symbol_resample = howto.null_symbol_resample_bb(2048) # Anpassung fuer Mode 1 erzeugen self.subCha = howto.sub_channel_vff(1536,StartAdr,SizeCU) # Subcarrier = 1536 self.timeInt = howto.time_interleaving_vff(SizeCU) # Time Interleaving self.depunct_fic = howto.depuncturing_vff(SizeCU,PI1,L1,PI2,L2,PI3,L3,PI4,L4) # Depuncturing self.viterbi = howto.viterbi_vfb((L1+L2+L3+L4)*32*4+4*6) # Viterbi + Tail self.energy_disp = howto.energy_disp_vbb((L1+L2+L3+L4)*32+6) # Energy dispersal anwenden self.prearrangement = howto.prearrangement_vbb((L1+L2+L3+L4)*32) # Bitwert zu Bytewert umwandeln self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( # TCP Abfluss itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9999, server=True, ) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), self.blks2_rational_resampler_xxx_0) self.connect(self.blks2_rational_resampler_xxx_0, self.framestart_detecter_cc, (self.ofdm_symbole,1)) # Framestart detektion self.connect(self.blks2_rational_resampler_xxx_0, (self.ofdm_symbole,0)) # Symbole herausarbeiten self.connect((self.ofdm_symbole,0), self.s2v, self.fft_vcc, self.diff) # FFT und Div Demod self.connect((self.diff, 1), (self.wxgui_scopesink2_0, 0)) # Modulationsgrafik self.connect((self.ofdm_symbole,1), self.null_symbol_resample, (self.subCha,1)) # Framestart-Signalisierung self.connect((self.diff, 0), self.freq_interl) # Frequenz interleaving self.connect(self.freq_interl, (self.subCha,0)) # MSC und FIC bilden''' self.connect((self.subCha,0), self.timeInt) # MSC self.connect(self.timeInt, self.depunct_fic) # Time interleaving self.connect(self.depunct_fic, self.viterbi) # Depuncturing self.connect(self.viterbi,self.energy_disp) # Viterbi self.connect(self.energy_disp,self.prearrangement) # Energy dispersal self.connect(self.prearrangement,self.blks2_tcp_sink_0) # Prearrangement fuer TCP self.v2s = gr.vector_to_stream(gr.sizeof_float, 2304/8) self.vector_sink_f = gr.vector_sink_f(1) #test self.connect((self.subCha,1), self.v2s, self.vector_sink_f) # Test
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm1") _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_freq_slider = base_freq_slider = 88.5e6 ################################################## # Blocks ################################################## _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label='frq_offset', converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-200000, maximum=200000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) _base_freq_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._base_freq_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_base_freq_slider_sizer, value=self.base_freq_slider, callback=self.set_base_freq_slider, label='base_freq_slider', converter=forms.float_converter(), proportion=0, ) self._base_freq_slider_slider = forms.slider( parent=self.GetWin(), sizer=_base_freq_slider_sizer, value=self.base_freq_slider, callback=self.set_base_freq_slider, minimum=88e6, maximum=108e6, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_base_freq_slider_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=2, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) 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=512, fft_rate=1, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_bandwidth(200000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_freq_slider) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(1) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(1, (10, ), frq_offset, samp_rate) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=48000, audio_decimation=1, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48000, decimation=1000000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.audio_sink_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
def setUp(self): #print os.getpid() #raw_input("Press the ANY key to continue") setuptime = time.clock() self.tb = gr.top_block() print "\nqa_multi_block_test START" offset = 1133 fftl = 512 cell_id = 124 N_rb_dl = 6 I = 768 D = 1000 # This first part is for syncing! #self.src = gr.vector_source_c(intu,False,1) infile1 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:48:19.dat' # successful! infile2 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:48:07.dat' # failed! infile3 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:46:30.dat' # successful! infile4 = '/home/johannes/lte/data/Messung_LTE_2012-05-23_12:47:32.dat' # successful! infile5 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:49:57.dat' # successful! samps = (fftl * 7 * 2 * 10 + 10 * fftl) * 300 + offset input_file = infile3 print input_file self.src = gr.file_source(gr.sizeof_gr_complex, input_file, False) self.resample = blks2.rational_resampler_ccc(I, D) self.head1 = gr.head(gr.sizeof_gr_complex, samps) #self.tag = lte_swig.tag_symbol_cc(offset,fftl) self.sync = lte_swig.cp_time_freq_sync_cc(fftl) self.pss = lte.hier_pss_sync_cc(fftl) self.est = lte.hier_freq_estimate_cc(fftl) # This is the actual place to initialize self.sss # Nevertheless it it the last block to be initialized because it needs pointers to some others. # self.sss = lte.hier_sss_sync_cc(fftl) #This part does still process all data (more ore less) self.rcp = lte_swig.remove_cp_cvc(fftl) self.fft = gr.fft_vcc(fftl, True, window.rectangular(fftl), False, 1) self.ext = lte_swig.extract_occupied_tones_vcvc(N_rb_dl, fftl) self.eq = lte.linear_OFDM_estimator_hier_vcvc(N_rb_dl) #cell_id, #self.eq.set_cell_id(cell_id) #self.sh1 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) #self.sh2 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) #self.sh3 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) # After the next block only the PBCH is processed! self.demux = lte_swig.pbch_demux_vcvc(N_rb_dl) #cell_id, #self.demux.set_cell_id(cell_id) self.pd1 = lte_swig.pre_decoder_vcvc(1, 'tx_diversity') self.pd2 = lte_swig.pre_decoder_vcvc(2, 'tx_diversity') self.ldm1 = lte_swig.layer_demapper_vcvc(1, 'tx_diversity') self.ldm2 = lte_swig.layer_demapper_vcvc(2, 'tx_diversity') self.int = gr.interleave(240 * 8) self.dmd = lte_swig.qpsk_soft_demod_vcvf() self.ld = lte_swig.descrambling_vfvf() #self.ld.set_cell_id(cell_id) self.lru = lte_swig.rate_unmatch_vff() # After Viterbi decoding, only bits are processed! self.vit = lte.viterbi_vfvb() self.crc = lte_swig.crc_calculator_vbvb() self.mib = lte_swig.mib_unpack_vb() ############################################################# # This last block is just a daemon to propagate the calculated cell id ############################################################# self.daemon = lte.cell_id_daemon(self.eq.get_eq(), self.demux, self.ld) self.sss = lte.hier_sss_sync_cc(self.daemon, fftl) # declaration of additional sink blocks for tests #self.snk1 = gr.vector_sink_f(120) #self.snk2 = gr.vector_sink_b(40) # Connect all blocks together! self.tb.connect(self.src, self.resample, self.head1, self.sync, self.pss, self.est, self.sss, self.rcp, self.fft, self.ext, self.eq) # self.tb.connect((self.eq, 0), (self.demux, 0)) self.tb.connect((self.eq, 1), (self.demux, 1)) self.tb.connect((self.eq, 2), (self.demux, 2)) self.tb.connect((self.demux, 0), (self.pd1, 0)) self.tb.connect((self.demux, 1), (self.pd1, 1)) self.tb.connect((self.demux, 0), (self.pd2, 0)) self.tb.connect((self.demux, 1), (self.pd2, 1)) self.tb.connect((self.demux, 2), (self.pd2, 2)) self.tb.connect(self.pd1, self.ldm1, (self.int, 0)) self.tb.connect(self.pd2, self.ldm2, (self.int, 1)) self.tb.connect(self.int, self.dmd, self.ld, self.lru, self.vit, self.crc) self.tb.connect((self.crc, 0), (self.mib, 0)) self.tb.connect((self.crc, 1), (self.mib, 1)) # additional sink blocks for testing #self.tb.connect(self.lru,self.snk1) #self.tb.connect(self.vit,self.snk2) print "\n\nsetuptime = " + str(time.clock() - setuptime) + "\n\n"
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.volume = volume = .05 self.samp_rate = samp_rate = 32000 self.resamp_factor = resamp_factor = 4 ################################################## # 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=0, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=256000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((volume, )) self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex*1, "/media/technoworld/Study & SW/2nd SEM/Seminar/IMPLEMENTATION/am_usrp710.dat", True) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_fff( interpolation=3, decimation=resamp_factor, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=resamp_factor, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.gr_file_source_1, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_complex_to_mag_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_complex_to_mag_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, StartAdr, SizeCU, Level, kbps): grc_wxgui.top_block_gui.__init__(self, title="Top Block") TabPunct = [ [32, 5, 3, 4, 17, 0, 5, 3, 2, 1, 0], # Tabelle fuer Depuncturing ETSI EN 300 401 Seite 134 [32, 4, 3, 3, 18, 0, 11, 6, 5, 1, 0], [32, 3, 3, 4, 14, 3, 15, 9, 6, 8, 0], [32, 2, 3, 4, 14, 3, 22, 13, 8, 13, 0], [32, 1, 3, 5, 13, 3, 24, 17, 12, 17, 4], [48, 5, 4, 3, 26, 3, 5, 4, 2, 3, 0], [48, 4, 3, 4, 26, 3, 9, 6, 4, 6, 0], [48, 3, 3, 4, 26, 3, 15, 10, 6, 9, 4], [48, 2, 3, 4, 26, 3, 24, 14, 8, 15, 0], [48, 1, 3, 5, 25, 3, 24, 18, 13, 18, 0], [56, 5, 6, 10, 23, 3, 5, 4, 2, 3, 0], [56, 4, 6, 10, 23, 3, 9, 6, 4, 5, 0], [56, 3, 6, 12, 21, 3, 16, 7, 6, 9, 0], [56, 2, 6, 10, 23, 3, 23, 13, 8, 13, 8], [64, 5, 6, 9, 31, 2, 5, 3, 2, 3, 0], [64, 4, 6, 9, 33, 0, 11, 6, 5, 1, 0], [64, 3, 6, 12, 27, 3, 16, 8, 6, 9, 0], [64, 2, 6, 10, 29, 3, 23, 13, 8, 13, 8], [64, 1, 6, 11, 28, 3, 24, 18, 12, 18, 4], [80, 5, 6, 10, 41, 3, 6, 3, 2, 3, 0], [80, 4, 6, 10, 41, 3, 11, 6, 5, 6, 0], [80, 3, 6, 11, 40, 3, 16, 8, 6, 7, 0], [80, 2, 6, 10, 41, 3, 23, 13, 8, 13, 8], [80, 1, 6, 10, 41, 3, 24, 17, 12, 18, 4], [96, 5, 7, 9, 53, 3, 5, 4, 2, 4, 0], [96, 4, 7, 10, 52, 3, 9, 6, 4, 6, 0], [96, 3, 6, 12, 51, 3, 16, 9, 6, 10, 4], [96, 2, 6, 10, 53, 3, 22, 12, 9, 12, 0], [96, 1, 6, 13, 50, 3, 24, 18, 13, 19, 0], [112, 5, 14, 17, 50, 3, 5, 4, 2, 5, 0], [112, 4, 11, 21, 49, 3, 9, 6, 4, 8, 0], [112, 3, 11, 23, 47, 3, 16, 8, 6, 9, 0], [112, 2, 11, 21, 49, 3, 23, 12, 9, 14, 4], [128, 5, 12, 19, 62, 3, 5, 3, 2, 4, 0], [128, 4, 11, 21, 61, 3, 11, 6, 5, 7, 0], [128, 3, 11, 22, 60, 3, 16, 9, 6, 10, 4], [128, 2, 11, 21, 61, 3, 22, 12, 9, 14, 0], [128, 1, 11, 20, 62, 3, 24, 17, 13, 19, 8], [160, 5, 11, 19, 87, 3, 5, 4, 2, 4, 0], [160, 4, 11, 23, 83, 3, 11, 6, 5, 9, 0], [160, 3, 11, 24, 82, 3, 16, 8, 6, 11, 0], [160, 2, 11, 21, 85, 3, 22, 11, 9, 13, 0], [160, 1, 11, 22, 84, 3, 24, 18, 12, 19, 0], [192, 5, 11, 20, 110, 3, 6, 4, 2, 5, 0], [192, 4, 11, 22, 108, 3, 10, 6, 4, 9, 0], [192, 3, 11, 24, 106, 3, 16, 10, 6, 11, 0], [192, 2, 11, 20, 110, 3, 22, 13, 9, 13, 8], [192, 1, 11, 21, 109, 3, 24, 20, 13, 24, 0], [224, 5, 12, 22, 131, 3, 8, 6, 2, 6, 4], [224, 4, 12, 26, 127, 3, 12, 8, 4, 11, 0], [224, 3, 11, 20, 134, 3, 16, 10, 7, 9, 0], [224, 2, 11, 22, 132, 3, 24, 16, 10, 15, 0], [224, 1, 11, 24, 130, 3, 24, 20, 12, 20, 4], [256, 5, 11, 24, 154, 3, 6, 5, 2, 5, 0], [256, 4, 11, 24, 154, 3, 12, 9, 5, 10, 4], [256, 3, 11, 27, 151, 3, 16, 10, 7, 10, 0], [256, 2, 11, 22, 156, 3, 24, 14, 10, 13, 8], [256, 1, 11, 26, 152, 3, 24, 19, 14, 18, 4], [320, 5, 11, 26, 200, 3, 8, 5, 2, 6, 4], [320, 4, 11, 25, 201, 3, 13, 9, 5, 10, 8], [320, 2, 11, 26, 200, 3, 24, 17, 9, 17, 0], [384, 5, 11, 27, 247, 3, 8, 6, 2, 7, 0], [384, 3, 11, 24, 250, 3, 16, 9, 7, 10, 4], [384, 1, 12, 28, 245, 3, 24, 20, 14, 23, 8] ] for x in range(64): # Werte aus Tabelle herauslesen if (TabPunct[x][0] == kbps) and (TabPunct[x][1] == Level): L1 = TabPunct[x][2] L2 = TabPunct[x][3] L3 = TabPunct[x][4] L4 = TabPunct[x][5] PI1 = TabPunct[x][6] PI2 = TabPunct[x][7] PI3 = TabPunct[x][8] PI4 = TabPunct[x][9] ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 fftsize = 2048 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) # Quelle self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(227360000, 0) # 194064000,227360000 self.uhd_usrp_source_0.set_gain(31.5, 0) self.throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate * 1) # Resampler fuer 2.000 MS/s -> 2.048 MS/s self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=128, decimation=125, taps=None, fractional_bw=None, ) # Framestarts detektieren self.framestart_detecter_cc = howto.framestart_detecter_cc( fftsize, 504, 76) # OFDM Symbole herausarbeiten self.ofdm_symbole = howto.ofdm_symbol_cutter_cc( 196608, fftsize, 504, 76, 150) # FFT des Symbols bilden self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, 2048) # FFT eines Symbols self.fft_vcc = gr.fft_vcc( fftsize, # FFT groesse True, # forward FFT [], # Window True) # Shift # Symbol-Differenz bilden self.diff = howto.de_diff_mod_vcc(fftsize, 256) # Anzeige der Modulation self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=791, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.freq_interl = howto.de_freq_interleaver_vcf( 2048, 1536) # FFT Size = 2048, Subcarrier = 1536 self.null_symbol_resample = howto.null_symbol_resample_bb( 2048) # Anpassung fuer Mode 1 erzeugen self.subCha = howto.sub_channel_vff(1536, StartAdr, SizeCU) # Subcarrier = 1536 self.timeInt = howto.time_interleaving_vff(SizeCU) # Time Interleaving self.depunct_fic = howto.depuncturing_vff(SizeCU, PI1, L1, PI2, L2, PI3, L3, PI4, L4) # Depuncturing self.viterbi = howto.viterbi_vfb( (L1 + L2 + L3 + L4) * 32 * 4 + 4 * 6) # Viterbi + Tail self.energy_disp = howto.energy_disp_vbb( (L1 + L2 + L3 + L4) * 32 + 6) # Energy dispersal anwenden self.prearrangement = howto.prearrangement_vbb( (L1 + L2 + L3 + L4) * 32) # Bitwert zu Bytewert umwandeln self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( # TCP Abfluss itemsize=gr.sizeof_char * 1, addr="127.0.0.1", port=9999, server=True, ) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), self.blks2_rational_resampler_xxx_0) self.connect(self.blks2_rational_resampler_xxx_0, self.framestart_detecter_cc, (self.ofdm_symbole, 1)) # Framestart detektion self.connect(self.blks2_rational_resampler_xxx_0, (self.ofdm_symbole, 0)) # Symbole herausarbeiten self.connect((self.ofdm_symbole, 0), self.s2v, self.fft_vcc, self.diff) # FFT und Div Demod self.connect((self.diff, 1), (self.wxgui_scopesink2_0, 0)) # Modulationsgrafik self.connect((self.ofdm_symbole, 1), self.null_symbol_resample, (self.subCha, 1)) # Framestart-Signalisierung self.connect((self.diff, 0), self.freq_interl) # Frequenz interleaving self.connect(self.freq_interl, (self.subCha, 0)) # MSC und FIC bilden''' self.connect((self.subCha, 0), self.timeInt) # MSC self.connect(self.timeInt, self.depunct_fic) # Time interleaving self.connect(self.depunct_fic, self.viterbi) # Depuncturing self.connect(self.viterbi, self.energy_disp) # Viterbi self.connect(self.energy_disp, self.prearrangement) # Energy dispersal self.connect(self.prearrangement, self.blks2_tcp_sink_0) # Prearrangement fuer TCP self.v2s = gr.vector_to_stream(gr.sizeof_float, 2304 / 8) self.vector_sink_f = gr.vector_sink_f(1) #test self.connect((self.subCha, 1), self.v2s, self.vector_sink_f) # Test
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) 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.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq+frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 fftsize = 2048 ################################################## # Blocks ################################################## self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception( "Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(225648000) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(3) #self.rtl2832_source_0 = uhd.usrp_source( # device_addr="addr=192.168.10.2", # io_type=uhd.io_type.COMPLEX_FLOAT32, # num_channels=1, #) self.throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate * 1) # Resampler fuer 2.000 MS/s -> 2.048 MS/s self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=128, decimation=125, taps=None, fractional_bw=None, ) # Framestarts detektieren self.framestart_detecter_cc = howto.framestart_detecter_cc( fftsize, 504, 76) # OFDM Symbole herausarbeiten self.ofdm_symbole = howto.ofdm_symbol_cutter_cc( 196608, fftsize, 504, 76, 150) # FFT des Symbols bilden self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, 2048) # FFT eines Symbols self.fft_vcc = gr.fft_vcc( fftsize, # FFT groesse True, # forward FFT [], # Window True) # Shift # Symbol-Differenz bilden self.diff = howto.de_diff_mod_vcc(fftsize, 256) # Anzeige der Modulation self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=791, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.freq_interl = howto.de_freq_interleaver_vcf( 2048, 1536) # FFT Size = 2048, Subcarrier = 1536 self.null_symbol_resample = howto.null_symbol_resample_bb( 2048) # Anpassung fuer Mode 1 erzeugen self.subCha = howto.sub_channel_vff(1536, 188, 84) # Subcarrier = 1536 self.v2s_msc = gr.vector_to_stream(gr.sizeof_float, 84 * 64 / 8) # Abfluss fuer MSC self.vector_sink_msc = gr.null_sink(gr.sizeof_float * 1) self.bonder = howto.bonder_vff(2304 / 8, 2304) self.depunct_fic = howto.depuncturing_vff(36, 16, 21, 15, 3, 1, 0, 1, 0) # Depuncturing self.viterbi = howto.viterbi_vfb(3096) # Viterbi self.energy_disp_fic = howto.energy_disp_vbb( 774) # Energy dispersal anwenden self.fib_cutter = howto.cutter_vbb(768, 256) # FIBs bilden fib_crc16 = howto.fib_crc16_vbb(256) # CRC Check erzeugen self.fib_sink = howto.fib_sink_vb( ) # Serviceanzeige auf Konsole initialisieren ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), self.blks2_rational_resampler_xxx_0) self.connect(self.blks2_rational_resampler_xxx_0, self.framestart_detecter_cc, (self.ofdm_symbole, 1)) # Framestart detektion self.connect(self.blks2_rational_resampler_xxx_0, (self.ofdm_symbole, 0)) # Symbole herausarbeiten self.connect((self.ofdm_symbole, 0), self.s2v, self.fft_vcc, self.diff) # FFT und Div Demod self.connect((self.diff, 1), (self.wxgui_scopesink2_0, 0)) # Modulationsgrafik self.connect((self.ofdm_symbole, 1), self.null_symbol_resample, (self.subCha, 1)) # Framestart-Signalisierung self.connect((self.diff, 0), self.freq_interl) # Frequenz interleaving self.connect(self.freq_interl, (self.subCha, 0)) # MSC und FIC bilden''' self.connect((self.subCha, 0), self.v2s_msc, self.vector_sink_msc) # MSC self.connect((self.subCha, 1), self.bonder) # FIC zusammensetzen self.connect(self.bonder, self.depunct_fic) self.connect(self.depunct_fic, self.viterbi) # Depuncturing self.connect(self.viterbi, self.energy_disp_fic) # Viterbi self.connect(self.energy_disp_fic, self.fib_cutter) # Energy Dispersal self.connect(self.fib_cutter, fib_crc16) # FIBs bilden self.connect(fib_crc16, self.fib_sink) # FIB Sink
def __init__(self, options): gr.hier_block2.__init__( self, "ais_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char), ) # Output signature self._samples_per_symbol = options.samples_per_symbol self._bits_per_sec = options.bits_per_sec self._samplerate = self._samples_per_symbol * self._bits_per_sec self._gain_mu = options.gain_mu self._mu = options.mu self._omega_relative_limit = options.omega_relative_limit self.fftlen = options.fftlen # right now we are going to hardcode the different options for VA mode here. later on we can use configurable options samples_per_symbol_viterbi = 2 bits_per_symbol = 2 samples_per_symbol = 6 samples_per_symbol_clockrec = samples_per_symbol / bits_per_symbol BT = 0.4 data_rate = 9600.0 samp_rate = options.samp_rate self.gmsk_sync = gmsk_sync.square_and_fft_sync(self._samplerate, self._bits_per_sec, self.fftlen) if options.viterbi is True: # calculate the required decimation and interpolation to achieve the desired samples per symbol denom = gcd(data_rate * samples_per_symbol, samp_rate) cr_interp = int(data_rate * samples_per_symbol / denom) cr_decim = int(samp_rate / denom) self.resample = blks2.rational_resampler_ccc(cr_interp, cr_decim) # here we take a different tack and use A.A.'s CPM decomposition technique self.clockrec = gr.clock_recovery_mm_cc( samples_per_symbol_clockrec, 0.005 * 0.005 * 0.25, 0.5, 0.005, 0.0005 ) # might have to futz with the max. deviation (fsm, constellation, MF, N, f0T) = make_gmsk( samples_per_symbol_viterbi, BT ) # calculate the decomposition required for demodulation self.costas = gr.costas_loop_cc( 0.015, 0.015 * 0.015 * 0.25, 100e-6, -100e-6, 4 ) # does fine freq/phase synchronization. should probably calc the coeffs instead of hardcode them. self.streams2stream = gr.streams_to_stream(int(gr.sizeof_gr_complex * 1), int(N)) self.mf0 = gr.fir_filter_ccc( samples_per_symbol_viterbi, MF[0].conjugate() ) # two matched filters for decomposition self.mf1 = gr.fir_filter_ccc(samples_per_symbol_viterbi, MF[1].conjugate()) self.fo = gr.sig_source_c( samples_per_symbol_viterbi, gr.GR_COS_WAVE, -f0T, 1, 0 ) # the memoryless modulation component of the decomposition self.fomult = gr.multiply_cc(1) self.trellis = trellis.viterbi_combined_cb( fsm, int(data_rate), -1, -1, int(N), constellation, trellis.TRELLIS_EUCLIDEAN ) # the actual Viterbi decoder else: # this is probably not optimal and someone who knows what they're doing should correct me self.datafiltertaps = gr.firdes.root_raised_cosine( 10, # gain self._samplerate * 32, # sample rate self._bits_per_sec, # symbol rate 0.4, # alpha, same as BT? 50 * 32, ) # no. of taps self.datafilter = gr.fir_filter_fff(1, self.datafiltertaps) sensitivity = (math.pi / 2) / self._samples_per_symbol self.demod = gr.quadrature_demod_cf(sensitivity) # param is gain # self.clockrec = digital.clock_recovery_mm_ff(self._samples_per_symbol,0.25*self._gain_mu*self._gain_mu,self._mu,self._gain_mu,self._omega_relative_limit) self.clockrec = gr.pfb_clock_sync_ccf(self._samples_per_symbol, 0.04, self.datafiltertaps, 32, 0, 1.15) self.tcslicer = digital.digital.binary_slicer_fb() # self.dfe = digital.digital.lms_dd_equalizer_cc( # 32, # 0.005, # 1, # digital.digital.constellation_bpsk() # ) # self.delay = gr.delay(gr.sizeof_float, 64 + 16) #the correlator delays 64 bits, and the LMS delays some as well. self.slicer = digital.digital.binary_slicer_fb() # self.training_correlator = digital.correlate_access_code_bb("1100110011001100", 0) # self.cma = digital.cma_equalizer_cc # just a note here: a complex combined quad demod/slicer could be based on if's rather than an actual quad demod, right? # in fact all the constellation decoders up to QPSK could operate on complex data w/o doing the whole atan thing self.diff = gr.diff_decoder_bb(2) self.invert = ais.invert() # NRZI signal diff decoded and inverted should give original signal self.connect(self, self.gmsk_sync) if options.viterbi is False: self.connect(self.gmsk_sync, self.clockrec, self.demod, self.slicer, self.diff, self.invert, self) # self.connect(self.gmsk_sync, self.demod, self.clockrec, self.tcslicer, self.training_correlator) # self.connect(self.clockrec, self.delay, (self.dfe, 0)) # self.connect(self.training_correlator, (self.dfe, 1)) # self.connect(self.dfe, self.slicer, self.diff, self.invert, self) else: self.connect(self.gmsk_sync, self.costas, self.resample, self.clockrec) self.connect(self.clockrec, (self.fomult, 0)) self.connect(self.fo, (self.fomult, 1)) self.connect(self.fomult, self.mf0) self.connect(self.fomult, self.mf1) self.connect(self.mf0, (self.streams2stream, 0)) self.connect(self.mf1, (self.streams2stream, 1)) self.connect(self.streams2stream, self.trellis, self.diff, self.invert, self)
def __init__(self, app, samp_rate, inter, dec): ''' in: - app = object of type TXApp - samp_rate = sample rate in Herz - inter = interpolation factor - dec = decimation factor ''' gr.hier_block2.__init__(self, "TXGui", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) # instance variables self.app = app self.gui = wxgui.top_block_gui("BPSK TX", size=default_gui_size) self.nb = self.__createNoteBook() self.throttle = gr.throttle(gr.sizeof_gr_complex, samp_rate) # resampler if inter == 1 and dec == 1: self.resampler = gr.multiply_const_vcc((1,)) print("i: resampler not need") else: self.resampler = blks2.rational_resampler_ccc( interpolation=inter, decimation=dec, taps=None, fractional_bw=None, ) # samples self.fft = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-40, sample_rate= inter*samp_rate/dec, fft_size=512, fft_rate=10, average=True, avg_alpha=0.1, title="FFT Plot", peak_hold=False, ) self.scope_IQ = scopesink2.scope_sink_c( self.nb.GetPage(1).GetWin(), title="Scope IQ", sample_rate = inter*samp_rate/dec, v_scale=0.001, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, ) # adding the visual components to the notebook self.nb.GetPage(0).Add(self.fft.win) self.nb.GetPage(1).Add(self.scope_IQ.win) # phase self.cmp2arg = gr.complex_to_arg() self.fftPhase = fftsink2.fft_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-40, sample_rate= inter*samp_rate/dec, fft_size=512, fft_rate=10, average=True, avg_alpha=0.1, title="FFT phase Plot", peak_hold=False, ) self.scopePhase = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Scope phase", sample_rate = inter*samp_rate/dec, v_scale=0.001, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, ) # adding the visual components to the notebook self.nb.GetPage(2).Add(self.fftPhase.win) self.nb.GetPage(3).Add(self.scopePhase.win) self.__makeConnections()
def __init__(self, frame, panel, vbox, argv): # Graphical part stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) # Config_____ tx_frequency = 14085000 usrp_interpolation = 400 usrp_tx_rate = 128000000 tx_side = 0 tx_dev = 0 audio_rate = 32000 tx_subdev=(tx_side,tx_dev) usrp_tx_sample_rate = usrp_tx_rate / usrp_interpolation def rtty_gen_f(samplerate,speed,textdata): bitsamples=samplerate/speed mark = 900 shift = 170 space = mark+shift wavedata=[] letters = "_E\nA SIU\rDRJNFCKTZLWHYPQOBG_MXV_" figures = "_3\n- '87\r_4_,!:(5+)2$6019?&_./;_" keyshift = 0 for c in textdata: chartable = letters baudotdata='' shiftdata='' if((c >= '!') and (c <='9')): if(not keyshift): shiftdata = '[MMSMM]' keyshift=1 else: if(keyshift): shiftdata='[MMMMM]' keyshift=0 baudotdata = ']' + baudotdata if(keyshift): chartable = figures; baudotval=chartable.find(c) for b in (16,8,4,2,1): if(baudotval>=b): baudotdata = 'M' + baudotdata baudotval = baudotval-b else: baudotdata = 'S' + baudotdata baudotdata = shiftdata + '[' + baudotdata for bit in baudotdata: if(bit == 'M'): bitval = mark bitlen = 1 if(bit == 'S'): bitval = space bitlen = 1 if(bit == '['): bitval = space bitlen = 1 if(bit == ']'): bitval = mark bitlen = 1.5 for s in range(0,bitlen*bitsamples): wavedata.append(bitval) return gr.vector_source_f(wavedata, True) ryry = "RYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRY\r\n" callsign = "ZCZC DE PA3FKM PA3FKM -- RUNNING GNURADIO -- \r\n" fox = "+-- THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG --+\r\n " rttymsg = ryry+ryry+callsign+fox+"(0123456789)\r\n" callgever = rtty_gen_f(audio_rate,45,rttymsg) lpf_coeffs = gr.firdes.low_pass(1, audio_rate, 5000, 200) lpf = gr.fir_filter_fff (1, lpf_coeffs) fsk_f = gr.vco_f(audio_rate, 2*pi,0.5) fsk_c = gr.hilbert_fc(audio_rate/300) # IF low pass filter lpf_tx_coeffs = gr.firdes.low_pass(32000, audio_rate, 2000, 1000 ) # Interpolation to usrp sample frequency fsk_resample = blks2.rational_resampler_ccc( usrp_tx_sample_rate / audio_rate, 1, taps=lpf_tx_coeffs ) usrp_tx = usrp.sink_c(0,usrp_interpolation) self.usrp_tx = usrp_tx speaker = audio.sink(audio_rate, "plughw:0,0"); self.connect(callgever, lpf, fsk_f) self.connect(fsk_f, fsk_c, fsk_resample, usrp_tx) #self.connect(fsk_f, speaker) # Set Multiplexer mux = usrp.determine_tx_mux_value(usrp_tx,tx_subdev) usrp_tx.set_mux(mux) # Select subdevice usrp_tx_subdev = usrp.selected_subdev(usrp_tx,tx_subdev) # Tune subdevice usrp_tx.tune(usrp_tx_subdev._which,usrp_tx_subdev, tx_frequency) # Enable Transmitter (Required if using one of the Flex boards) usrp_tx_subdev.set_enable(True)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="APRS Receiver") ################################################## # Variables ################################################## self.space = space = 1200 self.mark = mark = 2200 self.xlate_decim = xlate_decim = 8 self.xlate_bandwidth = xlate_bandwidth = 1200*6 self.sym_dev = sym_dev = (mark-space)/2 self.samp_rate = samp_rate = 1e6 self.quad_rate = quad_rate = 96000 self.gain = gain = 10 self.freq_offset = freq_offset = 390e3 self.freq = freq = 144e6 self.baud = baud = 1200 self.audio_rate = audio_rate = 48000 self.audio_mul = audio_mul = 1 self.aprs_rate = aprs_rate = 12000 self.ant = ant = 'TX/RX' ################################################## # Message Queues ################################################## ax25_hdlc_framer_b_0_msgq_out = ax25_print_frame_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Baseband") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Signal") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Slicer") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Eye") self.Add(self.nb) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _freq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, label="Freq Offset", converter=forms.float_converter(), proportion=0, ) self._freq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, minimum=-500e3, maximum=500e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_offset_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), ) self.Add(self._freq_text_box) _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_mul_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, label="Audio", converter=forms.float_converter(), proportion=0, ) self._audio_mul_slider = forms.slider( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, minimum=0, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self._ant_chooser = forms.drop_down( parent=self.GetWin(), value=self.ant, callback=self.set_ant, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._ant_chooser) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-65, ref_scale=2.0, sample_rate=aprs_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=aprs_rate/10, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_0_0_0.win) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.05, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.5, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_freq_offset(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(ant, 0) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 1, aprs_rate, 2e3, 600, firdes.WIN_HAMMING, 6.76)) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(0.0001, 1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float*1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((audio_mul, )) self.gr_agc_xx_1 = gr.agc_ff(1e-3, 0.8, 0.1, 10.0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), freq_offset, samp_rate) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, .25 * (0.05)**2, 0.5, 0.005, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc( interpolation=quad_rate, decimation=int(samp_rate/xlate_decim), taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=aprs_rate, decimation=quad_rate, taps=None, fractional_bw=None, ) self.blks2_nbfm_rx_0_0 = blks2.nbfm_rx( audio_rate=audio_rate, quad_rate=quad_rate, tau=75e-6, max_dev=25000, ) self.blks2_nbfm_rx_0 = blks2.nbfm_rx( audio_rate=aprs_rate, quad_rate=quad_rate, tau=75e-6, max_dev=3e3, ) self.ax25_print_frame_0 = packetradio.queue_watcher_thread(ax25_print_frame_0_msgq_in) self.ax25_hdlc_framer_b_0 = packetradio.hdlc_framer(ax25_hdlc_framer_b_0_msgq_out, False) self.analog_sig_source_x_0 = analog.sig_source_c(aprs_rate, analog.GR_SIN_WAVE, -(min(mark,space)+sym_dev), 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(aprs_rate/(2*math.pi*sym_dev)) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ax25_hdlc_framer_b_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_nbfm_rx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.blks2_nbfm_rx_0_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_nbfm_rx_0_0, 0)) self.connect((self.gr_agc_xx_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0, 0))
def __init__(self, options): gr.hier_block2.__init__(self, "ais_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._samples_per_symbol = options.samples_per_symbol self._bits_per_sec = options.bits_per_sec self._samplerate = self._samples_per_symbol * self._bits_per_sec self._gain_mu = options.gain_mu self._mu = options.mu self._omega_relative_limit = options.omega_relative_limit self.fftlen = options.fftlen #right now we are going to hardcode the different options for VA mode here. later on we can use configurable options samples_per_symbol_viterbi = 2 bits_per_symbol = 2 samples_per_symbol = 6 samples_per_symbol_clockrec = samples_per_symbol / bits_per_symbol BT = 0.4 data_rate = 9600.0 samp_rate = options.samp_rate self.gmsk_sync = gmsk_sync.square_and_fft_sync(self._samplerate, self._bits_per_sec, self.fftlen) if(options.viterbi is True): #calculate the required decimation and interpolation to achieve the desired samples per symbol denom = gcd(data_rate*samples_per_symbol, samp_rate) cr_interp = int(data_rate*samples_per_symbol/denom) cr_decim = int(samp_rate/denom) self.resample = blks2.rational_resampler_ccc(cr_interp, cr_decim) #here we take a different tack and use A.A.'s CPM decomposition technique self.clockrec = gr.clock_recovery_mm_cc(samples_per_symbol_clockrec, 0.005*0.005*0.25, 0.5, 0.005, 0.0005) #might have to futz with the max. deviation (fsm, constellation, MF, N, f0T) = make_gmsk(samples_per_symbol_viterbi, BT) #calculate the decomposition required for demodulation self.costas = gr.costas_loop_cc(0.015, 0.015*0.015*0.25, 100e-6, -100e-6, 4) #does fine freq/phase synchronization. should probably calc the coeffs instead of hardcode them. self.streams2stream = gr.streams_to_stream(int(gr.sizeof_gr_complex*1), int(N)) self.mf0 = gr.fir_filter_ccc(samples_per_symbol_viterbi, MF[0].conjugate()) #two matched filters for decomposition self.mf1 = gr.fir_filter_ccc(samples_per_symbol_viterbi, MF[1].conjugate()) self.fo = gr.sig_source_c(samples_per_symbol_viterbi, gr.GR_COS_WAVE, -f0T, 1, 0) #the memoryless modulation component of the decomposition self.fomult = gr.multiply_cc(1) self.trellis = trellis.viterbi_combined_cb(fsm, int(data_rate), -1, -1, int(N), constellation, trellis.TRELLIS_EUCLIDEAN) #the actual Viterbi decoder else: #this is probably not optimal and someone who knows what they're doing should correct me self.datafiltertaps = gr.firdes.root_raised_cosine(10, #gain self._samplerate*32, #sample rate self._bits_per_sec, #symbol rate 0.4, #alpha, same as BT? 50*32) #no. of taps self.datafilter = gr.fir_filter_fff(1, self.datafiltertaps) sensitivity = (math.pi / 2) / self._samples_per_symbol self.demod = gr.quadrature_demod_cf(sensitivity) #param is gain #self.clockrec = digital.clock_recovery_mm_ff(self._samples_per_symbol,0.25*self._gain_mu*self._gain_mu,self._mu,self._gain_mu,self._omega_relative_limit) self.clockrec = gr.pfb_clock_sync_ccf(self._samples_per_symbol, 0.04, self.datafiltertaps, 32, 0, 1.15) self.tcslicer = digital.digital.binary_slicer_fb() # self.dfe = digital.digital.lms_dd_equalizer_cc( # 32, # 0.005, # 1, # digital.digital.constellation_bpsk() # ) # self.delay = gr.delay(gr.sizeof_float, 64 + 16) #the correlator delays 64 bits, and the LMS delays some as well. self.slicer = digital.digital.binary_slicer_fb() # self.training_correlator = digital.correlate_access_code_bb("1100110011001100", 0) # self.cma = digital.cma_equalizer_cc #just a note here: a complex combined quad demod/slicer could be based on if's rather than an actual quad demod, right? #in fact all the constellation decoders up to QPSK could operate on complex data w/o doing the whole atan thing self.diff = gr.diff_decoder_bb(2) self.invert = ais.invert() #NRZI signal diff decoded and inverted should give original signal self.connect(self, self.gmsk_sync) if(options.viterbi is False): self.connect(self.gmsk_sync, self.clockrec, self.demod, self.slicer, self.diff, self.invert, self) #self.connect(self.gmsk_sync, self.demod, self.clockrec, self.tcslicer, self.training_correlator) #self.connect(self.clockrec, self.delay, (self.dfe, 0)) #self.connect(self.training_correlator, (self.dfe, 1)) #self.connect(self.dfe, self.slicer, self.diff, self.invert, self) else: self.connect(self.gmsk_sync, self.costas, self.resample, self.clockrec) self.connect(self.clockrec, (self.fomult, 0)) self.connect(self.fo, (self.fomult, 1)) self.connect(self.fomult, self.mf0) self.connect(self.fomult, self.mf1) self.connect(self.mf0, (self.streams2stream, 0)) self.connect(self.mf1, (self.streams2stream, 1)) self.connect(self.streams2stream, self.trellis, self.diff, self.invert, self)
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_1 = samp_rate_1 = 1024000 self.samp_rate_2 = samp_rate_2 = samp_rate_1/10 ################################################## # Blocks ################################################## self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=928000000, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate_1, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=908000000, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate_1, 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.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_clock_rate(918000000, uhd.ALL_MBOARDS) tr1 = uhd.tune_request(908e6, rf_freq=918e6, rf_freq_policy=uhd.tune_request.POLICY_MANUAL); tr2 = uhd.tune_request(928e6, rf_freq=918e6, rf_freq_policy=uhd.tune_request.POLICY_MANUAL); self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(1024000) #self.uhd_usrp_source_0.set_center_freq(908000000, 0) self.uhd_usrp_source_0.set_center_freq(tr1, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) #self.uhd_usrp_source_0.set_center_freq(928000000, 1) self.uhd_usrp_source_0.set_center_freq(tr2, 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.gr_throttle_0_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate_1) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate_1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=samp_rate_1/samp_rate_2/10, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=samp_rate_1/samp_rate_2/10, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.gr_throttle_0_0, 0)) self.connect((self.gr_throttle_0_0, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self, frame, panel, vbox, argv): # Graphical part stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) # Config_____ tx_frequency = 14085000 usrp_interpolation = 400 usrp_tx_rate = 128000000 tx_side = 0 tx_dev = 0 audio_rate = 32000 tx_subdev = (tx_side, tx_dev) usrp_tx_sample_rate = usrp_tx_rate / usrp_interpolation def rtty_gen_f(samplerate, speed, textdata): bitsamples = samplerate / speed mark = 900 shift = 170 space = mark + shift wavedata = [] letters = "_E\nA SIU\rDRJNFCKTZLWHYPQOBG_MXV_" figures = "_3\n- '87\r_4_,!:(5+)2$6019?&_./;_" keyshift = 0 for c in textdata: chartable = letters baudotdata = '' shiftdata = '' if ((c >= '!') and (c <= '9')): if (not keyshift): shiftdata = '[MMSMM]' keyshift = 1 else: if (keyshift): shiftdata = '[MMMMM]' keyshift = 0 baudotdata = ']' + baudotdata if (keyshift): chartable = figures baudotval = chartable.find(c) for b in (16, 8, 4, 2, 1): if (baudotval >= b): baudotdata = 'M' + baudotdata baudotval = baudotval - b else: baudotdata = 'S' + baudotdata baudotdata = shiftdata + '[' + baudotdata for bit in baudotdata: if (bit == 'M'): bitval = mark bitlen = 1 if (bit == 'S'): bitval = space bitlen = 1 if (bit == '['): bitval = space bitlen = 1 if (bit == ']'): bitval = mark bitlen = 1.5 for s in range(0, bitlen * bitsamples): wavedata.append(bitval) return gr.vector_source_f(wavedata, True) ryry = "RYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRYRY\r\n" callsign = "ZCZC DE PA3FKM PA3FKM -- RUNNING GNURADIO -- \r\n" fox = "+-- THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG --+\r\n " rttymsg = ryry + ryry + callsign + fox + "(0123456789)\r\n" callgever = rtty_gen_f(audio_rate, 45, rttymsg) lpf_coeffs = gr.firdes.low_pass(1, audio_rate, 5000, 200) lpf = gr.fir_filter_fff(1, lpf_coeffs) fsk_f = gr.vco_f(audio_rate, 2 * pi, 0.5) fsk_c = gr.hilbert_fc(audio_rate / 300) # IF low pass filter lpf_tx_coeffs = gr.firdes.low_pass(32000, audio_rate, 2000, 1000) # Interpolation to usrp sample frequency fsk_resample = blks2.rational_resampler_ccc(usrp_tx_sample_rate / audio_rate, 1, taps=lpf_tx_coeffs) usrp_tx = usrp.sink_c(0, usrp_interpolation) self.usrp_tx = usrp_tx speaker = audio.sink(audio_rate, "plughw:0,0") self.connect(callgever, lpf, fsk_f) self.connect(fsk_f, fsk_c, fsk_resample, usrp_tx) #self.connect(fsk_f, speaker) # Set Multiplexer mux = usrp.determine_tx_mux_value(usrp_tx, tx_subdev) usrp_tx.set_mux(mux) # Select subdevice usrp_tx_subdev = usrp.selected_subdev(usrp_tx, tx_subdev) # Tune subdevice usrp_tx.tune(usrp_tx_subdev._which, usrp_tx_subdev, tx_frequency) # Enable Transmitter (Required if using one of the Flex boards) usrp_tx_subdev.set_enable(True)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 fftsize = 2048 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) # Quelle self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(227360000, 0) # 194064000,227360000 self.uhd_usrp_source_0.set_gain(31.5, 0) self.throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*1) # Resampler fuer 2.000 MS/s -> 2.048 MS/s self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=128, decimation=125, taps=None, fractional_bw=None, ) # Framestarts detektieren self.framestart_detecter_cc = howto.framestart_detecter_cc(fftsize,504,76) # OFDM Symbole herausarbeiten self.ofdm_symbole = howto.ofdm_symbol_cutter_cc(196608,fftsize,504,76,150) # FFT des Symbols bilden self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, 2048) # FFT eines Symbols self.fft_vcc = gr.fft_vcc(fftsize, # FFT groesse True, # forward FFT [], # Window True) # Shift # Symbol-Differenz bilden self.diff = howto.de_diff_mod_vcc(fftsize,256) # Anzeige der Modulation self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=791, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.freq_interl = howto.de_freq_interleaver_vcf(2048,1536) # FFT Size = 2048, Subcarrier = 1536 self.null_symbol_resample = howto.null_symbol_resample_bb(2048) # Anpassung fuer Mode 1 erzeugen self.subCha = howto.sub_channel_vff(1536,188,84) # Subcarrier = 1536 self.v2s_msc = gr.vector_to_stream(gr.sizeof_float, 84*64/8) # Abfluss fuer MSC self.vector_sink_msc = gr.null_sink(gr.sizeof_float*1) self.bonder = howto.bonder_vff(2304/8,2304) self.depunct_fic = howto.depuncturing_vff(36,16,21,15,3,1,0,1,0) # Depuncturing self.viterbi = howto.viterbi_vfb(3096) # Viterbi self.energy_disp_fic = howto.energy_disp_vbb(774) # Energy dispersal anwenden self.fib_cutter = howto.cutter_vbb(768,256) # FIBs bilden fib_crc16 = howto.fib_crc16_vbb(256) # CRC Check self.fib_sink = howto.fib_sink3_vbf() # FIC Informationen auslesen self.dst_0 = gr.vector_sink_f() # Datenbank ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), self.blks2_rational_resampler_xxx_0) self.connect(self.blks2_rational_resampler_xxx_0, self.framestart_detecter_cc, (self.ofdm_symbole,1)) # Framestart detektion self.connect(self.blks2_rational_resampler_xxx_0, (self.ofdm_symbole,0)) # Symbole herausarbeiten self.connect((self.ofdm_symbole,0), self.s2v, self.fft_vcc, self.diff) # FFT und Div Demod self.connect((self.diff, 1), (self.wxgui_scopesink2_0, 0)) # Modulationsgrafik self.connect((self.ofdm_symbole,1), self.null_symbol_resample, (self.subCha,1)) # Framestart-Signalisierung self.connect((self.diff, 0), self.freq_interl) # Frequenz interleaving self.connect(self.freq_interl, (self.subCha,0)) # MSC und FIC bilden''' self.connect((self.subCha,0), self.v2s_msc, self.vector_sink_msc) # MSC self.connect((self.subCha,1), self.bonder) # FIC zusammensetzen self.connect(self.bonder, self.depunct_fic) self.connect(self.depunct_fic, self.viterbi) # Depuncturing self.connect(self.viterbi, self.energy_disp_fic) # Viterbi self.connect(self.energy_disp_fic, self.fib_cutter) # Energy Dispersal self.connect(self.fib_cutter, fib_crc16) # FIBs bilden self.connect(fib_crc16, self.fib_sink) # FIB Sink self.connect(self.fib_sink, self.dst_0) # Datenbank fuellen
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="AM Receiver") _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 = 1e6 self.offset_fine = offset_fine = 0 self.offset_coarse = offset_coarse = 0 self.freq = freq = 7200000 self.LO = LO = 0 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.width = width = 10000 self.trans = trans = 1500 self.rx_freq = rx_freq = LO+freq+(offset_coarse+offset_fine) self.rf_gain = rf_gain = 20 self.lo_freq = lo_freq = LO self.display_selector = display_selector = 0 self.af_gain = af_gain = 1 ################################################## # Blocks ################################################## _width_sizer = wx.BoxSizer(wx.VERTICAL) self._width_text_box = forms.text_box( parent=self.GetWin(), sizer=_width_sizer, value=self.width, callback=self.set_width, label="Filter", converter=forms.float_converter(), proportion=0, ) self._width_slider = forms.slider( parent=self.GetWin(), sizer=_width_sizer, value=self.width, callback=self.set_width, minimum=2000, maximum=40000, num_steps=760, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_width_sizer, 7, 0, 1, 1) _trans_sizer = wx.BoxSizer(wx.VERTICAL) self._trans_text_box = forms.text_box( parent=self.GetWin(), sizer=_trans_sizer, value=self.trans, callback=self.set_trans, label="Trans", converter=forms.float_converter(), proportion=0, ) self._trans_slider = forms.slider( parent=self.GetWin(), sizer=_trans_sizer, value=self.trans, callback=self.set_trans, minimum=500, maximum=5000, num_steps=900, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_trans_sizer, 8, 0, 1, 1) self._rx_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label="Receive", converter=forms.float_converter(), ) self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1) _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_fine_sizer, value=self.offset_fine, callback=self.set_offset_fine, label="Fine tune", converter=forms.float_converter(), proportion=0, ) self._offset_fine_slider = forms.slider( parent=self.GetWin(), sizer=_offset_fine_sizer, value=self.offset_fine, callback=self.set_offset_fine, minimum=-1000, maximum=1000, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2) _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_coarse_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_coarse_sizer, value=self.offset_coarse, callback=self.set_offset_coarse, label="Coarse tune", converter=forms.float_converter(), proportion=0, ) self._offset_coarse_slider = forms.slider( parent=self.GetWin(), sizer=_offset_coarse_sizer, value=self.offset_coarse, callback=self.set_offset_coarse, minimum=-120000, maximum=120000, num_steps=960, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2) self._display_selector_chooser = forms.drop_down( parent=self.GetWin(), value=self.display_selector, callback=self.set_display_selector, label="Spectrum", choices=[0, 1], labels=['Baseband','USRP'], ) self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1) _af_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._af_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, label="VOL", converter=forms.float_converter(), proportion=0, ) self._af_gain_slider = forms.slider( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, minimum=0, maximum=5, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_af_gain_sizer, 8, 1, 1, 1) self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), -(offset_coarse+offset_fine), samp_rate) self.rtlsdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) self.rtlsdr_source_c_0.set_sample_rate(samp_rate) self.rtlsdr_source_c_0.set_center_freq(31e6, 0) self.rtlsdr_source_c_0.set_freq_corr(0, 0) self.rtlsdr_source_c_0.set_gain_mode(0, 0) self.rtlsdr_source_c_0.set_gain(10, 0) self.rtlsdr_source_c_0.set_if_gain(24, 0) _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", 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=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1) self.low_pass_filter = gr.fir_filter_ccf(5, firdes.low_pass( 1, samp_rate, width/2, trans, firdes.WIN_HAMMING, 6.76)) self._lo_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.lo_freq, callback=self.set_lo_freq, label="LO", converter=forms.float_converter(), ) self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((af_gain, )) self.gr_agc2_xx_0 = gr.agc2_cc(0.1, 10e-6, 0.9, 1.0, 1.0) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="USRP", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 5, 1, 1, 1) self.fftsink = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=rx_freq*display_selector, y_per_div=10, y_divs=10, ref_level=0, ref_scale=13490.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.5, title="", peak_hold=False, size=(800,300), ) self.GridAdd(self.fftsink.win, 0, 0, 5, 4) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=441, decimation=500, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=44100, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(44100, "", True) ################################################## # Connections ################################################## self.connect((self.xlating_fir_filter, 0), (self.fftsink, 0)) self.connect((self.xlating_fir_filter, 0), (self.low_pass_filter, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.rtlsdr_source_c_0, 0), (self.xlating_fir_filter, 0))
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf(self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf(self.rate/self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,2,True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0 , self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self): gr.top_block.__init__(self, "LTE flowgraph") ################################################## # Variables ################################################## self.fftlen = fftlen = 2048 self.cpl0 = cpl0 = 160*fftlen/2048 self.cpl = cpl = 144*fftlen/2048 self.slotl = slotl = 7*fftlen+6*cpl+cpl0 self.samp_rate = samp_rate = slotl/0.0005 self.style = style = "tx_diversity" self.interp_val = interp_val = int(samp_rate/1e4) self.N_rb_dl = N_rb_dl = 6 ################################################## # Blocks ################################################## self.eq = lte.linear_OFDM_estimator_hier_vcvc(N_rb_dl) self.descr = lte.descrambling_vfvf() self.demux = lte.pbch_demux_vcvc(N_rb_dl) self.daemon = lte.cell_id_daemon(self.eq.eq, self.demux, self.descr) self.lte_viterbi_vfvb_0 = lte.viterbi_vfvb() self.lte_remove_cp_cvc_1 = lte.remove_cp_cvc(fftlen) self.lte_rate_unmatch_vff_0 = lte.rate_unmatch_vff() self.lte_qpsk_soft_demod_vcvf_0 = lte.qpsk_soft_demod_vcvf() self.lte_pre_decoder_vcvc_0_0 = lte.pre_decoder_vcvc(2, style) self.lte_pre_decoder_vcvc_0 = lte.pre_decoder_vcvc(1, style) self.lte_mib_unpack_vb_0 = lte.mib_unpack_vb() self.lte_layer_demapper_vcvc_0_0 = lte.layer_demapper_vcvc(2, style) self.lte_layer_demapper_vcvc_0 = lte.layer_demapper_vcvc(1, style) self.lte_hier_sss_sync_cc_0 = lte.hier_sss_sync_cc(self.daemon, fftlen) self.lte_hier_pss_sync_cc_0 = lte.hier_pss_sync_cc(fftlen) self.lte_hier_freq_estimate_cc_0 = lte.hier_freq_estimate_cc(fftlen) self.lte_extract_occupied_tones_vcvc_0 = lte.extract_occupied_tones_vcvc(N_rb_dl,fftlen) self.lte_crc_calculator_vbvb_0 = lte.crc_calculator_vbvb() self.lte_cp_time_freq_sync_cc_0 = lte.cp_time_freq_sync_cc(fftlen) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex*240) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:47:32.dat", False) self.fft_vxx_0 = fft.fft_vcc(fftlen, True, (window.rectangular(fftlen)), False, 1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=interp_val, decimation=1000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.lte_hier_freq_estimate_cc_0, 0), (self.lte_hier_sss_sync_cc_0, 0)) self.connect((self.gr_throttle_0, 0), (self.lte_cp_time_freq_sync_cc_0, 0)) self.connect((self.lte_hier_sss_sync_cc_0, 0), (self.lte_remove_cp_cvc_1, 0)) self.connect((self.fft_vxx_0, 0), (self.lte_extract_occupied_tones_vcvc_0, 0)) self.connect((self.lte_remove_cp_cvc_1, 0), (self.fft_vxx_0, 0)) self.connect((self.lte_pre_decoder_vcvc_0, 0), (self.lte_layer_demapper_vcvc_0, 0)) self.connect((self.lte_pre_decoder_vcvc_0_0, 0), (self.lte_layer_demapper_vcvc_0_0, 0)) self.connect((self.lte_layer_demapper_vcvc_0_0, 0), (self.gr_interleave_0, 1)) self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0_0, 1)) self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0, 1)) self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0, 0)) self.connect((self.demux, 2), (self.lte_pre_decoder_vcvc_0_0, 2)) self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0_0, 0)) self.connect((self.lte_qpsk_soft_demod_vcvf_0, 0), (self.descr, 0)) self.connect((self.gr_interleave_0, 0), (self.lte_qpsk_soft_demod_vcvf_0, 0)) self.connect((self.lte_layer_demapper_vcvc_0, 0), (self.gr_interleave_0, 0)) self.connect((self.descr, 0), (self.lte_rate_unmatch_vff_0, 0)) self.connect((self.lte_crc_calculator_vbvb_0, 1), (self.lte_mib_unpack_vb_0, 1)) self.connect((self.lte_crc_calculator_vbvb_0, 0), (self.lte_mib_unpack_vb_0, 0)) self.connect((self.lte_viterbi_vfvb_0, 0), (self.lte_crc_calculator_vbvb_0, 0)) self.connect((self.lte_rate_unmatch_vff_0, 0), (self.lte_viterbi_vfvb_0, 0)) self.connect((self.lte_cp_time_freq_sync_cc_0, 0), (self.lte_hier_pss_sync_cc_0, 0)) self.connect((self.lte_hier_pss_sync_cc_0, 0), (self.lte_hier_freq_estimate_cc_0, 0)) self.connect((self.lte_extract_occupied_tones_vcvc_0, 0), (self.eq, 0)) self.connect((self.eq, 0), (self.demux, 0)) self.connect((self.eq, 1), (self.demux, 1)) self.connect((self.eq, 2), (self.demux, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Tx Fifo") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 195.312e3 self.FM_freq = FM_freq = 96.5e6 ################################################## # 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), "Audio") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.Add(self.notebook_0) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label="FM Frequency", converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=87.5e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( 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="FFT Plot", peak_hold=False, win=window.hamming, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=FM_freq, 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.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(60, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((400e-6, )) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "/home/kranthi/documents/project/FM Transceiver Original/test.raw", True) self.blks2_wfm_tx_0 = blks2.wfm_tx( audio_rate=32000, quad_rate=800000, tau=75e-6, max_dev=75e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=2, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_wfm_tx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_file_source_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_wfm_tx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "LTE flowgraph") Qt.QWidget.__init__(self) self.setWindowTitle("LTE flowgraph") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.fftlen = fftlen = 512 self.cpl0 = cpl0 = 160*fftlen/2048 self.cpl = cpl = 144*fftlen/2048 self.slotl = slotl = 7*fftlen+6*cpl+cpl0 self.samp_rate = samp_rate = slotl/0.0005 self.style = style = "tx_diversity" self.interp_val = interp_val = int(samp_rate/1e4) self.N_rb_dl = N_rb_dl = 6 ################################################## # Blocks ################################################## self.eq = lte.linear_OFDM_equalizer_hier_vcvc(N_rb_dl) self.descr = lte.descrambling_vfvf() self.demux = lte.pbch_demux_vcvc(N_rb_dl) self.daemon = lte.cell_id_daemon(self.eq.eq, self.demux, self.descr) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) 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.lte_viterbi_vfvb_0 = lte.viterbi_vfvb() self.lte_remove_cp_cvc_1 = lte.remove_cp_cvc(fftlen) self.lte_rate_unmatch_vff_0 = lte.rate_unmatch_vff() self.lte_qpsk_soft_demod_vcvf_0 = lte.qpsk_soft_demod_vcvf() self.lte_pss_sync_hier_cc_0 = lte.pss_sync_hier_cc(fftlen) self.lte_pre_decoder_vcvc_0_0 = lte.pre_decoder_vcvc(2, style) self.lte_pre_decoder_vcvc_0 = lte.pre_decoder_vcvc(1, style) self.lte_mib_unpack_vb_0 = lte.mib_unpack_vb() self.lte_layer_demapper_vcvc_0_0 = lte.layer_demapper_vcvc(2, style) self.lte_layer_demapper_vcvc_0 = lte.layer_demapper_vcvc(1, style) self.lte_hier_sss_sync_cc_0 = lte.hier_sss_sync_cc(self.daemon, fftlen) self.lte_hier_freq_estimate_cc_0 = lte.hier_freq_estimate_cc(fftlen) self.lte_extract_occupied_tones_vcvc_0 = lte.extract_occupied_tones_vcvc(N_rb_dl,fftlen) self.lte_crc_calculator_vbvb_0 = lte.crc_calculator_vbvb() self.lte_cp_time_freq_sync_cc_0 = lte.cp_time_freq_sync_cc(fftlen) self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, 240) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex*240) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/demel/Dokumente/Messungen_31_10_2012/samples_12.5MSps_20dB.iq", False) self.fft_vxx_0 = fft.fft_vcc(fftlen, True, (window.rectangular(fftlen)), False, 1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=interp_val, decimation=1250, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.lte_hier_freq_estimate_cc_0, 0), (self.lte_hier_sss_sync_cc_0, 0)) self.connect((self.lte_pss_sync_hier_cc_0, 0), (self.lte_hier_freq_estimate_cc_0, 0)) self.connect((self.lte_cp_time_freq_sync_cc_0, 0), (self.lte_pss_sync_hier_cc_0, 0)) self.connect((self.gr_throttle_0, 0), (self.lte_cp_time_freq_sync_cc_0, 0)) self.connect((self.lte_hier_sss_sync_cc_0, 0), (self.lte_remove_cp_cvc_1, 0)) self.connect((self.fft_vxx_0, 0), (self.lte_extract_occupied_tones_vcvc_0, 0)) self.connect((self.lte_remove_cp_cvc_1, 0), (self.fft_vxx_0, 0)) self.connect((self.lte_extract_occupied_tones_vcvc_0, 0), (self.eq, 0)) self.connect((self.lte_pre_decoder_vcvc_0, 0), (self.lte_layer_demapper_vcvc_0, 0)) self.connect((self.eq, 0), (self.demux, 0)) self.connect((self.eq, 1), (self.demux, 1)) self.connect((self.eq, 2), (self.demux, 2)) self.connect((self.lte_pre_decoder_vcvc_0_0, 0), (self.lte_layer_demapper_vcvc_0_0, 0)) self.connect((self.lte_layer_demapper_vcvc_0_0, 0), (self.gr_interleave_0, 1)) self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0_0, 1)) self.connect((self.demux, 1), (self.lte_pre_decoder_vcvc_0, 1)) self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0, 0)) self.connect((self.demux, 2), (self.lte_pre_decoder_vcvc_0_0, 2)) self.connect((self.demux, 0), (self.lte_pre_decoder_vcvc_0_0, 0)) self.connect((self.lte_qpsk_soft_demod_vcvf_0, 0), (self.descr, 0)) self.connect((self.gr_interleave_0, 0), (self.lte_qpsk_soft_demod_vcvf_0, 0)) self.connect((self.lte_layer_demapper_vcvc_0, 0), (self.gr_interleave_0, 0)) self.connect((self.descr, 0), (self.lte_rate_unmatch_vff_0, 0)) self.connect((self.lte_crc_calculator_vbvb_0, 1), (self.lte_mib_unpack_vb_0, 1)) self.connect((self.lte_crc_calculator_vbvb_0, 0), (self.lte_mib_unpack_vb_0, 0)) self.connect((self.lte_viterbi_vfvb_0, 0), (self.lte_crc_calculator_vbvb_0, 0)) self.connect((self.lte_rate_unmatch_vff_0, 0), (self.lte_viterbi_vfvb_0, 0)) self.connect((self.gr_interleave_0, 0), (self.gr_vector_to_stream_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.qtgui_sink_x_0, 0))
def setUp (self): #print os.getpid() #raw_input("Press the ANY key to continue") setuptime = time.clock() self.tb = gr.top_block () print "\nqa_multi_block_test START" offset = 1133 fftl = 512 cell_id = 124 N_rb_dl = 6 I = 768 D = 1000 # This first part is for syncing! #self.src = gr.vector_source_c(intu,False,1) infile1 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:48:19.dat' # successful! infile2 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:48:07.dat' # failed! infile3 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:46:30.dat' # successful! infile4 = '/home/johannes/lte/data/Messung_LTE_2012-05-23_12:47:32.dat' # successful! infile5 = '/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:49:57.dat' # successful! samps = (fftl*7*2*10+10*fftl)*300 +offset input_file = infile3 print input_file self.src = gr.file_source(gr.sizeof_gr_complex,input_file, False) self.resample = blks2.rational_resampler_ccc(I, D) self.head1 = gr.head(gr.sizeof_gr_complex, samps) #self.tag = lte_swig.tag_symbol_cc(offset,fftl) self.sync = lte_swig.cp_time_freq_sync_cc(fftl) self.pss = lte.hier_pss_sync_cc(fftl) self.est = lte.hier_freq_estimate_cc(fftl) # This is the actual place to initialize self.sss # Nevertheless it it the last block to be initialized because it needs pointers to some others. # self.sss = lte.hier_sss_sync_cc(fftl) #This part does still process all data (more ore less) self.rcp = lte_swig.remove_cp_cvc(fftl) self.fft = gr.fft_vcc(fftl,True,window.rectangular(fftl),False,1) self.ext = lte_swig.extract_occupied_tones_vcvc(N_rb_dl,fftl) self.eq = lte.linear_OFDM_estimator_hier_vcvc(N_rb_dl)#cell_id, #self.eq.set_cell_id(cell_id) #self.sh1 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) #self.sh2 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) #self.sh3 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7) # After the next block only the PBCH is processed! self.demux= lte_swig.pbch_demux_vcvc(N_rb_dl)#cell_id, #self.demux.set_cell_id(cell_id) self.pd1 = lte_swig.pre_decoder_vcvc(1,'tx_diversity') self.pd2 = lte_swig.pre_decoder_vcvc(2,'tx_diversity') self.ldm1 = lte_swig.layer_demapper_vcvc(1,'tx_diversity') self.ldm2 = lte_swig.layer_demapper_vcvc(2,'tx_diversity') self.int = gr.interleave(240*8) self.dmd = lte_swig.qpsk_soft_demod_vcvf() self.ld = lte_swig.descrambling_vfvf() #self.ld.set_cell_id(cell_id) self.lru = lte_swig.rate_unmatch_vff() # After Viterbi decoding, only bits are processed! self.vit = lte.viterbi_vfvb() self.crc = lte_swig.crc_calculator_vbvb() self.mib = lte_swig.mib_unpack_vb() ############################################################# # This last block is just a daemon to propagate the calculated cell id ############################################################# self.daemon = lte.cell_id_daemon(self.eq.get_eq(),self.demux, self.ld) self.sss = lte.hier_sss_sync_cc(self.daemon, fftl) # declaration of additional sink blocks for tests #self.snk1 = gr.vector_sink_f(120) #self.snk2 = gr.vector_sink_b(40) # Connect all blocks together! self.tb.connect(self.src,self.resample,self.head1,self.sync,self.pss,self.est,self.sss,self.rcp,self.fft,self.ext,self.eq)# self.tb.connect( (self.eq,0), (self.demux,0) ) self.tb.connect( (self.eq,1), (self.demux,1) ) self.tb.connect( (self.eq,2), (self.demux,2) ) self.tb.connect( (self.demux,0) ,(self.pd1,0) ) self.tb.connect( (self.demux,1) ,(self.pd1,1) ) self.tb.connect( (self.demux,0) ,(self.pd2,0) ) self.tb.connect( (self.demux,1) ,(self.pd2,1) ) self.tb.connect( (self.demux,2) ,(self.pd2,2) ) self.tb.connect(self.pd1,self.ldm1,(self.int,0) ) self.tb.connect(self.pd2,self.ldm2,(self.int,1) ) self.tb.connect(self.int,self.dmd,self.ld,self.lru,self.vit,self.crc) self.tb.connect( (self.crc,0),(self.mib,0) ) self.tb.connect( (self.crc,1),(self.mib,1) ) # additional sink blocks for testing #self.tb.connect(self.lru,self.snk1) #self.tb.connect(self.vit,self.snk2) print "\n\nsetuptime = " + str(time.clock() - setuptime) + "\n\n"
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="APRS Receiver") ################################################## # Variables ################################################## self.space = space = 1200 self.mark = mark = 2200 self.xlate_decim = xlate_decim = 8 self.xlate_bandwidth = xlate_bandwidth = 1200 * 6 self.sym_dev = sym_dev = (mark - space) / 2 self.samp_rate = samp_rate = 1e6 self.quad_rate = quad_rate = 96000 self.gain = gain = 10 self.freq_offset = freq_offset = 390e3 self.freq = freq = 144e6 self.baud = baud = 1200 self.audio_rate = audio_rate = 48000 self.audio_mul = audio_mul = 1 self.aprs_rate = aprs_rate = 12000 self.ant = ant = 'TX/RX' ################################################## # Message Queues ################################################## ax25_hdlc_framer_b_0_msgq_out = ax25_print_frame_0_msgq_in = gr.msg_queue( 2) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Baseband") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Signal") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Slicer") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Eye") self.Add(self.nb) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _freq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, label="Freq Offset", converter=forms.float_converter(), proportion=0, ) self._freq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, minimum=-500e3, maximum=500e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_offset_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), ) self.Add(self._freq_text_box) _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_mul_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, label="Audio", converter=forms.float_converter(), proportion=0, ) self._audio_mul_slider = forms.slider( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, minimum=0, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self._ant_chooser = forms.drop_down( parent=self.GetWin(), value=self.ant, callback=self.set_ant, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._ant_chooser) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-65, ref_scale=2.0, sample_rate=aprs_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=aprs_rate / 10, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_0_0_0.win) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.05, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.5, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_freq_offset(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(ant, 0) self.low_pass_filter_0 = gr.fir_filter_ccf( 1, firdes.low_pass(1, aprs_rate, 2e3, 600, firdes.WIN_HAMMING, 6.76)) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff( 0.0001, 1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float * 1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((audio_mul, )) self.gr_agc_xx_1 = gr.agc_ff(1e-3, 0.8, 0.1, 10.0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)), freq_offset, samp_rate) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 10, .25 * (0.05)**2, 0.5, 0.005, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc( interpolation=quad_rate, decimation=int(samp_rate / xlate_decim), taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=aprs_rate, decimation=quad_rate, taps=None, fractional_bw=None, ) self.blks2_nbfm_rx_0_0 = blks2.nbfm_rx( audio_rate=audio_rate, quad_rate=quad_rate, tau=75e-6, max_dev=25000, ) self.blks2_nbfm_rx_0 = blks2.nbfm_rx( audio_rate=aprs_rate, quad_rate=quad_rate, tau=75e-6, max_dev=3e3, ) self.ax25_print_frame_0 = packetradio.queue_watcher_thread( ax25_print_frame_0_msgq_in) self.ax25_hdlc_framer_b_0 = packetradio.hdlc_framer( ax25_hdlc_framer_b_0_msgq_out, False) self.analog_sig_source_x_0 = analog.sig_source_c( aprs_rate, analog.GR_SIN_WAVE, -(min(mark, space) + sym_dev), 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( aprs_rate / (2 * math.pi * sym_dev)) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc( -70, 1e-1, 0, False) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc( -70, 1e-1, 0, False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ax25_hdlc_framer_b_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_nbfm_rx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.blks2_nbfm_rx_0_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_nbfm_rx_0_0, 0)) self.connect((self.gr_agc_xx_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) 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.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception( "Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq + frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc( sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, options): gr.top_block.__init__(self) self.rate = options.rate print "Samples per second is %i" % self.rate self._syms_per_sec = 3600; options.audiorate = 44100 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu=0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Tuning channel offset: %f" % options.offset self.freq = options.freq self.samp_rate = samp_rate = self.rate self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = 14000 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.channel_rate = channel_rate = 4800*samp_per_sym self.rtl = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) self.rtl.set_sample_rate(options.rate) self.rtl.set_center_freq(options.centerfreq, 0) self.rtl.set_freq_corr(options.ppm, 0) #self.rtl.set_gain_mode(1, 0) print "Channel Rate: %d Pre Channel Rate: %d" % (channel_rate, pre_channel_rate) self.centerfreq = options.centerfreq print "Setting center to (With Error): %fMHz" % (self.centerfreq - options.error) if not(self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: options.gain = 14 if options.bbgain is None: options.bbgain = 25 if options.ifgain is None: options.ifgain = 25 print "Setting RF gain to %i" % options.gain print "Setting BB gain to %i" % options.bbgain print "Setting IF gain to %i" % options.ifgain self.rtl.set_gain(options.gain, 0) self.rtl.set_if_gain(options.ifgain,0) self.rtl.set_bb_gain(options.bbgain,0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, self.xlate_bandwidth/2, 6000)), -options.offset, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/self.samp_per_sym,)*self.samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,3,True) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) #self.connect((self.analog_quadrature_demod_cf_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.rtl, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, talkgroup, options): gr.hier_block2.__init__( self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE * samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate / decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf( self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf( self.rate / self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff( 1, ((1.0 / samp_per_sym, ) * samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10.**(audio_mul / 10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ( "".join([ random.choice(string.letters + string.digits) for x in range(8) ]) ) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT, dsd.dsd_MOD_AUTO_SELECT, 3, 2, True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a') self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink( self.filename, 1, self.audiorate, 8 ) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0, self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self, app, gain, fc, samp_rate, inter, dec): ''' in: - app = object of type RXApp - gain = gain - samp_rate = sample rate in Hertz - inter = interpolation factor - dec = decimation factor ''' gr.hier_block2.__init__(self, "RXGui", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) # instance variables self.app = app self.gui = wxgui.top_block_gui("BPSK RX") self.nb = self.__createNoteBook() # controls self.gainTextBox = forms.text_box( parent=self.gui.GetWin(), value=gain, callback=self.setGain, label="gain", converter=forms.float_converter(), ) self.fcTextBox = forms.text_box( parent=self.gui.GetWin(), value=fc, callback=self.setFc, label="fc", converter=forms.float_converter(), ) self.startButton = wx.Button(self.gui.GetWin(), label="Record") self.startButton.Bind(wx.EVT_BUTTON, self.startRecording) # adding the visual components to the notebook self.gui.Add(self.gainTextBox) self.gui.Add(self.fcTextBox) self.gui.Add(self.startButton) #EO Controls # for port 1 Antenna samples (COMPLEX) self.throttleAn = gr.throttle(gr.sizeof_gr_complex, samp_rate) # resampler Antenna if inter == 1 and dec == 1: self.resamplerAn = gr.multiply_const_vcc((1,)) print("i: resamplerAn not need") else: self.resamplerAn = blks2.rational_resampler_ccc( interpolation=inter, decimation=dec, taps=None, fractional_bw=None, ) # self.cmp2arg1 = gr.complex_to_arg() self.fftAn = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-40, sample_rate= inter*samp_rate/dec, fft_size=512, fft_rate=10, average=True, avg_alpha=0.1, title="FFT Plot Antenna", peak_hold=False, ) self.scope_IQAn = scopesink2.scope_sink_c( self.nb.GetPage(1).GetWin(), title="Scope IQ Antenna", sample_rate = inter*samp_rate/dec, v_scale=0.001, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, ) # adding the visual components to the notebook self.nb.GetPage(0).Add(self.fftAn.win) self.nb.GetPage(1).Add(self.scope_IQAn.win) # for port 2 Matched filter (COMPLEX) self.throttleMF = gr.throttle(gr.sizeof_gr_complex, samp_rate) # resampler MF if inter == 1 and dec == 1: self.resamplerMF = gr.multiply_const_vcc((1,)) print("i: resamplerMF not need") else: self.resamplerMF = blks2.rational_resampler_ccc( interpolation=inter, decimation=dec, taps=None, fractional_bw=None, ) # self.cmp2arg1 = gr.complex_to_arg() self.fftMF = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-40, sample_rate= inter*samp_rate/dec, fft_size=512, fft_rate=10, average=True, avg_alpha=0.1, title="FFT Plot MF", peak_hold=False, ) self.scope_IQMF = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope IQ MF", sample_rate = inter*samp_rate/dec, v_scale=0.0005, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, ) # adding the visual components to the notebook self.nb.GetPage(2).Add(self.fftMF.win) self.nb.GetPage(3).Add(self.scope_IQMF.win) # end of MF self.__makeConnections()
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature #print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 5+1 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 2 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Message Queues ################################################## op25_fsk4_0_msgq_out = baz_message_callback_0_msgq_in = gr.msg_queue(2) op25_decoder_simple_0_msgq_out = op25_traffic_pane_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.op25_fsk4_0 = op25.op25_fsk4(channel_rate=channel_rate, auto_tune_msgq=op25_fsk4_0_msgq_out,) self.op25_decoder_simple_0 = op25.op25_decoder_simple(key="",traffic_msgq=op25_decoder_simple_0_msgq_out,) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf((channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 4000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = gr.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) self.baz_message_callback_0 = message_callback.message_callback(msgq=baz_message_callback_0_msgq_in, callback=auto_tune_offset , msg_part="arg1", custom_parts="", dummy=False) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. ################################################## # Connections ################################################## self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.op25_fsk4_0, 0)) self.connect((self.op25_fsk4_0, 0), (self.op25_decoder_simple_0, 0)) self.connect((self.op25_decoder_simple_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) ## Start self.connect(self, (self.gr_freq_xlating_fir_filter_xxx_0, 0)) ## End self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0,0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.variable_slider_0 = variable_slider_0 = 0 self.samp_rate = samp_rate = 500e3 ################################################## # Controls ################################################## _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, label="Volume", converter=forms.float_converter(), proportion=0, ) self._variable_slider_0_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_variable_slider_0_sizer) ################################################## # Blocks ################################################## self.audio_sink_0 = audio.sink(48000, "", True) self.blks2_nbfm_rx_0 = blks2.nbfm_rx( audio_rate=25000, quad_rate=100000, tau=75e-6, max_dev=15e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=48, decimation=25, taps=None, fractional_bw=None, ) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((variable_slider_0, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vcc((100e3, )) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 10, samp_rate, 5e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.uhd_single_usrp_source_0 = uhd.single_usrp_source( device_addr="addr=192.168.10.3", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_single_usrp_source_0.set_samp_rate(samp_rate) self.uhd_single_usrp_source_0.set_center_freq(462.5625e6, 0) self.uhd_single_usrp_source_0.set_gain(45, 0) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) ################################################## # Connections ################################################## self.connect((self.blks2_nbfm_rx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blks2_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.uhd_single_usrp_source_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dsd Grc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self._config_freq_config = ConfigParser.ConfigParser() self._config_freq_config.read(".grc_op25") try: config_freq = self._config_freq_config.getfloat("main", "freq") except: config_freq = 489900000 self.config_freq = config_freq self.freq = freq = config_freq self._config_xlate_offset_config = ConfigParser.ConfigParser() self._config_xlate_offset_config.read(".grc_op25") try: config_xlate_offset = self._config_xlate_offset_config.getfloat("main", "xlate_offset") except: config_xlate_offset = 0 self.config_xlate_offset = config_xlate_offset self.click_freq = click_freq = freq-config_xlate_offset self.xlate_offset_fine = xlate_offset_fine = 0 self.xlate_offset = xlate_offset = freq-click_freq self.samp_rate = samp_rate = 1000000 self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self._config_xlate_bandwidth_config = ConfigParser.ConfigParser() self._config_xlate_bandwidth_config.read(".grc_op25") try: config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat("main", "xlate_bandwidth") except: config_xlate_bandwidth = 24000 self.config_xlate_bandwidth = config_xlate_bandwidth self.auto_tune_offset = auto_tune_offset = 0 self.xlate_bandwidth = xlate_bandwidth = config_xlate_bandwidth self.variable_static_text_0 = variable_static_text_0 = freq+xlate_offset+xlate_offset_fine+auto_tune_offset self.squelch = squelch = -65 self.pre_channel_rate = pre_channel_rate = samp_rate/decim self.gain = gain = 25 self.fine_click_freq = fine_click_freq = 0 self.channel_rate = channel_rate = 4800*samp_per_sym self.audio_mul = audio_mul = 0 ################################################## # Blocks ################################################## _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_offset_fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, label="Fine Offset", converter=forms.float_converter(), proportion=0, ) self._xlate_offset_fine_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, minimum=-10000, maximum=10000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_offset_fine_sizer) self._xlate_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.xlate_offset, callback=self.set_xlate_offset, label="Xlate Offset", converter=forms.float_converter(), ) self.Add(self._xlate_offset_text_box) _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, label="Xlate BW", converter=forms.float_converter(), proportion=0, ) self._xlate_bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, minimum=5000, maximum=50000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_bandwidth_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4FSK") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Dibits") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Traffic") self.Add(self.nb) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.Add(self._freq_text_box) _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_mul_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, label="Audio mul", converter=forms.float_converter(), proportion=0, ) self._audio_mul_slider = forms.slider( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, minimum=-30, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(3).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1.5, v_offset=0, t_scale=0.05, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=fine_click_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0.win) def wxgui_fftsink2_0_0_callback(x, y): self.set_fine_click_freq(x) self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_click_freq(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Final freq", converter=forms.float_converter(), ) self.Add(self._variable_static_text_0_static_text) _squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._squelch_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, minimum=-100, maximum=100, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_squelch_sizer) self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_dc_offset_mode(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(14, 0) self.osmosdr_source_c_0.set_if_gain(gain, 0) self.osmosdr_source_c_0.set_bb_gain(gain, 0) self.osmosdr_source_c_0.set_antenna("", 0) self.osmosdr_source_c_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 6000)), xlate_offset+xlate_offset_fine-fine_click_freq, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_P25_PHASE_1,dsd.dsd_MOD_C4FM,3,3,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Tx Fifo") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 195.312e3 self.FM_freq = FM_freq = 96.5e6 ################################################## # 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), "Audio") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.Add(self.notebook_0) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label="FM Frequency", converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=87.5e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( 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="FFT Plot", peak_hold=False, win=window.hamming, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=FM_freq, 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.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.20.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_time_source("mimo", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((400e-6, )) self.gr_file_source_0 = gr.file_source( gr.sizeof_short * 1, "/home/kranthi/documents/project/FM Transceiver Original/test.raw", True) self.blks2_wfm_tx_0 = blks2.wfm_tx( audio_rate=32000, quad_rate=800000, tau=75e-6, max_dev=75e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=2, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_wfm_tx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_file_source_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_wfm_tx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0))