def __init__(self): gr.top_block.__init__(self, "FM whole-band Channelizer to Measure Latency vs TP") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 3.125e6 self.gain = gain = 10 self.pfb_transition_width = pfb_transition_width = 120e3 self.pfb_samp_rate = pfb_samp_rate = samp_rate self.pfb_gain = pfb_gain = 1 self.pfb_cutoff_freq = pfb_cutoff_freq = 80e3 self.pfb_attenuation = pfb_attenuation = 60 self.audio_transition_width = audio_transition_width = 3e3/10 self.audio_samp_rate = audio_samp_rate = 44.1e3 self.audio_gain = audio_gain = gain self.audio_cutoff_freq = audio_cutoff_freq = 18e3/10 self.audio_attenuation = audio_attenuation = 80 self.pfb_taps = pfb_taps = firdes.low_pass_2(pfb_gain, pfb_samp_rate, pfb_cutoff_freq, pfb_transition_width, pfb_attenuation) self.audio_taps = audio_taps = firdes.low_pass_2(audio_gain, audio_samp_rate, audio_cutoff_freq, audio_transition_width, audio_attenuation) self.pfb_ntaps = pfb_ntaps = pfb_taps.__len__() self.channel = channel = 0 self.audio_rate = audio_rate = 44.1e3 self.audio_ntaps = audio_ntaps = audio_taps.__len__() ################################################## # Blocks ################################################## self.west_timestamp_tagger_ff_0 = west.timestamp_tagger_ff(gr.sizeof_gr_complex, 100) self.west_timestamp_sink_f_0 = west.timestamp_sink_f("timestamp", "fm_latency_meas") self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( audio_rate / 50e3, taps=(audio_taps), flt_size=10) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/nathan/Downloads/WFM-97.9MHz-3.125Msps.dat", False) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=200e3, audio_decimation=int(200e3 / audio_rate), ) self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=75e-6) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.analog_fm_deemph_0, 0), (self.west_timestamp_sink_f_0, 0)) self.connect((self.west_timestamp_sink_f_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.west_timestamp_tagger_ff_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.west_timestamp_tagger_ff_0, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_sensitivity(2 * math.pi * self.delta_f / self.samp_rate) self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) self.set_info_taps( firdes.low_pass_2(1, self.samp_rate, self.f_m, self.f_m / 8, 60, firdes.WIN_BLACKMAN_hARRIS)) self.set_filt_taps( firdes.low_pass_2(1, self.samp_rate, self.B_T / 2, self.B_T / 12, 60, firdes.WIN_BLACKMAN_hARRIS)) self.blocks_throttle_0.set_sample_rate(self.samp_rate / 10) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
def set_atten(self, atten): self.atten = atten self.set_pfb_taps( firdes.low_pass_2(1, self.samp_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_BLACKMAN_HARRIS) ) self.set_pfb_synth_taps( firdes.low_pass_2( self.channels / 2, self.synth_channels * self.ch_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_BLACKMAN_HARRIS, ) )
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_pfb_taps( firdes.low_pass_2(1, self.samp_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_BLACKMAN_HARRIS) ) self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate)
def __init__(self, width, chan_width, sym_rate, sps): # Save params self.width = width # Synthesizer (always need even # of channels for 2x oversampling) if width > 1: self.width_synth = ((width + 1) & ~1) self.taps_synth = firdes.low_pass_2(1.0, self.width_synth, 0.5, 0.2, 80, firdes.WIN_BLACKMAN_HARRIS) self.rotation = -math.pi * ((self.width - 1) / (2.0 * self.width_synth)) chan_rate = chan_width * self.width_synth / self.width else: self.width_synth = None self.taps_synth = None self.rotation = 0 chan_rate = chan_width # Resampler self.resamp = (sym_rate * sps) / (chan_rate * self.OVERSAMPLE) self.taps_resamp = firdes.root_raised_cosine( 32.0, 32.0 * chan_rate * self.OVERSAMPLE, sym_rate, 0.35, int(11.0 * 32 * chan_rate * self.OVERSAMPLE / sym_rate))
def set_B_T(self, B_T): self.B_T = B_T self.set_filt_taps( firdes.low_pass_2(1, self.samp_rate, self.B_T / 2, self.B_T / 12, 60, firdes.WIN_BLACKMAN_hARRIS)) Qt.QMetaObject.invokeMethod(self._B_T_label, "setText", Qt.Q_ARG("QString", self.B_T))
def __init__(self): gr.top_block.__init__(self, "AirHogs Sync Framer Example") # SDR configuration self.freq = 2402e6 self.gain = 40 self.symbol_rate = 2e6 self.sample_rate = 4e6 # SDR source (gr-osmosdr source) self.osmosdr_source = osmosdr.source() self.osmosdr_source.set_sample_rate(self.sample_rate) self.osmosdr_source.set_center_freq(self.freq) self.osmosdr_source.set_gain(self.gain) #self.osmosdr_source.set_antenna('TX/RX') # Low pass filter self.lpf = filter.fir_filter_ccf( 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 50e3, 50)) # GFSK demod, defaults to 2 samples per symbol self.gfsk_demod = digital.gfsk_demod() # Nordic RX self.nordic_rx = nordic.nordic_rx(3, 5, 2, 2) # Connect the blocks self.connect((self.osmosdr_source, 0), (self.lpf, 0)) self.connect((self.lpf, 0), (self.gfsk_demod, 0)) self.connect((self.gfsk_demod, 0), (self.nordic_rx, 0)) # Handle incoming packets self.nordictap_handler = microsoft_nordictap_handler(self) self.msg_connect( self.nordic_rx, "nordictap_out", self.nordictap_handler, "nordictap_in")
def __init__(self, sample_rate, decimation, symbol_rate): super(ask_channel_filter, self).__init__( "ask_channel_filter", gr.io_signature(1, 1, gr.sizeof_float * 1), gr.io_signature(1, 1, gr.sizeof_float * 1), ) output_sampling_rate = float(sample_rate) / decimation output_nyquist = output_sampling_rate / 2.0 filter_attenuation_db = 40 filter_cutoff = symbol_rate * 1.4 * 0.5 filter_transition = symbol_rate * 1.4 * 0.2 if (filter_cutoff + filter_transition) > output_nyquist: raise RuntimeError('ASK channel filter exceeds Nyquist frequency') filter_taps = firdes.low_pass_2(1.0, sample_rate, filter_cutoff, filter_transition, filter_attenuation_db) self.filter = filter.fir_filter_fff(decimation, (filter_taps)) self.connect((self, 0), (self.filter, 0)) self.envelope = tpms.ask_env(alpha=0.02) self.connect((self.filter, 0), (self.envelope, 0)) self.connect((self.envelope, 0), (self, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_pfb_taps( firdes.low_pass_2(1, self.samp_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_HANN)) self.osmosdr_source_0.set_sample_rate(self.samp_rate) self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_taps1( firdes.low_pass_2(1.0, self.samp_rate, 1.5e3, 128e3 - 1.5e3, 60.0, firdes.WIN_BLACKMAN_HARRIS, 6.76)) self.set_samp_rate2(self.samp_rate / self.decimate_1) self.osmosdr_source_0.set_sample_rate(self.samp_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) self.fir_filter_xxx_0.set_taps( (firdes.low_pass_2(self.amp, self.samp_rate, self.bw, 1e3, 50)))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) self.fir_filter_xxx_0.set_taps( (firdes.low_pass_2(1, self.samp_rate, self.bw, 1e3, 50))) self.blocks_throttle_0.set_sample_rate(self.samp_rate)
def __init__(self, sample_rate, offset, deviation, decimation, symbol_rate): super(fsk_demodulator, self).__init__( "fsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) symbol_taps_length = int(floor(float(sample_rate) / symbol_rate)) symbol_taps = (1,) * symbol_taps_length self.symbol_filter_h = filter.freq_xlating_fir_filter_ccf(1, (symbol_taps), offset + deviation, sample_rate) self.symbol_filter_l = filter.freq_xlating_fir_filter_ccf(1, (symbol_taps), offset - deviation, sample_rate) self.mag_h = blocks.complex_to_mag(1) self.mag_l = blocks.complex_to_mag(1) self.sub = blocks.sub_ff(1) output_filter_cutoff = symbol_rate * 0.75 output_filter_transition = symbol_rate * 0.25 output_filter_attenuation = 40 output_filter_taps = firdes.low_pass_2(1.0, sample_rate, output_filter_cutoff, output_filter_transition, output_filter_attenuation) self.output_filter = filter.fir_filter_fff(decimation, (output_filter_taps)) self.connect((self, 0), (self.symbol_filter_h, 0)) self.connect((self, 0), (self.symbol_filter_l, 0)) self.connect((self.symbol_filter_h, 0), (self.mag_h, 0)) self.connect((self.symbol_filter_l, 0), (self.mag_l, 0)) self.connect((self.mag_h, 0), (self.sub, 0)) self.connect((self.mag_l, 0), (self.sub, 1)) self.connect((self.sub, 0), (self.output_filter, 0)) self.connect((self.output_filter, 0), (self, 0))
def set_f_m(self, f_m): self.f_m = f_m self.set_info_taps( firdes.low_pass_2(1, self.samp_rate, self.f_m, self.f_m / 8, 60, firdes.WIN_BLACKMAN_hARRIS)) self.analog_sig_source_x_0.set_frequency(self.f_m) self.set_B_T(self._B_T_formatter(2 * (self.delta_f + self.f_m)))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.variable_slider_0 = variable_slider_0 = .846 self.test = test = .005 self.shift = shift = .906 self.samp_rate_0 = samp_rate_0 = 1.2e6 self.samp_rate = samp_rate = 1.2e6/4 self.pows = pows = 1.3 self.lpf = lpf = .724 self.go = go = 0.564 self.gm = gm = 1.61 self.centre_freq = centre_freq = 439.95e6 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate_0) self.rtlsdr_source_0.set_center_freq(439.9e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(10, 0) self.rtlsdr_source_0.set_bb_gain(10, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff(10, firdes.low_pass( 1, samp_rate, 2.56e3*lpf, (2.56e3/2)*lpf, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass_2(1,samp_rate_0,100e3,50e3,40)), 0, samp_rate_0) self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_ff(11.6439*(1+test), 0.25*0.175*0.175*go, 0.5, 0.175*gm, 0.005*variable_slider_0) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_add_const_vxx_0 = blocks.add_const_vff((-12*shift, )) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9000, server=False, ) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40*pows, .001, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, fft_len, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh): gr.hier_block2.__init__(self, "Coarse Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ''' Constructor @param fft_len - @param freq_sample_delay_samps - @param freq_samps_to_avg - @param mag_samps_to_avg - @param thresh - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(1.0 / (fft_len / 4.0), taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.30,.05,60))) self.fir.declare_sample_delay(0) self.fft_peak = fft_peak(fft_len=fft_len) self.vco = blocks.vco_c(1, 2.0 * pi / fft_len, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fft_peak, 0), (self.s_and_h_detector, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self, 0), (self.fft_peak, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.vco, 0))
def set_synth_channels(self, synth_channels): self.synth_channels = synth_channels self.set_fm_quad_rate(self.ch_rate * self.synth_channels) self.set_pfb_synth_taps( firdes.low_pass_2( self.channels / 2, self.synth_channels * self.ch_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_BLACKMAN_HARRIS, ) ) self.qtgui_freq_sink_x_0_0_0.set_frequency_range(0, self.ch_rate * self.synth_channels) self.fir_filter_xxx_0.set_taps( (firdes.low_pass_2(1, self.ch_rate * self.synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS)) )
def set_nchans(self, nchans): self.nchans = nchans self.qtgui_waterfall_sink_x_0.set_frequency_range( 0, self.nchans * self.chan_rate) self.qtgui_freq_sink_x_0.set_frequency_range( 0, self.nchans * self.chan_rate) self.pfb_synthesizer_ccf_0.set_taps( (firdes.low_pass_2(self.nchans, self.nchans * self.chan_rate, 100e3, 20e3, 50))) self.pfb_decimator_ccf_0.set_taps( (firdes.low_pass_2(self.rx_vol, self.nchans * self.chan_rate, self.chan_rate / 2, self.chan_rate / 4, 50))) self.fft_filter_xxx_0.set_taps((firdes.complex_band_pass_2( 1, self.nchans * self.chan_rate, (self.rx_chan * self.chan_rate) - self.chan_rate / 2, (self.rx_chan * self.chan_rate) + self.chan_rate / 2, self.chan_rate / 10, 80)))
def set_dect_channel_bandwidth(self, dect_channel_bandwidth): self.dect_channel_bandwidth = dect_channel_bandwidth self.set_resampler_filter_taps( firdes.low_pass_2( 1, 3 * self.baseband_sampling_rate, self.dect_occupied_bandwidth / 2, (self.dect_channel_bandwidth - self.dect_occupied_bandwidth) / 2, 30))
def __init__(self, uhd_address, options): gr.top_block.__init__(self) self.uhd_addr = uhd_address self.freq = options.freq self.samp_rate = options.samp_rate self.gain = options.gain self.threshold = options.threshold self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, stream_args=uhd.stream_args('fc32')) self.uhd_src.set_samp_rate(self.samp_rate) self.uhd_src.set_center_freq(self.freq, 0) self.uhd_src.set_gain(self.gain, 0) taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = filter.fir_filter_ccc(10, taps) self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods data = 1000*[0,] + 1000*[1,] self.signal = blocks.vector_source_s(data, True) # Energy detector to get signal burst ## use squelch to detect energy self.det = analog.simple_squelch_cc(self.threshold, 0.01) ## convert to mag squared (float) self.c2m = blocks.complex_to_mag_squared() ## average to debounce self.avg = filter.single_pole_iir_filter_ff(0.01) ## rescale signal for conversion to short self.scale = blocks.multiply_const_ff(2**16) ## signal input uses shorts self.f2s = blocks.float_to_short() # Use file sink burst tagger to capture bursts self.fsnk = blocks.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) ################################################## # Connections ################################################## self.connect((self.uhd_src, 0), (self.tagger, 0)) self.connect((self.tagger, 0), (self.fsnk, 0)) if self.trigger: # Connect a dummy signaler to the burst tagger self.connect((self.signal, 0), (self.tagger, 1)) else: # Connect an energy detector signaler to the burst tagger self.connect(self.uhd_src, self.det) self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) self.connect(self.f2s, (self.tagger, 1))
def __init__(self, uhd_address, options): gr.top_block.__init__(self) self.uhd_addr = uhd_address self.freq = options.freq self.samp_rate = options.samp_rate self.gain = options.gain self.threshold = options.threshold self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, stream_args=uhd.stream_args('fc32')) self.uhd_src.set_samp_rate(self.samp_rate) self.uhd_src.set_center_freq(self.freq, 0) self.uhd_src.set_gain(self.gain, 0) taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = filter.fir_filter_ccc(10, taps) self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods data = 1000 * [0, ] + 1000 * [1, ] self.signal = blocks.vector_source_s(data, True) # Energy detector to get signal burst # use squelch to detect energy self.det = analog.simple_squelch_cc(self.threshold, 0.01) # convert to mag squared (float) self.c2m = blocks.complex_to_mag_squared() # average to debounce self.avg = filter.single_pole_iir_filter_ff(0.01) # rescale signal for conversion to short self.scale = blocks.multiply_const_ff(2**16) # signal input uses shorts self.f2s = blocks.float_to_short() # Use file sink burst tagger to capture bursts self.fsnk = blocks.tagged_file_sink( gr.sizeof_gr_complex, self.samp_rate) ################################################## # Connections ################################################## self.connect((self.uhd_src, 0), (self.tagger, 0)) self.connect((self.tagger, 0), (self.fsnk, 0)) if self.trigger: # Connect a dummy signaler to the burst tagger self.connect((self.signal, 0), (self.tagger, 1)) else: # Connect an energy detector signaler to the burst tagger self.connect(self.uhd_src, self.det) self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) self.connect(self.f2s, (self.tagger, 1))
def set_num_banks(self, num_banks): self.num_banks = num_banks self.set_taps( firdes.low_pass_2(5, self.num_banks * self.quad_rate, 60e3, 60e3, 80, firdes.WIN_BLACKMAN_HARRIS)) self.blocks_throttle_1.set_sample_rate(self.quad_rate * self.num_banks) self.osmosdr_sink_0.set_sample_rate(self.quad_rate * self.num_banks) self.qtgui_sink_x_0.set_frequency_range( 0, self.quad_rate * self.num_banks)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_sensitivity(2 * math.pi * self.delta_f / self.samp_rate) self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.samp_rate) self.fft_filter_xxx_0.set_taps( (firdes.low_pass_2(1000, self.samp_rate, 100e3, 15e3, 50))) self.broadcast_fm_rx_0.set_chan_rate(self.samp_rate) self.set_audio_decim(self.samp_rate / self.audio_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_taps(firdes.low_pass_2(6, 6*self.samp_rate, self.samp_rate/3.0, self.samp_rate/4.0, 60)) self.blocks_throttle_0.set_sample_rate(self.samp_rate) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0_1.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0_2.set_sampling_freq(self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate*6)
def __init__(self, args): gr.top_block.__init__(self, "Nordic Auto-ACK Example") # SDR configuration self.freq = 2400e6 + args.channel * 1e6 self.gain = args.gain self.symbol_rate = args.data_rate self.sample_rate = args.data_rate * args.samples_per_symbol # SDR source (gr-osmosdr source) self.osmosdr_source = osmosdr.source() self.osmosdr_source.set_sample_rate(self.sample_rate) self.osmosdr_source.set_center_freq(self.freq) self.osmosdr_source.set_gain(self.gain) self.osmosdr_source.set_antenna('TX/RX') # SDR sink (gr-osmosdr source) self.osmosdr_sink = osmosdr.sink() self.osmosdr_sink.set_sample_rate(self.sample_rate) self.osmosdr_sink.set_center_freq(self.freq) self.osmosdr_sink.set_gain(self.gain) self.osmosdr_sink.set_antenna('TX/RX') # Transmit chain self.tx = nordic.nordic_tx() self.gfsk_mod = digital.gfsk_mod( samples_per_symbol=args.samples_per_symbol) self.connect(self.tx, self.gfsk_mod) self.connect(self.gfsk_mod, self.osmosdr_sink) # Receive chain dr = 0 if args.data_rate == 1e6: dr = 1 elif args.data_rate == 2e6: dr = 2 self.rx = nordic.nordic_rx(args.channel, args.address_length, args.crc_length, dr) self.gfsk_demod = digital.gfsk_demod( samples_per_symbol=args.samples_per_symbol) self.lpf = filter.fir_filter_ccf( 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 50e3, 50)) self.connect(self.osmosdr_source, self.lpf) self.connect(self.lpf, self.gfsk_demod) self.connect(self.gfsk_demod, self.rx) # Handle incoming packets self.nordictap_ack_handler = nordictap_ack_handler() self.msg_connect(self.rx, "nordictap_out", self.nordictap_ack_handler, "nordictap_in") # Reply with ACKs self.msg_connect(self.nordictap_ack_handler, "nordictap_out", self.tx, "nordictap_in")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.udp_dest_port = udp_dest_port = 8082 self.udp_dest_host = udp_dest_host = "192.168.10.30" self.sql = sql = -10.0 self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 49.5 self.frq_corr = frq_corr = 30.0 self.device_arg = device_arg = "rtl_tcp=192.168.10.109:1235" self.base_freq = base_freq = 120.5e6 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device_arg ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dest_host, udp_dest_port, 1472, True) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, target_frequency, if_sampling_rate): super(source_rtlsdr, self).__init__( "source_rtlsdr", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) import osmosdr model = 'r820t' rf_sampling_rate = 2400000 if model == 'e4000': offset_frequency = rf_sampling_rate / 4 rf_gain = 42 # E4000, Gains set assuming a front-end filter keeps out-of-band noise down. elif model == 'r820t': offset_frequency = 0 rf_gain = 42.1 # R820T, Gains set assuming a front-end filter keeps out-of-band noise down. else: raise RuntimeError('Unknown RTL-SDR receiver model') if_gain = 42 bb_gain = 20 # Not sure this has an effect on RTL-SDR. baseband_bandwidth = 0 # No effect on RTL-SDR? if_filter_attenuation = 60 rf_decimation, rf_decimation_remainder = divmod( rf_sampling_rate, if_sampling_rate) if rf_decimation_remainder != 0: raise RuntimeError('RF decimation must be an integer') rf_decimation = int(round(rf_decimation)) tuning_frequency = target_frequency - offset_frequency self.source = osmosdr.source(args="numchan=1 rtl=0") self.source.set_sample_rate(rf_sampling_rate) self.source.set_center_freq(tuning_frequency, 0) self.source.set_freq_corr(0, 0) self.source.set_dc_offset_mode(0, 0) self.source.set_iq_balance_mode(0, 0) self.source.set_gain_mode(False, 0) self.source.set_gain(rf_gain, 0) self.source.set_if_gain(if_gain, 0) self.source.set_bb_gain(bb_gain, 0) self.source.set_antenna("", 0) self.source.set_bandwidth(baseband_bandwidth, 0) if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate * 0.45, if_sampling_rate * 0.1, if_filter_attenuation) self.if_filter = filter.freq_xlating_fir_filter_ccc( rf_decimation, (if_taps), offset_frequency, rf_sampling_rate) #self.if_filter.set_min_output_buffer(1048576) self.connect(self.source, self.if_filter, self)
def set_baseband_sampling_rate(self, baseband_sampling_rate): self.baseband_sampling_rate = baseband_sampling_rate self.set_resample_ratio( int((3.0 * self.baseband_sampling_rate / 2.0) / self.dect_symbol_rate / 4.0)) self.set_resampler_filter_taps( firdes.low_pass_2( 1, 3 * self.baseband_sampling_rate, self.dect_occupied_bandwidth / 2, (self.dect_channel_bandwidth - self.dect_occupied_bandwidth) / 2, 30))
def __init__(self, bias, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, resamp_rate, thresh): gr.hier_block2.__init__(self, "Fine Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ################################################## # Parameters ################################################## self.bias = bias self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.resamp_rate = resamp_rate self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(resamp_rate * 2.0, taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.25,.05,60))) self.fir.declare_sample_delay(0) self.vco = blocks.vco_c(1, 1, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) self.add_const = blocks.add_const_vff((-1.0 * bias * (resamp_rate), )) self.demod = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.demod, 0), (self.s_and_h_detector, 1)) self.connect((self.add_const, 0), (self.vco, 0)) self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.add_const, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_taps( firdes.low_pass_2(6, 6 * self.samp_rate, self.samp_rate / 3.0, self.samp_rate / 4.0, 60)) self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.samp_rate) self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) self.blocks_throttle_0.set_sample_rate(self.samp_rate) self.analog_sig_source_x_0_0_0_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0_0_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0_0.set_sampling_freq(self.samp_rate) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
def set_chan_rate(self, chan_rate): self.chan_rate = chan_rate self.set_sensitivity(2 * math.pi * self.delta_f / self.chan_rate) self.qtgui_waterfall_sink_x_0.set_frequency_range( 0, self.nchans * self.chan_rate) self.qtgui_freq_sink_x_0.set_frequency_range( 0, self.nchans * self.chan_rate) self.pfb_synthesizer_ccf_0.set_taps( (firdes.low_pass_2(self.nchans, self.nchans * self.chan_rate, 100e3, 20e3, 50))) self.pfb_decimator_ccf_0.set_taps( (firdes.low_pass_2(self.rx_vol, self.nchans * self.chan_rate, self.chan_rate / 2, self.chan_rate / 4, 50))) self.fft_filter_xxx_0.set_taps((firdes.complex_band_pass_2( 1, self.nchans * self.chan_rate, (self.rx_chan * self.chan_rate) - self.chan_rate / 2, (self.rx_chan * self.chan_rate) + self.chan_rate / 2, self.chan_rate / 10, 80))) self.broadcast_fm_tx_0_0_0.set_chan_rate(self.chan_rate) self.broadcast_fm_tx_0_0.set_chan_rate(self.chan_rate) self.broadcast_fm_tx_0.set_chan_rate(self.chan_rate) self.broadcast_fm_rx_0.set_chan_rate(self.chan_rate)
def set_nfilts(self, nfilts): self.nfilts = nfilts self.set_lp_taps( firdes.low_pass_2(self.nfilts, self.nfilts, 2 / self.sps, 0.05, self.nfilts)) self.set_rrc_taps( firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0 / float(self.sps), self.ebw, 64 * self.nfilts)) self.set_bp_taps( firdes.band_pass_2(self.nfilts, self.nfilts, 0.1 / float(self.sps), 1.2 / float(self.sps), self.ebw, 64 * self.nfilts))
def set_channels(self, channels): self.channels = channels self.set_samp_rate(self.ch_rate * self.channels) self.set_pfb_synth_taps( firdes.low_pass_2( self.channels / 2, self.synth_channels * self.ch_rate, self.ch_bw, self.ch_tb, self.atten, firdes.WIN_BLACKMAN_HARRIS, ) )
def __init__(self, target_frequency, if_sampling_rate): super(source_rtlsdr, self).__init__( "source_rtlsdr", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) import osmosdr model = 'r820t' rf_sampling_rate = 2400000 if model == 'e4000': offset_frequency = rf_sampling_rate / 4 rf_gain = 42 # E4000, Gains set assuming a front-end filter keeps out-of-band noise down. elif model == 'r820t': offset_frequency = 0 rf_gain = 42.1 # R820T, Gains set assuming a front-end filter keeps out-of-band noise down. else: raise RuntimeError('Unknown RTL-SDR receiver model') if_gain = 42 bb_gain = 20 # Not sure this has an effect on RTL-SDR. baseband_bandwidth = 0 # No effect on RTL-SDR? if_filter_attenuation = 60 rf_decimation, rf_decimation_remainder = divmod(rf_sampling_rate, if_sampling_rate) if rf_decimation_remainder != 0: raise RuntimeError('RF decimation must be an integer') rf_decimation = int(round(rf_decimation)) tuning_frequency = target_frequency - offset_frequency self.source = osmosdr.source(args="numchan=1 rtl=0") self.source.set_sample_rate(rf_sampling_rate) self.source.set_center_freq(tuning_frequency, 0) self.source.set_freq_corr(0, 0) self.source.set_dc_offset_mode(0, 0) self.source.set_iq_balance_mode(0, 0) self.source.set_gain_mode(False, 0) self.source.set_gain(rf_gain, 0) self.source.set_if_gain(if_gain, 0) self.source.set_bb_gain(bb_gain, 0) self.source.set_antenna("", 0) self.source.set_bandwidth(baseband_bandwidth, 0) if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate*0.45, if_sampling_rate*0.1, if_filter_attenuation) self.if_filter = filter.freq_xlating_fir_filter_ccc(rf_decimation, (if_taps), offset_frequency, rf_sampling_rate) #self.if_filter.set_min_output_buffer(1048576) self.connect(self.source, self.if_filter, self)
def __init__(self, snr_db=10, taps=[]): gr.top_block.__init__(self, "LMS Watterson Experiment") ################################################## # Variables ################################################## self.snr_db = snr_db self.samp_rate = samp_rate = 1000000 self.num_symbols = num_symbols = 4096 self.taps = taps self.const = const = digital.constellation_8psk().base() ################################################## # Blocks ################################################## self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc( 2, (firdes.low_pass_2(1, 1, .25, .1, 80))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 2, 1, 2, const) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc( (const.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0, frequency_offset=0.0, epsilon=1.0, taps=self.taps, noise_seed=0, block_tags=False) self.blocks_vector_sink_x_0 = blocks.vector_sink_c(1) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, num_symbols) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, const.arity(), 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_1, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.blocks_head_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self) input_rate = 200e3 # rate of a broadcast FM station audio_rate = 44.1e3 # Rate we send the signal to the speaker # resample from the output of the demodulator to the rate of # the audio sink. resamp_rate = audio_rate / input_rate # use a file as a dummy source. Replace this with a real radio # receiver to capture signals over-the-air. src = blocks.file_source(gr.sizeof_gr_complex, "dummy.dat", True) # Set the demodulator using the same deviation as the receiver. max_dev = 75e3 fm_demod_gain = input_rate / (2 * math.pi * max_dev / 8.0) fm_demod = analog.quadrature_demod_cf(fm_demod_gain) # Create a filter for the resampler and filter the audio # signal to 15 kHz. The nfilts is the number of filters in the # arbitrary resampler. It logically operates at a rate of # nfilts*input_rate, so we make those adjustments when # building the filter. volume = 0.20 nfilts = 32 resamp_taps = firdes.low_pass_2( volume * nfilts, # gain nfilts * input_rate, # sampling rate 15e3, # low pass cutoff freq 1e3, # width of trans. band 60, # stop band attenuaton firdes.WIN_KAISER) # Build the resampler and filter resamp_filter = filter.pfb_arb_resampler_fff(resamp_rate, resamp_taps, nfilts) # sound card as final sink You may have to add a specific # device name as a second argument here, something like # "pulse" if using pulse audio or "plughw:0,0". audio_sink = audio.sink(int(audio_rate)) # now wire it all together self.connect(src, fm_demod) self.connect(fm_demod, resamp_filter) self.connect(resamp_filter, (audio_sink, 0))
def __init__(self): gr.top_block.__init__(self) input_rate = 200e3 # rate of a broadcast FM station audio_rate = 44.1e3 # Rate we send the signal to the speaker # resample from the output of the demodulator to the rate of # the audio sink. resamp_rate = audio_rate / input_rate # use a file as a dummy source. Replace this with a real radio # receiver to capture signals over-the-air. src = blocks.file_source(gr.sizeof_gr_complex, "dummy.dat", True) # Set the demodulator using the same deviation as the receiver. max_dev = 75e3 fm_demod_gain = input_rate/(2*math.pi*max_dev/8.0) fm_demod = analog.quadrature_demod_cf(fm_demod_gain) # Create a filter for the resampler and filter the audio # signal to 15 kHz. The nfilts is the number of filters in the # arbitrary resampler. It logically operates at a rate of # nfilts*input_rate, so we make those adjustments when # building the filter. volume = 0.20 nfilts = 32 resamp_taps = firdes.low_pass_2(volume*nfilts, # gain nfilts*input_rate, # sampling rate 15e3, # low pass cutoff freq 1e3, # width of trans. band 60, # stop band attenuaton firdes.WIN_KAISER) # Build the resampler and filter resamp_filter = filter.pfb_arb_resampler_fff(resamp_rate, resamp_taps, nfilts) # sound card as final sink You may have to add a specific # device name as a second argument here, something like # "pulse" if using pulse audio or "plughw:0,0". audio_sink = audio.sink(int(audio_rate)) # now wire it all together self.connect(src, fm_demod) self.connect(fm_demod, resamp_filter) self.connect(resamp_filter, (audio_sink,0))
def __init__(self, target_frequency, if_sampling_rate): super(source_hackrf, self).__init__( "source_hackrf", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) import osmosdr rf_sampling_rate = 10000000 baseband_bandwidth = 1750000 offset_frequency = 400000 # Keep well below roll-off of baseband filter. rf_gain = 14 # Gains set assuming a front-end filter keeps out-of-band noise down. if_gain = 40 bb_gain = 24 if_filter_attenuation = 60 rf_decimation, rf_decimation_remainder = divmod( rf_sampling_rate, if_sampling_rate) if rf_decimation_remainder != 0: raise RuntimeError('RF decimation must be an integer') rf_decimation = int(round(rf_decimation)) tuning_frequency = target_frequency - offset_frequency self.source = osmosdr.source(args="numchan=1 hackrf=0") self.source.set_sample_rate(rf_sampling_rate) self.source.set_center_freq(tuning_frequency, 0) self.source.set_freq_corr(0, 0) self.source.set_dc_offset_mode(0, 0) self.source.set_iq_balance_mode(0, 0) self.source.set_gain_mode(False, 0) self.source.set_gain(rf_gain, 0) self.source.set_if_gain(if_gain, 0) self.source.set_bb_gain(bb_gain, 0) self.source.set_antenna("", 0) self.source.set_bandwidth(baseband_bandwidth, 0) if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate * 0.45, if_sampling_rate * 0.1, if_filter_attenuation) self.if_filter = filter.freq_xlating_fir_filter_ccc( rf_decimation, (if_taps), offset_frequency, rf_sampling_rate) #self.if_filter.set_min_output_buffer(1048576) self.connect(self.source, self.if_filter, self)
def __init__(self, args): gr.top_block.__init__(self, "Nordic Single-Channel Receiver Example") self.freq = 2414e6 self.gain = args.gain self.symbol_rate = 2e6 self.sample_rate = 4e6 # Channel map channel_count = 3 channel_map = [14, 18, 10] # Data rate index dr = 2 # 2M # SDR source (gr-osmosdr source) self.osmosdr_source = osmosdr.source() self.osmosdr_source.set_sample_rate(self.sample_rate * channel_count) self.osmosdr_source.set_center_freq(self.freq) self.osmosdr_source.set_gain(self.gain) self.osmosdr_source.set_antenna('TX/RX') # PFB channelizer taps = firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 100e3, 30) self.channelizer = filter.pfb_channelizer_ccf(channel_count, taps, 1) # Stream to streams (PFB channelizer input) self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, channel_count) self.connect(self.osmosdr_source, self.s2ss) # Demodulators and packet deframers self.nordictap_printer = nordictap_printer() self.demods = [] self.rxs = [] for x in range(channel_count): self.connect((self.s2ss, x), (self.channelizer, x)) self.demods.append(digital.gfsk_demod()) self.rxs.append(nordic.nordic_rx(x, 5, 2, dr)) self.connect((self.channelizer, x), self.demods[x]) self.connect(self.demods[x], self.rxs[x]) self.msg_connect(self.rxs[x], "nordictap_out", self.nordictap_printer, "nordictap_in")
def set_baseband_sampling_rate(self, baseband_sampling_rate): self.baseband_sampling_rate = baseband_sampling_rate self.set_resample_ratio( int((3.0 * self.baseband_sampling_rate / 2.0) / self.dect_symbol_rate / 4.0)) self.set_resampler_filter_taps( firdes.low_pass_2( 1, 3 * self.baseband_sampling_rate, self.dect_occupied_bandwidth / 2, (self.dect_channel_bandwidth - self.dect_occupied_bandwidth) / 2, 30)) self.freq_xlating_fir_filter_xxx_0.set_taps( firdes.low_pass(1, self.baseband_sampling_rate, self.options_low_pass, self.options_low_pass * 0.2)) self.mmse_resampler_xx_0.set_resamp_ratio( (3.0 * self.baseband_sampling_rate / 2.0) / self.dect_symbol_rate / 4.0) self.rtlsdr_source_0.set_sample_rate(self.baseband_sampling_rate)
def __init__(self, target_frequency, if_sampling_rate): super(source_hackrf, self).__init__( "source_hackrf", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) import osmosdr rf_sampling_rate = 10000000 baseband_bandwidth = 1750000 offset_frequency = 400000 # Keep well below roll-off of baseband filter. rf_gain = 14 # Gains set assuming a front-end filter keeps out-of-band noise down. if_gain = 40 bb_gain = 24 if_filter_attenuation = 60 rf_decimation, rf_decimation_remainder = divmod(rf_sampling_rate, if_sampling_rate) if rf_decimation_remainder != 0: raise RuntimeError('RF decimation must be an integer') rf_decimation = int(round(rf_decimation)) tuning_frequency = target_frequency - offset_frequency self.source = osmosdr.source(args="numchan=1 hackrf=0") self.source.set_sample_rate(rf_sampling_rate) self.source.set_center_freq(tuning_frequency, 0) self.source.set_freq_corr(0, 0) self.source.set_dc_offset_mode(0, 0) self.source.set_iq_balance_mode(0, 0) self.source.set_gain_mode(False, 0) self.source.set_gain(rf_gain, 0) self.source.set_if_gain(if_gain, 0) self.source.set_bb_gain(bb_gain, 0) self.source.set_antenna("", 0) self.source.set_bandwidth(baseband_bandwidth, 0) if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate*0.45, if_sampling_rate*0.1, if_filter_attenuation) self.if_filter = filter.freq_xlating_fir_filter_ccc(rf_decimation, (if_taps), offset_frequency, rf_sampling_rate) #self.if_filter.set_min_output_buffer(1048576) self.connect(self.source, self.if_filter, self)
def __init__(self, target_frequency, if_sampling_rate): super(source_limesdr, self).__init__( "source_limesdr", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) import limesdr rf_sampling_rate = 10e6 baseband_bandwidth = 1750000 offset_frequency = 0 rf_gain = 30 # Gains set assuming a front-end filter keeps out-of-band noise down. if_filter_attenuation = 60 rf_decimation, rf_decimation_remainder = divmod( rf_sampling_rate, if_sampling_rate) if rf_decimation_remainder != 0: raise RuntimeError('RF decimation must be an integer') rf_decimation = int(round(rf_decimation)) tuning_frequency = target_frequency - offset_frequency self.source = limesdr.source('', 0, '') self.source.set_sample_rate(rf_sampling_rate) self.source.set_center_freq(tuning_frequency, 0) self.source.set_gain(rf_gain, 0) self.source.set_antenna(2, 0) self.source.set_bandwidth(max(1.5e6, baseband_bandwidth), 0) self.source.calibrate(max(2.5e6, rf_sampling_rate), 0) if_taps = firdes.low_pass_2(1.0, rf_sampling_rate, if_sampling_rate * 0.45, if_sampling_rate * 0.1, if_filter_attenuation) self.if_filter = filter.freq_xlating_fir_filter_ccc( rf_decimation, (if_taps), offset_frequency, rf_sampling_rate) #self.if_filter.set_min_output_buffer(1048576) self.connect(self.source, self.if_filter, self)
def __init__(self, sample_rate, decimation, symbol_rate): super(ask_channel_filter, self).__init__( "ask_channel_filter", gr.io_signature(1, 1, gr.sizeof_float*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) output_sampling_rate = float(sample_rate) / decimation output_nyquist = output_sampling_rate / 2.0 filter_attenuation_db = 40 filter_cutoff = symbol_rate * 1.4 * 0.5 filter_transition = symbol_rate * 1.4 * 0.2 if (filter_cutoff + filter_transition) > output_nyquist: raise RuntimeError('ASK channel filter exceeds Nyquist frequency') filter_taps = firdes.low_pass_2(1.0, sample_rate, filter_cutoff, filter_transition, filter_attenuation_db) self.filter = filter.fir_filter_fff(decimation, (filter_taps)) self.connect((self, 0), (self.filter, 0)) self.envelope = tpms.ask_env(alpha=0.02) self.connect((self.filter, 0), (self.envelope, 0)) self.connect((self.envelope, 0), (self, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.freq_xlating_fir_filter_xxx_0.set_taps((firdes.low_pass_2(1,self.samp_rate,25e3,10e3,40))) self.rtlsdr_source_0.set_sample_rate(self.samp_rate)
def __init__(self): gr.top_block.__init__(self, "Fm Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Rx") 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.samp_rate = samp_rate = 2e6 self.in_rate = in_rate = samp_rate self.audio_rate = audio_rate = 44.1e3 self.volume = volume = 0.2 self.resamp_rate = resamp_rate = audio_rate/in_rate self.nfilts = nfilts = 32 self.fm_deviation_hz = fm_deviation_hz = 75e3 ################################################## # Blocks ################################################## 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(91.9e6, 0) self.rtlsdr_source_c_0.set_freq_corr(0, 0) self.rtlsdr_source_c_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_c_0.set_iq_balance_mode(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(20, 0) self.rtlsdr_source_c_0.set_bb_gain(20, 0) self.rtlsdr_source_c_0.set_antenna("", 0) self.rtlsdr_source_c_0.set_bandwidth(0, 0) self.qtgui_sink_x_2 = qtgui.sink_f( 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_2.set_update_time(1.0 / 10) self._qtgui_sink_x_2_win = sip.wrapinstance(self.qtgui_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_2_win) self.qtgui_sink_x_1 = qtgui.sink_f( 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_1.set_update_time(1.0 / 10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 91.9e6, #fc samp_rate/2, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = filter.pfb.arb_resampler_fff( resamp_rate, taps=(firdes.low_pass_2(volume*nfilts, nfilts*in_rate, 15e3, 1e3, 60, firdes.WIN_KAISER)), flt_size=nfilts) self.audio_sink_0 = audio.sink(int(audio_rate), "pulse", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(in_rate/(2*math.pi*fm_deviation_hz/8.0)) ################################################## # Connections ################################################## self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_sink_x_2, 0)) self.connect((self.rtlsdr_source_c_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.rtlsdr_source_c_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _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 = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq1 = offset_freq1 = -300e3 self.freq_corr = freq_corr = 0 self.base_freq = base_freq = 27.315e6 ################################################## # 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=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) 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=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(base_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(1, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self._offset_freq1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq1, callback=self.set_offset_freq1, label="Frequency select", choices=[-800e3,-550e3, -300e3,300e3,500e3], labels=["TWR1 118.6M","TWR2 118.85M", "APP1 119.1M","APP2 119.7M","APP3 119.9M"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq1_chooser) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), base_freq, samp_rate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.dect_symbol_rate = dect_symbol_rate = 1152000 self.dect_occupied_bandwidth = dect_occupied_bandwidth = 1.2*dect_symbol_rate self.dect_channel_bandwidth = dect_channel_bandwidth = 1.728e6 self.baseband_sampling_rate = baseband_sampling_rate = 100000000/32 self.rx_gain = rx_gain = 0 self.rx_freq = rx_freq = 1897344000 self.resampler_filter_taps = resampler_filter_taps = firdes.low_pass_2(1, 3*baseband_sampling_rate, dect_occupied_bandwidth/2, (dect_channel_bandwidth - dect_occupied_bandwidth)/2, 30) self.part_id = part_id = 0 ################################################## # Blocks ################################################## self._rx_gain_layout = Qt.QVBoxLayout() self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_layout.addWidget(self._rx_gain_tool_bar) self._rx_gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._rx_gain_counter = qwt_counter_pyslot() self._rx_gain_counter.setRange(0, 30, 1) self._rx_gain_counter.setNumButtons(2) self._rx_gain_counter.setValue(self.rx_gain) self._rx_gain_tool_bar.addWidget(self._rx_gain_counter) self._rx_gain_counter.valueChanged.connect(self.set_rx_gain) self._rx_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._rx_gain_slider.setRange(0, 30, 1) self._rx_gain_slider.setValue(self.rx_gain) self._rx_gain_slider.setMinimumWidth(200) self._rx_gain_slider.valueChanged.connect(self.set_rx_gain) self._rx_gain_layout.addWidget(self._rx_gain_slider) self.top_layout.addLayout(self._rx_gain_layout) self._rx_freq_options = [1897344000, 1881792000, 1883520000, 1885248000, 1886876000, 1888704000, 1890432000, 1892160000, 1893888000, 1895616000,] self._rx_freq_labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel("Carrier Number"+": ")) self._rx_freq_combo_box = Qt.QComboBox() self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box) for label in self._rx_freq_labels: self._rx_freq_combo_box.addItem(label) self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rx_freq_options.index(i))) self._rx_freq_callback(self.rx_freq) self._rx_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_rx_freq(self._rx_freq_options[i])) self.top_layout.addWidget(self._rx_freq_tool_bar) self.vocoder_g721_decode_bs_0 = vocoder.g721_decode_bs() 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(3125000) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=6, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler = filter.rational_resampler_base_ccc(3, 2, (resampler_filter_taps)) self._part_id_options = [0, 1, 2, 3, 4, 5, 6, 7, 8] self._part_id_labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8"] self._part_id_tool_bar = Qt.QToolBar(self) self._part_id_tool_bar.addWidget(Qt.QLabel("Select Part"+": ")) self._part_id_combo_box = Qt.QComboBox() self._part_id_tool_bar.addWidget(self._part_id_combo_box) for label in self._part_id_labels: self._part_id_combo_box.addItem(label) self._part_id_callback = lambda i: Qt.QMetaObject.invokeMethod(self._part_id_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._part_id_options.index(i))) self._part_id_callback(self.part_id) self._part_id_combo_box.currentIndexChanged.connect( lambda i: self.set_part_id(self._part_id_options[i])) self.top_layout.addWidget(self._part_id_tool_bar) self.fractional_resampler = filter.fractional_resampler_cc(0, (3.0*baseband_sampling_rate/2.0)/dect_symbol_rate/4.0) self.dect2_phase_diff_0 = dect2.phase_diff() self.dect2_packet_receiver_0 = dect2.packet_receiver() self.dect2_packet_decoder_0 = dect2.packet_decoder() self.console_0 = dect2.console() self.top_layout.addWidget(self.console_0) self.blocks_short_to_float_0 = blocks.short_to_float(1, 32768) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.rational_resampler, 0), (self.fractional_resampler, 0)) self.connect((self.fractional_resampler, 0), (self.dect2_phase_diff_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.vocoder_g721_decode_bs_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler, 0)) self.connect((self.dect2_packet_decoder_0, 0), (self.vocoder_g721_decode_bs_0, 0)) self.connect((self.dect2_phase_diff_0, 0), (self.dect2_packet_receiver_0, 0)) self.connect((self.dect2_packet_receiver_0, 0), (self.dect2_packet_decoder_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.rational_resampler_xxx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.dect2_packet_decoder_0, "log_out", self.console_0, "in") self.msg_connect(self.dect2_packet_receiver_0, "rcvr_msg_out", self.dect2_packet_decoder_0, "rcvr_msg_in")
def set_in_rate(self, in_rate): self.in_rate = in_rate self.set_resamp_rate(self.audio_rate/self.in_rate) self.pfb_arb_resampler_xxx_0.set_taps((firdes.low_pass_2(self.volume*self.nfilts, self.nfilts*self.in_rate, 15e3, 1e3, 60, firdes.WIN_KAISER))) self.analog_quadrature_demod_cf_0.set_gain(self.in_rate/(2*math.pi*self.fm_deviation_hz/8.0))
def set_pfb_attenuation(self, pfb_attenuation): self.pfb_attenuation = pfb_attenuation self.set_pfb_taps(firdes.low_pass_2(self.pfb_gain, self.pfb_samp_rate, self.pfb_cutoff_freq, self.pfb_transition_width, self.pfb_attenuation))
def __init__(self): gr.top_block.__init__(self, "FM whole-band Channelizer") Qt.QWidget.__init__(self) self.setWindowTitle("FM whole-band Channelizer") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_channelize") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 3.125e6 self.gain = gain = 25 self.pfb_transition_width = pfb_transition_width = 120e3 self.pfb_samp_rate = pfb_samp_rate = samp_rate self.pfb_gain = pfb_gain = 1 self.pfb_cutoff_freq = pfb_cutoff_freq = 80e3 self.pfb_attenuation = pfb_attenuation = 60 self.audio_transition_width = audio_transition_width = 3e3/10 self.audio_samp_rate = audio_samp_rate = 44.1e3 self.audio_gain = audio_gain = gain self.audio_cutoff_freq = audio_cutoff_freq = 18e3/10 self.audio_attenuation = audio_attenuation = 80 self.pfb_taps = pfb_taps = firdes.low_pass_2(pfb_gain, pfb_samp_rate, pfb_cutoff_freq, pfb_transition_width, pfb_attenuation) self.audio_taps = audio_taps = firdes.low_pass_2(audio_gain, audio_samp_rate, audio_cutoff_freq, audio_transition_width, audio_attenuation) self.pfb_ntaps = pfb_ntaps = pfb_taps.__len__() self.channel = channel = 0 self.audio_rate = audio_rate = 44.1e3 self.audio_ntaps = audio_ntaps = audio_taps.__len__() ################################################## # Blocks ################################################## self._channel_layout = Qt.QVBoxLayout() self._channel_tool_bar = Qt.QToolBar(self) self._channel_layout.addWidget(self._channel_tool_bar) self._channel_tool_bar.addWidget(Qt.QLabel("fm channel"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._channel_counter = qwt_counter_pyslot() self._channel_counter.setRange(0, 125, 1) self._channel_counter.setNumButtons(2) self._channel_counter.setValue(self.channel) self._channel_tool_bar.addWidget(self._channel_counter) self._channel_counter.valueChanged.connect(self.set_channel) self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._channel_slider.setRange(0, 125, 1) self._channel_slider.setValue(self.channel) self._channel_slider.setMinimumWidth(125) self._channel_slider.valueChanged.connect(self.set_channel) self._channel_layout.addWidget(self._channel_slider) self.top_layout.addLayout(self._channel_layout) self.pfb_decimator_ccf_0 = pfb.decimator_ccf( 15, (pfb_taps), channel, 100, True, True) self.pfb_decimator_ccf_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( audio_rate / 50e3, taps=(audio_taps), flt_size=10) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 100, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 100, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/nathan/Downloads/WFM-97.9MHz-3.125Msps.dat", True) self.audio_sink_0 = audio.sink(int(audio_rate), "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=200e3, audio_decimation=int(200e3 / audio_rate), ) self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=75e-6) ################################################## # Connections ################################################## self.connect((self.pfb_decimator_ccf_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.pfb_decimator_ccf_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_fm_deemph_0, 0), (self.blocks_null_sink_0, 0))
def set_audio_attenuation(self, audio_attenuation): self.audio_attenuation = audio_attenuation self.set_audio_taps(firdes.low_pass_2(self.audio_gain, self.audio_samp_rate, self.audio_cutoff_freq, self.audio_transition_width, self.audio_attenuation))
def set_dect_channel_bandwidth(self, dect_channel_bandwidth): self.dect_channel_bandwidth = dect_channel_bandwidth self.set_resampler_filter_taps(firdes.low_pass_2(1, 3*self.baseband_sampling_rate, self.dect_occupied_bandwidth/2, (self.dect_channel_bandwidth - self.dect_occupied_bandwidth)/2, 30))
def set_baseband_sampling_rate(self, baseband_sampling_rate): self.baseband_sampling_rate = baseband_sampling_rate self.set_resampler_filter_taps(firdes.low_pass_2(1, 3*self.baseband_sampling_rate, self.dect_occupied_bandwidth/2, (self.dect_channel_bandwidth - self.dect_occupied_bandwidth)/2, 30)) self.fractional_resampler.set_resamp_ratio((3.0*self.baseband_sampling_rate/2.0)/self.dect_symbol_rate/4.0)
def __init__(self): gr.top_block.__init__(self, "Fm Channelizer") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Channelizer") try: self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc")) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_channelizer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.synth_channels = synth_channels = 6 self.channels = channels = 10 self.ch_rate = ch_rate = 100e3 self.samp_rate = samp_rate = ch_rate * channels self.gain = gain = 20 self.fm_quad_rate = fm_quad_rate = ch_rate * synth_channels self.ch_tb = ch_tb = 20e3 self.ch_bw = ch_bw = ch_rate / 2 self.audio_rate = audio_rate = 60e3 self.atten = atten = 80 self.volume = volume = 0.1 self.tun_gain = tun_gain = gain self.pfb_taps = pfb_taps = firdes.low_pass_2(1, samp_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS) self.pfb_synth_taps = pfb_synth_taps = firdes.low_pass_2( channels / 2, synth_channels * ch_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS ) self.freq_corr = freq_corr = 0 self.fm_audio_decim = fm_audio_decim = int(fm_quad_rate / audio_rate) * 2 self.channel = channel = 0 self.center_freq = center_freq = 101.1e6 + 0e3 self.address = address = "" ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._volume_counter = qwt_counter_pyslot() self._volume_counter.setRange(0, 10, 0.1) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 10, 0.1) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_grid_layout.addLayout(self._volume_layout, 3, 0, 1, 1) self._tun_gain_layout = Qt.QVBoxLayout() self._tun_gain_tool_bar = Qt.QToolBar(self) self._tun_gain_layout.addWidget(self._tun_gain_tool_bar) self._tun_gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._tun_gain_counter = qwt_counter_pyslot() self._tun_gain_counter.setRange(0, 70, 1) self._tun_gain_counter.setNumButtons(2) self._tun_gain_counter.setValue(self.tun_gain) self._tun_gain_tool_bar.addWidget(self._tun_gain_counter) self._tun_gain_counter.valueChanged.connect(self.set_tun_gain) self._tun_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._tun_gain_slider.setRange(0, 70, 1) self._tun_gain_slider.setValue(self.tun_gain) self._tun_gain_slider.setMinimumWidth(200) self._tun_gain_slider.valueChanged.connect(self.set_tun_gain) self._tun_gain_layout.addWidget(self._tun_gain_slider) self.top_grid_layout.addLayout(self._tun_gain_layout, 2, 1, 1, 1) self._freq_corr_layout = Qt.QVBoxLayout() self._freq_corr_tool_bar = Qt.QToolBar(self) self._freq_corr_layout.addWidget(self._freq_corr_tool_bar) self._freq_corr_tool_bar.addWidget(Qt.QLabel("Frequency Correction" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_corr_counter = qwt_counter_pyslot() self._freq_corr_counter.setRange(-40e3, 40e3, 100) self._freq_corr_counter.setNumButtons(2) self._freq_corr_counter.setValue(self.freq_corr) self._freq_corr_tool_bar.addWidget(self._freq_corr_counter) self._freq_corr_counter.valueChanged.connect(self.set_freq_corr) self._freq_corr_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_corr_slider.setRange(-40e3, 40e3, 100) self._freq_corr_slider.setValue(self.freq_corr) self._freq_corr_slider.setMinimumWidth(200) self._freq_corr_slider.valueChanged.connect(self.set_freq_corr) self._freq_corr_layout.addWidget(self._freq_corr_slider) self.top_grid_layout.addLayout(self._freq_corr_layout, 3, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args(cpu_format="fc32", channels=range(1)) ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(center_freq + freq_corr, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_FLATTOP, # wintype 0, # fc ch_rate * synth_channels, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_BLACKMAN_hARRIS, # wintype 0, # fc samp_rate, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(synth_channels, (pfb_synth_taps), True) self.pfb_synthesizer_ccf_0.set_channel_map(([10, 11, 0, 1, 2, 3])) self.pfb_synthesizer_ccf_0.declare_sample_delay(0) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(channels, (pfb_taps), 2.0, atten) self.pfb_channelizer_ccf_0.set_channel_map(()) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 44.1e3 / (fm_quad_rate / fm_audio_decim), taps=None, flt_size=32 ) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc( 2, (firdes.low_pass_2(1, ch_rate * synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS)) ) self.fir_filter_xxx_0.declare_sample_delay(0) self._channel_layout = Qt.QVBoxLayout() self._channel_tool_bar = Qt.QToolBar(self) self._channel_layout.addWidget(self._channel_tool_bar) self._channel_tool_bar.addWidget(Qt.QLabel("Output Channel" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._channel_counter = qwt_counter_pyslot() self._channel_counter.setRange(0, channels - 1, 1) self._channel_counter.setNumButtons(2) self._channel_counter.setValue(self.channel) self._channel_tool_bar.addWidget(self._channel_counter) self._channel_counter.valueChanged.connect(self.set_channel) self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._channel_slider.setRange(0, channels - 1, 1) self._channel_slider.setValue(self.channel) self._channel_slider.setMinimumWidth(200) self._channel_slider.valueChanged.connect(self.set_channel) self._channel_layout.addWidget(self._channel_slider) self.top_grid_layout.addLayout(self._channel_layout, 2, 0, 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx = blocks.multiply_const_vff((volume,)) self.audio_sink = audio.sink(44100, "", True) self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=fm_quad_rate, audio_decimation=fm_audio_decim) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_wfm_rcv, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx, 0), (self.audio_sink, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.pfb_synthesizer_ccf_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.pfb_synthesizer_ccf_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.pfb_synthesizer_ccf_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.pfb_synthesizer_ccf_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.pfb_synthesizer_ccf_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.pfb_synthesizer_ccf_0, 5)) self.connect((self.pfb_synthesizer_ccf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _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 = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq = offset_freq = 119e6 self.freq_corr = freq_corr = 65 self.freq = freq = 591.28e6 self.base_freq = base_freq = 560e6 ################################################## # 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=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._offset_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq, callback=self.set_offset_freq, label="Frequency select", choices=[119e6,120.5e6,123.85e6,126.55e6,128.65e6,132.225e6,560e6], labels=["bradley 119M","worc tow 120.5M", "worc ground 123.85M","worc atais126.55M","worc clrnc 128.65M","logan twr 132.225M","560AM"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq_chooser) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(offset_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=48, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=500e6, maximum=1200e6, num_steps=700, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
rtl0.set_bandwidth(1e6, 0) rtl1 = osmosdr.source( args="nchan=" + str(1) + " " + "rtl=1" ) rtl1.set_sample_rate(samp_rate) rtl1.set_center_freq(cf, 0) rtl1.set_freq_corr(0, 0) rtl1.set_dc_offset_mode(2, 0) rtl1.set_iq_balance_mode(0, 0) rtl1.set_gain_mode(0, 0) rtl1.set_gain(rfgain, 0) rtl1.set_if_gain(ifgain, 0) rtl1.set_bb_gain(0, 0) rtl1.set_antenna("", 0) rtl1.set_bandwidth(1e6, 0) lpf0 = filter.fir_filter_ccc(dec, (firdes.low_pass_2(1, samp_rate, 50e3, 10e3, 40, firdes.WIN_BLACKMAN_hARRIS))) lpf1 = filter.fir_filter_ccc(dec, (firdes.low_pass_2(1, samp_rate, 50e3, 10e3, 40, firdes.WIN_BLACKMAN_hARRIS))) dc0 = filter.dc_blocker_cc(1000, True) dc1 = filter.dc_blocker_cc(1000, True) rtl0.set_gain(0.0, 0) rtl0.set_if_gain(0.0, 0) rtl1.set_gain(0.0, 0) rtl1.set_if_gain(0.0, 0) tstamp=time_stamp() os.makedirs("%s-%s/000"%(op.name,tstamp)) os.makedirs("%s-%s/001"%(op.name,tstamp)) print "Making dir %s-%s/000"%(op.name,tstamp) print "Making dir %s-%s/001"%(op.name,tstamp)
def set_nfilts(self, nfilts): self.nfilts = nfilts self.pfb_arb_resampler_xxx_0.set_taps((firdes.low_pass_2(self.volume*self.nfilts, self.nfilts*self.in_rate, 15e3, 1e3, 60, firdes.WIN_KAISER)))
def set_samp_rate_0(self, samp_rate_0): self.samp_rate_0 = samp_rate_0 self.freq_xlating_fir_filter_xxx_0.set_taps((firdes.low_pass_2(1,self.samp_rate_0,100e3,50e3,40))) self.rtlsdr_source_0.set_sample_rate(self.samp_rate_0)
def __init__(self, bind_addr="0.0.0.0", dest_addr="127.0.0.1", lo_offset=100e3, recv_port=16886, rx_sdr_device="usrpb200", send_port=5022, tx_sdr_device="usrpb200", wod_port=5023): gr.top_block.__init__(self, "UPSat Tranceiver") ################################################## # Parameters ################################################## self.bind_addr = bind_addr self.dest_addr = dest_addr self.lo_offset = lo_offset self.recv_port = recv_port self.rx_sdr_device = rx_sdr_device self.send_port = send_port self.tx_sdr_device = tx_sdr_device self.wod_port = wod_port ################################################## # Variables ################################################## self.samples_per_symbol_tx = samples_per_symbol_tx = 4*8 self.sq_wave = sq_wave = (1.0, ) * samples_per_symbol_tx self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.gaussian_taps = gaussian_taps = filter.firdes.gaussian(1.0, samples_per_symbol_tx, 1.0, 4*samples_per_symbol_tx) self.deviation = deviation = 3.9973e3 self.decimation_rx = decimation_rx = 20 self.baud_rate_uplink = baud_rate_uplink = 1200 self.baud_rate_downlink = baud_rate_downlink = 9600 self.tx_frequency = tx_frequency = 145.835e6 self.taps = taps = firdes.low_pass(1.0, samp_rate_rx, 20000, 60000, firdes.WIN_HAMMING, 6.76) self.samp_rate_tx = samp_rate_tx = satnogs.hw_tx_settings[rx_sdr_device]['samp_rate'] self.rx_frequency = rx_frequency = 435.765e6 self.modulation_index_uplink = modulation_index_uplink = deviation / (baud_rate_uplink / 2.0) self.modulation_index_downlink = modulation_index_downlink = deviation / (baud_rate_downlink / 2.0) self.interp_taps = interp_taps = numpy.convolve(numpy.array(gaussian_taps), numpy.array(sq_wave)) self.first_stage_samp_rate_rx = first_stage_samp_rate_rx = samp_rate_rx / decimation_rx ################################################## # Blocks ################################################## self.satnogs_upsat_fsk_frame_encoder_0 = satnogs.upsat_fsk_frame_encoder([0x33]*8 , [0x7A, 0x0E], False, False, False, True, True, "ABCD", 0, "ON02GR", 0, 64) self.satnogs_udp_msg_source_0 = satnogs.udp_msg_source(bind_addr, recv_port, 1500) self.satnogs_udp_msg_sink_0_0_0 = satnogs.udp_msg_sink(dest_addr, wod_port, 1500) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(dest_addr, send_port, 1500) self.satnogs_qb50_deframer_0 = satnogs.qb50_deframer(0xe) self.satnogs_multi_format_msg_sink_0 = satnogs.multi_format_msg_sink(1) self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm('GND', 0, False, True, 256, 3) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate_tx / (baud_rate_uplink * samples_per_symbol_tx), taps=(firdes.low_pass_2(32, 32, 0.8, 0.1, 60)), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_frequency - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'], 0) self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[rx_sdr_device]['if_gain'], 0) self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'], 0) self.osmosdr_source_0.set_antenna(satnogs.hw_rx_settings[rx_sdr_device]['antenna'], 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + satnogs.hw_tx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_sink_0.set_sample_rate(samp_rate_tx) self.osmosdr_sink_0.set_center_freq(tx_frequency - lo_offset, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(satnogs.hw_tx_settings[tx_sdr_device]['rf_gain'], 0) self.osmosdr_sink_0.set_if_gain(satnogs.hw_tx_settings[tx_sdr_device]['if_gain'], 0) self.osmosdr_sink_0.set_bb_gain(satnogs.hw_tx_settings[tx_sdr_device]['bb_gain'], 0) self.osmosdr_sink_0.set_antenna(satnogs.hw_tx_settings[tx_sdr_device]['antenna'], 0) self.osmosdr_sink_0.set_bandwidth(samp_rate_tx, 0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(samples_per_symbol_tx, (interp_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation_rx, (taps), lo_offset, samp_rate_rx) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(first_stage_samp_rate_rx/baud_rate_downlink, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate_tx, analog.GR_COS_WAVE, lo_offset , 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(((first_stage_samp_rate_rx) / baud_rate_downlink)/(math.pi*modulation_index_downlink)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc((math.pi*modulation_index_uplink) / samples_per_symbol_tx) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'failed_pdu'), (self.satnogs_multi_format_msg_sink_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_qb50_deframer_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'wod'), (self.satnogs_udp_msg_sink_0_0_0, 'in')) self.msg_connect((self.satnogs_udp_msg_source_0, 'msg'), (self.satnogs_upsat_fsk_frame_encoder_0, 'pdu')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.satnogs_upsat_fsk_frame_encoder_0, 0), (self.interp_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Channelizer Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Channelizer Tx") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ofdm_channelizer_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100e3 self.taps = taps = firdes.low_pass_2(6, 6*samp_rate, samp_rate/3.0, samp_rate/4.0, 60) ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_FLATTOP, #wintype 0, #fc samp_rate*6, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf( 6, (taps), False) self.pfb_synthesizer_ccf_0.set_channel_map(([5])) self.pfb_synthesizer_ccf_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_sig_source_x_0_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -20000, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 20000, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -10000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.pfb_synthesizer_ccf_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.pfb_synthesizer_ccf_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.pfb_synthesizer_ccf_0, 2)) self.connect((self.analog_sig_source_x_0_2, 0), (self.pfb_synthesizer_ccf_0, 3)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_synthesizer_ccf_0, 0), (self.blocks_throttle_0, 0))