def key_factory(index): print "FACTORY CALLED index = %d" % (index) r = es.es_pyhandler() excess_bw = 0.5 sps = 4 amplitude = sig_amp taps = gr.firdes.root_raised_cosine( sps * amplitude, # Gain sps, # Sampling rate 1.0, # Symbol rate excess_bw, # Roll-off factor 11 * sps) # Number of taps blocks = {} blocks["src"] = es.vector_source([1]) blocks["scrambler"] = digital.scrambler_bb(0x8A, 0x7F, 7) blocks["mapper"] = digital.chunks_to_symbols_bc( [-1 + 0j, 0 + 1j, 1 + 0j, 0 - 1j]) blocks["rrc"] = filter.interp_fir_filter_ccf(sps, taps) r.sink = es.vector_sink([gr.sizeof_gr_complex]) r.set_pyb2(blocks) tb = gr.top_block() tb.connect(blocks["src"], blocks["scrambler"], blocks["mapper"], blocks["rrc"], r.sink) r.tb = tb.to_top_block() return r
def __init__(self): gr.top_block.__init__(self, "test") self._lock = threading.RLock() ################################################## # Variables ################################################## self.bw = bw = 250000 self.time_wait = time_wait = 200 self.threshold = threshold = 10 self.sf = sf = 12 self.samp_rate = samp_rate = bw self.pay_len = pay_len = 64 self.noise = noise = 5 self.n_frame = n_frame = 5 self.multi_control = multi_control = True self.mult_const = mult_const = 1 self.impl_head = impl_head = False self.has_crc = has_crc = False self.frame_period = frame_period = 200 self.cr = cr = 4 ################################################## # Blocks ################################################## self.lora_sdr_hier_tx_1 = lora_sdr.hier_tx( pay_len, n_frame, "TrccpfQHyKfvXswsA4ySxtTiIvi10nSJCUJPYonkWqDHH005UmNfGuocPw3FHKc9", cr, sf, impl_head, has_crc, samp_rate, bw, time_wait, [8, 16], True) self.lora_sdr_hier_tx_1.set_min_output_buffer(32768) self.lora_sdr_hier_rx_1 = lora_sdr.hier_rx(samp_rate, bw, sf, impl_head, cr, pay_len, has_crc, [8, 16], True) self.lora_sdr_frame_detector_1 = lora_sdr.frame_detector( sf, samp_rate, bw, 600) self.lora_sdr_frame_detector_1.set_min_output_buffer(32768) self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccf( 4, (-0.128616616593872, -0.212206590789194, -0.180063263231421, 3.89817183251938e-17, 0.300105438719035, 0.636619772367581, 0.900316316157106, 1, 0.900316316157106, 0.636619772367581, 0.300105438719035, 3.89817183251938e-17, -0.180063263231421, -0.212206590789194, -0.128616616593872)) self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_1_0.set_min_output_buffer(32768) self.blocks_throttle_0_1_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 10, True) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0_1_0, 0), (self.lora_sdr_frame_detector_1, 0)) self.connect((self.interp_fir_filter_xxx_0_1_0, 0), (self.lora_sdr_hier_rx_1, 0)) self.connect((self.lora_sdr_frame_detector_1, 0), (self.interp_fir_filter_xxx_0_1_0, 0)) self.connect((self.lora_sdr_hier_tx_1, 0), (self.blocks_throttle_0_1_0, 0))
def graph (args): print os.getpid() nargs = len (args) if nargs == 1: infile = args[0] else: sys.stderr.write('usage: interp.py input_file\n') sys.exit (1) tb = gr.top_block() srcf = blocks.file_source(gr.sizeof_short,infile) s2ss = blocks.stream_to_streams(gr.sizeof_short,2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() src0 = blocks.float_to_complex() lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) lp = filter.interp_fir_filter_ccf(3, lp_coeffs) file = blocks.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") tb.connect( srcf, s2ss ) tb.connect( (s2ss, 0), s2f1, (src0,0) ) tb.connect( (s2ss, 1), s2f2, (src0,1) ) tb.connect( src0, lp, file) tb.start() raw_input ('Head End: Press Enter to stop') tb.stop()
def graph(args): print os.getpid() nargs = len(args) if nargs == 1: infile = args[0] else: sys.stderr.write('usage: interp.py input_file\n') sys.exit(1) tb = gr.top_block() srcf = blocks.file_source(gr.sizeof_short, infile) s2ss = blocks.stream_to_streams(gr.sizeof_short, 2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() src0 = blocks.float_to_complex() lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) lp = filter.interp_fir_filter_ccf(3, lp_coeffs) file = blocks.file_sink(gr.sizeof_gr_complex, "/tmp/atsc_pipe_1") tb.connect(srcf, s2ss) tb.connect((s2ss, 0), s2f1, (src0, 0)) tb.connect((s2ss, 1), s2f2, (src0, 1)) tb.connect(src0, lp, file) tb.start() raw_input('Head End: Press Enter to stop') tb.stop()
def __init__(self, sps=2.0, rolloff=0.35, preamble=[0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,1,1,1,0,0,0,0], modtype=mapper.QPSK, greymap=[0,1,3,2] ): gr.hier_block2.__init__(self, "preamble_correlator", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_float)) #gr.io_signature(0,0,0)) # vet preamble bits for b in preamble: assert(b >= 0 and b<=1); tb = gr.top_block(); vs = blocks.vector_source_b( preamble ); mp = mapper.mapper(modtype, greymap); it = filter.interp_fir_filter_ccf(2, firdes.root_raised_cosine(1, 1.0, 1.0/sps, rolloff, 21)) vk = blocks.vector_sink_c(); tb.connect(vs,mp,it,vk); tb.run(); self.taps = list(vk.data()); self.taps.reverse(); self.taps = map(lambda x: x.conjugate(), self.taps); self.flt = filter.fft_filter_ccc(1, self.taps); self.mag = blocks.complex_to_mag_squared(); self.connect(self, self.flt, self.mag); # connect output self.connect(self.mag, self);
def key_factory(index): print "FACTORY CALLED index = %d"%(index); r = es.es_pyhandler(); excess_bw = 0.5; sps = 4; amplitude = sig_amp; taps = gr.firdes.root_raised_cosine(sps*amplitude, # Gain sps, # Sampling rate 1.0, # Symbol rate excess_bw, # Roll-off factor 11*sps) # Number of taps blocks = {}; blocks["src"] = es.vector_source([1]) blocks["scrambler"] = digital.scrambler_bb(0x8A, 0x7F, 7); blocks["mapper"] = digital.chunks_to_symbols_bc( [-1+0j, 0+1j, 1+0j, 0-1j] ); blocks["rrc"] = filter.interp_fir_filter_ccf(sps, taps); r.sink = es.vector_sink([gr.sizeof_gr_complex]); r.set_pyb2(blocks); tb = gr.top_block(); tb.connect( blocks["src"], blocks["scrambler"], blocks["mapper"], blocks["rrc"], r.sink ); r.tb = tb.to_top_block(); return r;
class InterpolationFilterBlock(FlowGraphBlock): def __init__(self): FlowGraphBlock.__init__(self) def setup(self, params): if (len(params) != 2): print "GNURadio: Invalid number of interpolation filter parameters" return None try: interpolationFactor = int(params[0]) gain = float(params[1]) except ValueError, msg: print "GNURadio: Invalid interpolation filter parameter - %s" % msg return None if ((interpolationFactor <= 0) or (interpolationFactor > 20)): print "GNURadio: Interpolation factor out of range" return None # Calculate the FIR filter taps using the Blackman-Harris window method. cutoffFreq = 0.375 / interpolationFactor transitionWidth = 0.25 / interpolationFactor filterTaps = filter.firdes.low_pass(gain, 1.0, cutoffFreq, transitionWidth, filter.firdes.WIN_BLACKMAN_HARRIS) print "Generated FIR filter with %d taps" % len(filterTaps) self.firFilter = filter.interp_fir_filter_ccf(interpolationFactor, filterTaps) return self
def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset): gr.top_block.__init__(self) rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) self.chn = channels.channel_model(noise, foffset, toffset) self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) self.vsnk_src = blocks.vector_sink_c() self.vsnk_fll = blocks.vector_sink_c() self.vsnk_frq = blocks.vector_sink_f() self.vsnk_phs = blocks.vector_sink_f() self.vsnk_err = blocks.vector_sink_f() self.connect(self.src, self.rrc, self.chn, self.fll, self.vsnk_fll) self.connect(self.rrc, self.vsnk_src) self.connect((self.fll,1), self.vsnk_frq) self.connect((self.fll,2), self.vsnk_phs) self.connect((self.fll,3), self.vsnk_err)
def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset, mode=0): gr.top_block.__init__(self) rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) gain = bw nfilts = 32 rrc_taps_rx = filter.firdes.root_raised_cosine( nfilts, sps*nfilts, 1.0, rolloff, ntaps*nfilts) data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) self.chn = channels.channel_model(noise, foffset, toffset) self.off = filter.fractional_resampler_cc(0.20, 1.0) if mode == 0: self.clk = digital.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx, nfilts, nfilts//2, 1) self.taps = self.clk.taps() self.dtaps = self.clk.diff_taps() self.delay = int(scipy.ceil(((len(rrc_taps)-1)/2 + (len(self.taps[0])-1)/2)/float(sps))) + 1 self.vsnk_err = blocks.vector_sink_f() self.vsnk_rat = blocks.vector_sink_f() self.vsnk_phs = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) self.connect((self.clk,2), self.vsnk_rat) self.connect((self.clk,3), self.vsnk_phs) else: # mode == 1 mu = 0.5 gain_mu = bw gain_omega = 0.25*gain_mu*gain_mu omega_rel_lim = 0.02 self.clk = digital.clock_recovery_mm_cc(sps, gain_omega, mu, gain_mu, omega_rel_lim) self.vsnk_err = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) self.vsnk_src = blocks.vector_sink_c() self.vsnk_clk = blocks.vector_sink_c() self.connect(self.src, self.rrc, self.chn, self.off, self.clk, self.vsnk_clk) self.connect(self.src, self.vsnk_src)
def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset, mode=0): gr.top_block.__init__(self) rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) gain = bw nfilts = 32 rrc_taps_rx = filter.firdes.root_raised_cosine( nfilts, sps*nfilts, 1.0, rolloff, ntaps*nfilts) data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) self.chn = channels.channel_model(noise, foffset, toffset) self.off = filter.mmse_resampler_cc(0.20, 1.0) if mode == 0: self.clk = digital.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx, nfilts, nfilts//2, 1) self.taps = self.clk.taps() self.dtaps = self.clk.diff_taps() self.delay = int(scipy.ceil(((len(rrc_taps)-1)//2 + (len(self.taps[0])-1)//2 )//float(sps))) + 1 self.vsnk_err = blocks.vector_sink_f() self.vsnk_rat = blocks.vector_sink_f() self.vsnk_phs = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) self.connect((self.clk,2), self.vsnk_rat) self.connect((self.clk,3), self.vsnk_phs) else: # mode == 1 mu = 0.5 gain_mu = bw gain_omega = 0.25*gain_mu*gain_mu omega_rel_lim = 0.02 self.clk = digital.clock_recovery_mm_cc(sps, gain_omega, mu, gain_mu, omega_rel_lim) self.vsnk_err = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) self.vsnk_src = blocks.vector_sink_c() self.vsnk_clk = blocks.vector_sink_c() self.connect(self.src, self.rrc, self.chn, self.off, self.clk, self.vsnk_clk) self.connect(self.src, self.vsnk_src)
def __init__(self): args = get_args() gr.top_block.__init__(self) self._usrp = None self._channels_id_list = None self._m_board = 0 # Init and configure USRP self.init_usrp(self._m_board, args.ip_address, args.clock_rate, args.sampling_rate, args.number_of_channels, args.internal_clock) # Configure front-ends if args.pa_gain > 0 and args.disable_safety: self.configure_front_ends(args.pa_gain) else: print('Safety engaged, will not increase the PA gain.') self.configure_front_ends(0) # Tune self.tune_front_ends(args.center_frequency, args.no_dsp_offset, self._m_board) # Load files or activate sine-wave if args.sine_frequency is None: ntaps = args.K * args.samples_per_symbol self._tx_rrc_taps = filter.firdes.root_raised_cosine( args.samples_per_symbol, args.samples_per_symbol, 1.0, args.rolloff_factor, ntaps) print( 'Number of taps for pulse-shaping: {:d} ({:d} sps, alpha {:f})' .format(ntaps, args.samples_per_symbol, args.rolloff_factor)) # Load binary file for k in np.arange(len(args.filename)): print('Load file {:s} on channel {:d}'.format( args.filename[k], self._channels_id_list[k])) print('Scaling:', args.scaling) self.connect( blocks.file_source(gr.sizeof_gr_complex, args.filename[k], repeat=True), blocks.multiply_const_cc(args.scaling[k]), filter.interp_fir_filter_ccf(args.samples_per_symbol, self._tx_rrc_taps), (self._usrp, self._channels_id_list[k])) else: self._signal_source = analog.sig_source_c(args.sampling_rate, analog.GR_SIN_WAVE, args.sine_frequency, args.scaling[0]) # Connect all blocks and run for channel_id in self._channels_id_list: self.connect(self._signal_source, (self._usrp, channel_id)) print('Transmission setup completed.')
def __init__(self, channel_shift_hz=0, random_source_seed=0, sample_rate=0, symbol_rate=1): gr.hier_block2.__init__( self, "Hurdle2 Fm", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.channel_shift_hz = channel_shift_hz self.random_source_seed = random_source_seed self.sample_rate = sample_rate self.symbol_rate = symbol_rate ################################################## # Blocks ################################################## self.low_pass_filter_0_0_0_0 = filter.interp_fir_filter_ccf( 5, firdes.low_pass(1, sample_rate, symbol_rate * 5, symbol_rate, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=10000, quad_rate=600000, tau=75e-6, max_dev=50e3, ) self.analog_sig_source_x_0_0 = analog.sig_source_c( sample_rate, analog.GR_COS_WAVE, channel_shift_hz, 1, 0) self.analog_noise_source_x_1 = analog.noise_source_f( analog.GR_GAUSSIAN, 0.3, random_source_seed) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_1, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.low_pass_filter_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self, 0)) self.connect((self.low_pass_filter_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0))
def __init__(self, principal_gui, options): gr.hier_block2.__init__(self, "bpsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature #Enter the parameters of modulation self._samples_per_symbol = options.samples_per_symbol self.verbose = options.verbose self._gray_code =_def_gray_code if self._samples_per_symbol < 2: raise TypeError, "samples_per_symbol must be >= 2, is %r" % (self._samples_per_symbol,) arity = pow(2,self.bits_per_symbol()) # Automatic gain control #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.agc = analog.agc2_cc(1e-5, 1.0,1.0,1.0) #self.agc = gr.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * self._samples_per_symbol self.rrc_taps = filter.firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate 0.35, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps) self._costas = digital.costas_loop_cc(6.28/100.0, 2) self.gr_null_sink = blocks.null_sink(gr.sizeof_float*1) self.connect((self._costas, 1), (self.gr_null_sink, 0)) self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol, # Initial samples/symbol 1e-06, # Second order gain 0.5, # Initial symbol phase 0.001, # First order gain 0.0001) # Maximum timing offset if self.verbose: self._print_verbage() # Do differential decoding based on phase change of symbols #self.diffdec = gr.diff_phasor_cc() # Connect and Initialize base class self.connect(self, self.agc, self.rrc_filter, (self._costas,0), self._mm, self)
def __init__(self): gr.top_block.__init__(self, "Motorola CQUAM v1.4") ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(1, 44100, 11e3, 1e3, firdes.WIN_BLACKMAN, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/mnt/mediay/SEND/output_4.wav', 2, 44100, 16) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.3, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_3 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_source_0 = audio.source(44100, 'tx_source', True) self.analog_sig_source_x_2_0_0 = analog.sig_source_f( 44100, analog.GR_SIN_WAVE, 25, 0.08, 0) self.analog_sig_source_x_2_0 = analog.sig_source_f( 44100, analog.GR_COS_WAVE, 0, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_2_0_0, 0), (self.blocks_add_xx_3, 0)) self.connect((self.audio_source_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.audio_source_0, 1), (self.blocks_add_xx_1, 1)) self.connect((self.audio_source_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.audio_source_0, 1), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_3, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_add_xx_3, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))
def test01(self): sps = 4 rolloff = 0.35 bw = 2*math.pi/100.0 ntaps = 45 # Create pulse shape filter rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) # The frequency offset to correct foffset = 0.2 / (2.0*math.pi) # Create a set of 1's and -1's, pulse shape and interpolate to sps random.seed(0) data = [2.0*random.randint(0, 2) - 1.0 for i in range(200)] self.src = blocks.vector_source_c(data, False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) # Mix symbols with a complex sinusoid to spin them self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1) self.mix = blocks.multiply_cc() # FLL will despin the symbols to an arbitrary phase self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) # Create sinks for all outputs of the FLL # we will only care about the freq and error outputs self.vsnk_frq = blocks.vector_sink_f() self.nsnk_fll = blocks.null_sink(gr.sizeof_gr_complex) self.nsnk_phs = blocks.null_sink(gr.sizeof_float) self.nsnk_err = blocks.null_sink(gr.sizeof_float) # Connect the blocks self.tb.connect(self.nco, (self.mix,1)) self.tb.connect(self.src, self.rrc, (self.mix,0)) self.tb.connect(self.mix, self.fll, self.nsnk_fll) self.tb.connect((self.fll,1), self.vsnk_frq) self.tb.connect((self.fll,2), self.nsnk_phs) self.tb.connect((self.fll,3), self.nsnk_err) self.tb.run() N = 700 dst_data = self.vsnk_frq.data()[N:] expected_result = len(dst_data)* [-0.20,] self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
def __init__(self): gr.top_block.__init__(self, "Bpsk Tx") ################################################## # Variables ################################################## self.sync_word = sync_word = [complex(1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(-1, 0), complex(1, 0), complex(1, 0), complex(-1, 0)] self.samp_rate = samp_rate = 1000000 self.samp_per_symb = samp_per_symb = 8 self.payload_mod = payload_mod = digital.constellation_bpsk() self.packet_len = packet_len = 96 self.length_tag_name = length_tag_name = "packet_len" self.bandwidth_excess = bandwidth_excess = .9 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.interp_fir_filter_ccf(samp_per_symb, firdes.root_raised_cosine( samp_per_symb, samp_per_symb, 1, bandwidth_excess, 11*samp_per_symb)) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.dctk_generic_tx_path_0 = dctk.generic_tx_path( payload_packet_len=packet_len, sync_packet_len=len(sync_word), ) self.blocks_vector_source_x_0 = blocks.vector_source_c(sync_word, True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/csmedina/WiComModules/gr-dctk/build/tx_bits.txt") self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/csmedina/WiComModules/gr-dctk/build/tx_symbols.txt") self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/csmedina/WiComModules/gr-dctk/build/tx_2usrp.txt") self.blocks_file_sink_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, packet_len)), True) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_0, 0), (self.dctk_generic_tx_path_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.dctk_generic_tx_path_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.dctk_generic_tx_path_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset): gr.top_block.__init__(self) rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) data = 2.0*numpy.random.randint(0, 2, N) - 1.0 data = numpy.exp(1j*poffset) * data self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) self.chn = channels.channel_model(noise, foffset, toffset) self.cst = digital.costas_loop_cc(bw, 2) self.vsnk_src = blocks.vector_sink_c() self.vsnk_cst = blocks.vector_sink_c() self.vsnk_frq = blocks.vector_sink_f() self.connect(self.src, self.rrc, self.chn, self.cst, self.vsnk_cst) self.connect(self.rrc, self.vsnk_src) self.connect((self.cst,1), self.vsnk_frq)
def __init__(self, sps=2.0, rolloff=0.35, preamble=[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 ], modtype=mapper.QPSK, greymap=[0, 1, 3, 2]): gr.hier_block2.__init__(self, "preamble_correlator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) #gr.io_signature(0,0,0)) # vet preamble bits for b in preamble: assert (b >= 0 and b <= 1) tb = gr.top_block() vs = blocks.vector_source_b(preamble) mp = mapper.mapper(modtype, greymap) it = filter.interp_fir_filter_ccf( 2, firdes.root_raised_cosine(1, 1.0, 1.0 / sps, rolloff, 21)) vk = blocks.vector_sink_c() tb.connect(vs, mp, it, vk) tb.run() self.taps = list(vk.data()) self.taps.reverse() self.taps = map(lambda x: x.conjugate(), self.taps) self.flt = filter.fft_filter_ccc(1, self.taps) self.mag = blocks.complex_to_mag_squared() self.connect(self, self.flt, self.mag) # connect output self.connect(self.mag, self)
def graph (args): nargs = len(args) if nargs == 2: infile = args[0] outfile = args[1] else: raise ValueError('usage: interp.py input_file output_file\n') tb = gr.top_block () # Convert to a from shorts to a stream of complex numbers. srcf = blocks.file_source (gr.sizeof_short,infile) s2ss = blocks.stream_to_streams(gr.sizeof_short,2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() src0 = blocks.float_to_complex() tb.connect(srcf, s2ss) tb.connect((s2ss, 0), s2f1, (src0, 0)) tb.connect((s2ss, 1), s2f2, (src0, 1)) # Low pass filter it and increase sample rate by a factor of 3. lp_coeffs = filter.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING ) lp = filter.interp_fir_filter_ccf ( 3, lp_coeffs ) tb.connect(src0, lp) # Upconvert it. duc_coeffs = filter.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING ) duc = filter.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, 5.75e6, 19.2e6 ) # Discard the imaginary component. c2f = blocks.complex_to_float() tb.connect(lp, duc, c2f) # Frequency Phase Lock Loop input_rate = 19.2e6 IF_freq = 5.75e6 # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE/2. NTAPS = 279 tt = filter.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS) # heterodyne the low pass coefficients up to the specified bandpass # center frequency. Note that when we do this, the filter bandwidth # is effectively twice the low pass (2.69 * 2 = 5.38) and hence # matches the diagram in the ATSC spec. arg = 2. * math.pi * IF_freq / input_rate t=[] for i in range(len(tt)): t += [tt[i] * 2. * math.cos(arg * i)] rrc = filter.fir_filter_fff(1, t) fpll = atsc.fpll() pilot_freq = IF_freq - 3e6 + 0.31e6 lower_edge = 6e6 - 0.31e6 upper_edge = IF_freq - 3e6 + pilot_freq transition_width = upper_edge - lower_edge lp_coeffs = filter.firdes.low_pass(1.0, input_rate, (lower_edge + upper_edge) * 0.5, transition_width, filter.firdes.WIN_HAMMING); lp_filter = filter.fir_filter_fff(1,lp_coeffs) alpha = 1e-5 iir = filter.single_pole_iir_filter_ff(alpha) remove_dc = blocks.sub_ff() tb.connect(c2f, fpll, lp_filter) tb.connect(lp_filter, iir) tb.connect(lp_filter, (remove_dc,0)) tb.connect(iir, (remove_dc,1)) # Bit Timing Loop, Field Sync Checker and Equalizer btl = atsc.bit_timing_loop() fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() tb.connect(remove_dc, btl) tb.connect((btl, 0),(fsc, 0),(eq, 0),(fsd, 0)) tb.connect((btl, 1),(fsc, 1),(eq, 1),(fsd, 1)) # Viterbi viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() dst = blocks.file_sink(gr.sizeof_char, outfile) tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst) dst2 = blocks.file_sink(gr.sizeof_gr_complex, "atsc_complex.data") tb.connect(src0, dst2) tb.run ()
def __init__(self): gr.top_block.__init__(self, "Sv Receiver Gmsk") Qt.QWidget.__init__(self) self.setWindowTitle("Sv Receiver Gmsk") 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", "SV_receiver_GMSK") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 800000 self.samp_per_sym = samp_per_sym = 2 self.car_freq = car_freq = 600000 self.bit_per_sym = bit_per_sym = 1 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(car_freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 8, samp_rate, 0.4*samp_rate, 10000, firdes.WIN_HAMMING, 6.76)) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=samp_per_sym, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./rxfifo.ogg", False) self.blocks_file_sink_0.set_unbuffered(True) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0, 0))
def graph(args): nargs = len(args) if nargs == 2: infile = args[0] outfile = args[1] else: raise ValueError('usage: interp.py input_file output_file\n') tb = gr.top_block() # Convert to a from shorts to a stream of complex numbers. srcf = blocks.file_source(gr.sizeof_short, infile) s2ss = blocks.stream_to_streams(gr.sizeof_short, 2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() src0 = blocks.float_to_complex() tb.connect(srcf, s2ss) tb.connect((s2ss, 0), s2f1, (src0, 0)) tb.connect((s2ss, 1), s2f2, (src0, 1)) # Low pass filter it and increase sample rate by a factor of 3. lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) lp = filter.interp_fir_filter_ccf(3, lp_coeffs) tb.connect(src0, lp) # Upconvert it. duc_coeffs = filter.firdes.low_pass(1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING) duc = filter.freq_xlating_fir_filter_ccf(1, duc_coeffs, 5.75e6, 19.2e6) # Discard the imaginary component. c2f = blocks.complex_to_float() tb.connect(lp, duc, c2f) # Frequency Phase Lock Loop input_rate = 19.2e6 IF_freq = 5.75e6 # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE / 2. NTAPS = 279 tt = filter.firdes.root_raised_cosine(1.0, input_rate, symbol_rate, .115, NTAPS) # heterodyne the low pass coefficients up to the specified bandpass # center frequency. Note that when we do this, the filter bandwidth # is effectively twice the low pass (2.69 * 2 = 5.38) and hence # matches the diagram in the ATSC spec. arg = 2. * math.pi * IF_freq / input_rate t = [] for i in range(len(tt)): t += [tt[i] * 2. * math.cos(arg * i)] rrc = filter.fir_filter_fff(1, t) fpll = atsc.fpll() pilot_freq = IF_freq - 3e6 + 0.31e6 lower_edge = 6e6 - 0.31e6 upper_edge = IF_freq - 3e6 + pilot_freq transition_width = upper_edge - lower_edge lp_coeffs = filter.firdes.low_pass(1.0, input_rate, (lower_edge + upper_edge) * 0.5, transition_width, filter.firdes.WIN_HAMMING) lp_filter = filter.fir_filter_fff(1, lp_coeffs) alpha = 1e-5 iir = filter.single_pole_iir_filter_ff(alpha) remove_dc = blocks.sub_ff() tb.connect(c2f, fpll, lp_filter) tb.connect(lp_filter, iir) tb.connect(lp_filter, (remove_dc, 0)) tb.connect(iir, (remove_dc, 1)) # Bit Timing Loop, Field Sync Checker and Equalizer btl = atsc.bit_timing_loop() fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() tb.connect(remove_dc, btl) tb.connect((btl, 0), (fsc, 0), (eq, 0), (fsd, 0)) tb.connect((btl, 1), (fsc, 1), (eq, 1), (fsd, 1)) # Viterbi viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() dst = blocks.file_sink(gr.sizeof_char, outfile) tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst) dst2 = blocks.file_sink(gr.sizeof_gr_complex, "atsc_complex.data") tb.connect(src0, dst2) tb.run()
def __init__(self): gr.top_block.__init__(self, "Lora Rx") ################################################## # Variables ################################################## self.sf = sf = 7 self.samp_rate = samp_rate = 250000 self.pay_len = pay_len = 64 self.impl_head = impl_head = False self.has_crc = has_crc = False self.cr = cr = 4 self.bw = bw = 250000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('', "addr=192.168.10.3")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(915e6, 0) self.uhd_usrp_source_0.set_gain(10, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(bw, 0) self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder( impl_head, cr, pay_len, has_crc) self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec() self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc() self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync( samp_rate, bw, sf, impl_head) self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf, impl_head) self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening() self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf) self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif() self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccf( 4, (-0.128616616593872, -0.212206590789194, -0.180063263231421, 3.89817183251938e-17, 0.300105438719035, 0.636619772367581, 0.900316316157106, 1, 0.900316316157106, 0.636619772367581, 0.300105438719035, 3.89817183251938e-17, -0.180063263231421, -0.212206590789194, -0.128616616593872)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) ################################################## # Connections ################################################## self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_deinterleaver_0, 'new_frame')) self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_dewhitening_0, 'new_frame')) self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_fft_demod_0, 'new_frame')) self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_hamming_dec_0, 'new_frame')) self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_header_decoder_0, 'new_frame')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_crc_verif_0, 'CRC')) self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_crc_verif_0, 'pay_len')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_deinterleaver_0, 'CR')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_dewhitening_0, 'CRC')) self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_dewhitening_0, 'pay_len')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_fft_demod_0, 'CR')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_frame_sync_0, 'CR')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_frame_sync_0, 'crc')) self.msg_connect((self.lora_sdr_header_decoder_0, 'err'), (self.lora_sdr_frame_sync_0, 'err')) self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_frame_sync_0, 'pay_len')) self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_hamming_dec_0, 'CR')) self.connect((self.interp_fir_filter_xxx_0, 0), (self.lora_sdr_frame_sync_0, 0)) self.connect((self.lora_sdr_deinterleaver_0, 0), (self.lora_sdr_hamming_dec_0, 0)) self.connect((self.lora_sdr_dewhitening_0, 0), (self.lora_sdr_crc_verif_0, 0)) self.connect((self.lora_sdr_fft_demod_0, 0), (self.lora_sdr_gray_enc_0, 0)) self.connect((self.lora_sdr_frame_sync_0, 0), (self.lora_sdr_fft_demod_0, 0)) self.connect((self.lora_sdr_gray_enc_0, 0), (self.lora_sdr_deinterleaver_0, 0)) self.connect((self.lora_sdr_hamming_dec_0, 0), (self.lora_sdr_header_decoder_0, 0)) self.connect((self.lora_sdr_header_decoder_0, 0), (self.lora_sdr_dewhitening_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.interp_fir_filter_xxx_0, 0))
def __init__(self, principal_gui, options): gr.hier_block2.__init__(self, "bpsk_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._samples_per_symbol = options.sps self.amplitude = options.amplitude self.verbose = options.verbose self._excess_bw = _def_excess_bw self._gray_code = _def_gray_code if not isinstance(self._samples_per_symbol, int) or self._samples_per_symbol < 2: raise TypeError, ("sample per symbol must be an integer >= 2, is %d" % self._samples_per_symbol) arity = pow(2,self.bits_per_symbol()) #arity = pow (2, 2) # turn bytes into k-bit vectors self.packed_to_unpacked_bb = \ blocks.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) if self._gray_code: map_param = psk.binary_to_gray[arity] self.symbol_mapper = digital.map_bb(map_param) else: self.symbol_mapper = digital.map_bb(psk.binary_to_ungray[arity]) self.diff_encoder_bb = digital.diff_encoder_bb(arity) #This bloc allow to decode the stream #self.scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) #Transform symbols to chips self.symbols_to_chips = ieee_868_915.symbols_to_chips_bs() #self.chunks2symbols = gr.chunks_to_symbols_ic(psk.constellation[arity]) self.chunks2symbols = digital.chunks_to_symbols_sc([-1+0j, 1+0j]) self.chunks2symbols_b = digital.chunks_to_symbols_bc([-1+0j, 1+0j]) # transform chips to symbols print "bits_per_symbol", self.bits_per_symbol() self.packed_to_unpacked_ss = \ blocks.packed_to_unpacked_ss(self.bits_per_symbol(), gr.GR_MSB_FIRST) ntaps = 11 * self._samples_per_symbol # pulse shaping filter self.rrc_taps = filter.firdes.root_raised_cosine( self._samples_per_symbol, # gain (samples_per_symbol since we're # interpolating by samples_per_symbol) self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) # Connect #self.connect(self, self.bytes2chunks, self.symbol_mapper,self.scrambler, self.chunks2symbols, self.rrc_filter, self) #Modefied for IEEE 802.15.4 #self.connect(self, self.packed_to_unpacked_bb, self.symbol_mapper, self.diff_encoder_bb, self.symbols_to_chips, self.packed_to_unpacked_ss, self.chunks2symbols, self.rrc_filter, self) #For IEEE 802.15.4 915 868 MHz standard self.connect(self, self.packed_to_unpacked_bb, self.symbol_mapper, self.symbols_to_chips, self.packed_to_unpacked_ss, self.chunks2symbols, self.rrc_filter, self) #self.connect(self, self.symbols_to_chips, self.packed_to_unpacked_ss, self.chunks2symbols, self.rrc_filter, self) #self.connect(self, self.packed_to_unpacked_ss, self.chunks2symbols, self.rrc_filter, self) #case when we use a stream of bits #self.connect(self, self.chunks2symbols_b, self.rrc_filter, self) if self.verbose: self._print_verbage()
def __init__(self, constellation=gnuradio.digital.constellation_qpsk().base()): gr.top_block.__init__(self, "Packet TX time test") Qt.QWidget.__init__(self) self.setWindowTitle("Packet TX time test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "Test_for_packet_tx_time_c") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.constellation = constellation ################################################## # Variables ################################################## self.system_time_granularity_us = system_time_granularity_us = 5 self.sps = sps = 4 self.samp_rate = samp_rate = 4e6 self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.develop_mode_list = develop_mode_list = [0,1,5] ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.interp_fir_filter_ccf(sps, firdes.root_raised_cosine( 1, sps, 1.0, 0.8, 11*sps)) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.inets_t_control_tx_cc_0 = inets.t_control_tx_cc((develop_mode_list), constellation.bits_per_symbol() * (samp_rate / sps)) self.inets_pending_tx_finish_0 = inets.pending_tx_finish((develop_mode_list), system_time_granularity_us, samp_rate, "packet_len") self.inets_packetizer_0 = inets.packetizer((develop_mode_list), (preamble), 64, constellation.bits_per_symbol() * (samp_rate / sps)) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation.points()), 1) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((gnuradio.fft.window.hanning(1024)), 0, 0, False, "packet_len") self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", sps) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, constellation.bits_per_symbol(), "packet_len", False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.1, 111) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_packetizer_0, 'payload_in')) self.msg_connect((self.inets_packetizer_0, 'packet_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.inets_pending_tx_finish_0, 'spark_out'), (self.blocks_message_debug_0, 'print')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.inets_t_control_tx_cc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.inets_t_control_tx_cc_0, 0), (self.inets_pending_tx_finish_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def update(self, rxcenter, txcenter, rxsps, txsps, fast=False): ModeShell.update(self, rxcenter, txcenter, rxsps, txsps, fast=fast) """ Updates the module by its parameters. Supports a full reconfiguration and a fast reconfiguration for only simple changes such as volume, squelch, frequency, and audiosps which can be changed without much computational expense. """ rxsps = float(rxsps) self.rxsps = rxsps txsps = float(txsps) self.txsps = txsps pre = [ 'tx_vol', 'tx_sq', 'tx_cnst_src', 'tx_ftc', 'tx_ssb_shifter_mul', 'tx_ssb_shifter', 'tx_lpf', 'tx_if0', 'tx_if0_mul', 'rx_if0', 'rx_if0_mul', 'rx_lpf', 'rx_cms', 'rx_vol', 'sqblock' ] for q in pre: setattr(self, q, None) freq = self.freq.get_value() tx_audio_mul = self.tx_audio_mul.get_value() tx_ssb_shifter_freq = self.ssb_shifter_freq.get_value() tx_cutoff_freq = self.cutoff_freq.get_value() tx_filter_gain = self.tx_filter_gain.get_value() tx_cutoff_width = self.cutoff_width.get_value() tx_sqval = self.qtx_sq.get_value() rx_output_gain = self.rx_output_gain.get_value() rx_cutoff_freq = self.cutoff_freq.get_value() rx_filter_gain = self.rx_filter_gain.get_value() rx_cutoff_width = self.cutoff_width.get_value() rx_sqval = self.qrx_sq.get_value() print 'rx_cutoff_freq:%s' % rx_cutoff_freq tx_loc_freq = freq - txcenter rx_loc_freq = freq - rxcenter print '@@@@@@@@@@ KEY CHANGED WAS %s' % self.key_changed if self.key_changed == 'txpwrpri': print '$$$$ RETURNING' return if self.key_changed == 'qtx_sq' and self.tx_sq is not None: self.tx_sq.set_threshold(tx_sqval / 100.0) return if self.key_changed == 'qrx_sq' and self.sqblock is not None: self.sqblock_sq.set_threshold(rx_sqval / 100.0) return if self.key_changed == 'freq': freq = self.freq.get_value() tx_loc_freq = freq - txcenter rx_loc_freq = freq - rxcenter if abs(tx_loc_freq) < txsps * 0.7 and self.tx_vol is not None: self.rxtxstatus.set_tx_status(True) self.tx_if0_mul.set_phase_inc(tx_loc_freq / txsps * math.pi * 2.0) if abs(rx_loc_freq) < txsps * 0.7 and self.rx_if0 is not None: self.rxtxstatus.set_rx_status(True) self.rx_if0_mul.set_phase_inc(rx_loc_freq / txsps * math.pi * 2.0) if self.rx_if0 is not None and self.tx_vol is not None: return if self.key_changed == 'ssb_shifter_freq' and self.tx_ssb_shifter is not None: self.tx_ssb_shifter_mul.set_phase_inc(tx_ssb_shifter_freq / 16000.0 * math.pi * 2.0) return if self.key_changed == 'cutoff_freq' or self.key_changed == 'cutoff_width': if self.tx_lpf: self.tx_lpf.set_taps( filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) if self.rx_lpf: self.rx_lpf.set_taps( filter.firdes.low_pass(int(rx_filter_gain), rxsps, rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return if self.key_changed == 'tx_filter_gain' and self.tx_lpf is not None: self.tx_lpf.set_taps( filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return if self.key_changed == 'rx_filter_gain' and self.rx_lpf is not None: self.rx_lpf.set_taps( filter.firdes.low_pass(int(rx_filter_gain), rxsps, rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return # Turn it off to disconnect them before the variable contents # below are replaced. was_active = self.active self.off() if abs(tx_loc_freq) > txsps * 0.75: self.tx_vol = None self.rxtxstatus.set_tx_status(False) else: self.tx_vol = blocks.multiply_const_ff(tx_audio_mul) self.tx_sq = analog.standard_squelch(audio_rate=16000) self.tx_sq.set_threshold(tx_sqval / 100.0) self.tx_cnst_src = analog.sig_source_f(int(16000), analog.GR_CONST_WAVE, 0, 0, 0) self.tx_ftc = blocks.float_to_complex() self.tx_ssb_shifter_mul = blocks.rotator_cc() self.tx_ssb_shifter_mul.set_phase_inc(tx_ssb_shifter_freq / 16000.0 * math.pi * 2.0) self.tx_lpf = filter.interp_fir_filter_ccf( int(txsps / 16000), filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) self.tx_if0_mul = blocks.rotator_cc() self.tx_if0_mul.set_phase_inc(tx_loc_freq / txsps * math.pi * 2.0) # Late failure is okay. Better false negative than RX is OFF. self.rxtxstatus.set_tx_status(True) if abs(rx_loc_freq) > rxsps * 0.75: self.rx_if0 = None self.rxtxstatus.set_rx_status(False) else: # Early failure is okay. Better false positive that TX is ON. self.rxtxstatus.set_rx_status(True) self.rx_if0_mul = blocks.rotator_cc() self.rx_if0_mul.set_phase_inc(-rx_loc_freq / rxsps * math.pi * 2.0) self.rx_lpf = filter.fir_filter_ccf( int(rxsps / 16000), filter.firdes.low_pass(int(rx_filter_gain), int(rxsps), rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_HAMMING, 6.76)) self.rx_cms = blocks.complex_to_mag_squared() self.rx_vol = blocks.multiply_const_ff(10.0**(rx_output_gain / 10.0)) self.sqblock = analog.standard_squelch(16000) self.sqblock.set_threshold(float(rx_sqval) / 100.0) self.rx_sigstr = gblocks.SignalStrengthCalculator(numpy.float32) self.chanover.set_audio_strength_query_func( self.rx_sigstr.get_value) if was_active: self.on() else: self.off()
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.variable_constellation_0_1 = variable_constellation_0_1 = digital.constellation_calcdist(([1+0j,0.707+0.707j, -0.707+0.707j, 0+1j, 0.707-0.707j, 0-1j, -1+0j, -0.707-0.707j]), ([0, 1, 2, 3, 4, 5, 6, 7]), 4, 1).base() self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist(([0.707+0.707j, -0.707-0.707j]), ([0, 1]), 4, 1).base() self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 1).base() self.samp_rate = samp_rate = 10000 self.EbN0 = EbN0 = 10 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0_0 = filter.fir_filter_ccf(4, firdes.root_raised_cosine( 1, samp_rate, samp_rate/4, 0.35, 10*4)) self.root_raised_cosine_filter_0 = filter.interp_fir_filter_ccf(4, firdes.root_raised_cosine( 1, samp_rate, samp_rate/4, 0.35, 10*4)) self.qtgui_time_sink_x_1_0_0_1_0_0 = qtgui.time_sink_f( 24*2, #size samp_rate/10, #samp_rate "Tx Bits", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1_0_0.set_update_time(.10) self.qtgui_time_sink_x_1_0_0_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0_1_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0_0_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0_1_0_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0_0_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0_1_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_1_0_0_win) self.qtgui_time_sink_x_1_0_0_1_0 = qtgui.time_sink_f( 24*2, #size samp_rate/10, #samp_rate "RX bits", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1_0.set_update_time(.10) self.qtgui_time_sink_x_1_0_0_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0_0_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_1_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["BER", "", "", "", "", "", "", "", "", ""] units = ["x10^-4", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e4, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_2 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_2.set_update_time(0.10) self.qtgui_const_sink_x_2.set_y_axis(-2, 2) self.qtgui_const_sink_x_2.set_x_axis(-2, 2) self.qtgui_const_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_2.enable_autoscale(True) self.qtgui_const_sink_x_2.enable_grid(False) if not True: self.qtgui_const_sink_x_2.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_2.set_line_label(i, labels[i]) self.qtgui_const_sink_x_2.set_line_width(i, widths[i]) self.qtgui_const_sink_x_2.set_line_color(i, colors[i]) self.qtgui_const_sink_x_2.set_line_style(i, styles[i]) self.qtgui_const_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_2_win = sip.wrapinstance(self.qtgui_const_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_2_win) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(variable_constellation_0_1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([1+0j,0.707+0.707j, -0.707+0.707j, 0+1j, 0.707-0.707j, 0-1j, -1+0j, -0.707-0.707j]), 1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(3) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, 30) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='SER', win_size=100000, bits_per_symbol=2, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 10000)), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1.0 / math.sqrt(2*2.0 * digital.constellation_8psk().bits_per_symbol() * 10**(EbN0/10)), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_delay_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1_0_0_1_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0_0_1_0_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_const_sink_x_2, 0))
def update(self, rxcenter, txcenter, rxsps, txsps, fast=False): ModeShell.update(self, rxcenter, txcenter, rxsps, txsps, fast=fast) """ Updates the module by its parameters. Supports a full reconfiguration and a fast reconfiguration for only simple changes such as volume, squelch, frequency, and audiosps which can be changed without much computational expense. """ rxsps = float(rxsps) self.rxsps = rxsps txsps = float(txsps) self.txsps = txsps pre = [ 'tx_vol', 'tx_sq', 'tx_cnst_src', 'tx_ftc', 'tx_ssb_shifter_mul', 'tx_ssb_shifter', 'tx_lpf', 'tx_if0', 'tx_if0_mul', 'rx_if0', 'rx_if0_mul', 'rx_lpf', 'rx_cms', 'rx_vol', 'sqblock' ] for q in pre: setattr(self, q, None) freq = self.freq.get_value() tx_audio_mul = self.tx_audio_mul.get_value() tx_ssb_shifter_freq = self.ssb_shifter_freq.get_value() tx_cutoff_freq = self.cutoff_freq.get_value() tx_filter_gain = self.tx_filter_gain.get_value() tx_cutoff_width = self.cutoff_width.get_value() tx_sqval = self.qtx_sq.get_value() rx_output_gain = self.rx_output_gain.get_value() rx_cutoff_freq = self.cutoff_freq.get_value() rx_filter_gain = self.rx_filter_gain.get_value() rx_cutoff_width = self.cutoff_width.get_value() rx_sqval = self.qrx_sq.get_value() print 'rx_cutoff_freq:%s' % rx_cutoff_freq tx_loc_freq = freq - txcenter rx_loc_freq = freq - rxcenter print '@@@@@@@@@@ KEY CHANGED WAS %s' % self.key_changed if self.key_changed == 'txpwrpri': print '$$$$ RETURNING' return if self.key_changed == 'qtx_sq' and self.tx_sq is not None: self.tx_sq.set_threshold(tx_sqval / 100.0) return if self.key_changed == 'qrx_sq' and self.sqblock is not None: self.sqblock_sq.set_threshold(rx_sqval / 100.0) return if self.key_changed == 'freq': freq = self.freq.get_value() tx_loc_freq = freq - txcenter rx_loc_freq = freq - rxcenter if abs(tx_loc_freq) < txsps * 0.7 and self.tx_vol is not None: self.rxtxstatus.set_tx_status(True) self.tx_if0_mul.set_phase_inc(tx_loc_freq / txsps * math.pi * 2.0) if abs(rx_loc_freq) < txsps * 0.7 and self.rx_if0 is not None: self.rxtxstatus.set_rx_status(True) self.rx_if0_mul.set_phase_inc(rx_loc_freq / txsps * math.pi * 2.0) if self.rx_if0 is not None and self.tx_vol is not None: return if self.key_changed == 'ssb_shifter_freq' and self.tx_ssb_shifter is not None: self.tx_ssb_shifter_mul.set_phase_inc (tx_ssb_shifter_freq / 16000.0 * math.pi * 2.0) return if self.key_changed == 'cutoff_freq' or self.key_changed == 'cutoff_width': if self.tx_lpf: self.tx_lpf.set_taps(filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) if self.rx_lpf: self.rx_lpf.set_taps(filter.firdes.low_pass(int(rx_filter_gain), rxsps, rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return if self.key_changed == 'tx_filter_gain' and self.tx_lpf is not None: self.tx_lpf.set_taps(filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return if self.key_changed == 'rx_filter_gain' and self.rx_lpf is not None: self.rx_lpf.set_taps(filter.firdes.low_pass(int(rx_filter_gain), rxsps, rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) return # Turn it off to disconnect them before the variable contents # below are replaced. was_active = self.active self.off() if abs(tx_loc_freq) > txsps * 0.75: self.tx_vol = None self.rxtxstatus.set_tx_status(False) else: self.tx_vol = blocks.multiply_const_ff(tx_audio_mul) self.tx_sq = analog.standard_squelch(audio_rate=16000) self.tx_sq.set_threshold(tx_sqval / 100.0) self.tx_cnst_src = analog.sig_source_f(int(16000), analog.GR_CONST_WAVE, 0, 0, 0) self.tx_ftc = blocks.float_to_complex() self.tx_ssb_shifter_mul = blocks.rotator_cc() self.tx_ssb_shifter_mul.set_phase_inc(tx_ssb_shifter_freq / 16000.0 * math.pi * 2.0) self.tx_lpf = filter.interp_fir_filter_ccf(int(txsps / 16000), filter.firdes.low_pass(int(tx_filter_gain), txsps, tx_cutoff_freq, tx_cutoff_width, filter.firdes.WIN_BLACKMAN, 6.76)) self.tx_if0_mul = blocks.rotator_cc() self.tx_if0_mul.set_phase_inc(tx_loc_freq / txsps * math.pi * 2.0) # Late failure is okay. Better false negative than RX is OFF. self.rxtxstatus.set_tx_status(True) if abs(rx_loc_freq) > rxsps * 0.75: self.rx_if0 = None self.rxtxstatus.set_rx_status(False) else: # Early failure is okay. Better false positive that TX is ON. self.rxtxstatus.set_rx_status(True) self.rx_if0_mul = blocks.rotator_cc() self.rx_if0_mul.set_phase_inc(-rx_loc_freq / rxsps * math.pi * 2.0) self.rx_lpf = filter.fir_filter_ccf(int(rxsps / 16000), filter.firdes.low_pass(int(rx_filter_gain), int(rxsps), rx_cutoff_freq, rx_cutoff_width, filter.firdes.WIN_HAMMING, 6.76)) self.rx_cms = blocks.complex_to_mag_squared() self.rx_vol = blocks.multiply_const_ff(10.0 ** (rx_output_gain / 10.0)) self.sqblock = analog.standard_squelch(16000) self.sqblock.set_threshold(float(rx_sqval) / 100.0) self.rx_sigstr = gblocks.SignalStrengthCalculator(numpy.float32) self.chanover.set_audio_strength_query_func(self.rx_sigstr.get_value) if was_active: self.on() else: self.off()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="V/HF mult-imode transmitter") ################################################## # Variables ################################################## self.var_1 = var_1 = 145100000 self.var_text = var_text = var_1 self.tx_mode = tx_mode = 0, 0, 1 self.tx_freq = tx_freq = 1500, -1500, -1500 self.tune = tune = 0 self.side_band = side_band = 2 self.samp_rate = samp_rate = 1.515152e6 self.pwr = pwr = 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.0, 0, 0.11 self.lo_freq_Hz = lo_freq_Hz = (145.1e6, 145.11e6, 14.070e6, 14.236e6, 28.720e6, 10.0e6, 15.0e6, var_1) self.hi_lo = hi_lo = 1 self.freq_chooser = freq_chooser = 0 self.fine_tune = fine_tune = 0 self.chooser = chooser = 1 ################################################## # Blocks ################################################## _tune_sizer = wx.BoxSizer(wx.VERTICAL) self._tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, label="Coarse Tune", converter=forms.int_converter(), proportion=0, ) self._tune_slider = forms.slider( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, minimum=-61000, maximum=61000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_tune_sizer, 3, 1, 1, 1) self._side_band_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.side_band, callback=self.set_side_band, label=" Sideband", choices=[0, 1, 2], labels=["LSB", "USB", "CW"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._side_band_chooser, 3, 2, 1, 1) self._hi_lo_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.hi_lo, callback=self.set_hi_lo, label="Power Level", choices=[1, 2], labels=["Low", "High"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._hi_lo_chooser, 4, 2, 1, 1) self._freq_chooser_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq_chooser, callback=self.set_freq_chooser, label="FREQUENCY SELECT", choices=[0, 1, 2, 3, 4, 5, 6, 7], labels=["145.100", "145.110", "14.070", "14.236", "28.720", "10", "15", "PRESET"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._freq_chooser_chooser, 1, 1, 1, 1) _fine_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, label="Fine Tune", converter=forms.float_converter(), proportion=0, ) self._fine_tune_slider = forms.slider( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, minimum=-5000 / 2, maximum=5000 / 2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_tune_sizer, 4, 1, 1, 1) self._chooser_chooser = forms.button( parent=self.GetWin(), value=self.chooser, callback=self.set_chooser, label="TX-RX Selector", choices=[1, 0], labels=["Receive", "Transmit"], ) self.GridAdd(self._chooser_chooser, 6, 1, 2, 1) self._var_text_static_text = forms.static_text( parent=self.GetWin(), value=self.var_text, callback=self.set_var_text, label="PRESET FREQUENCY", converter=forms.float_converter(), ) self.GridAdd(self._var_text_static_text, 1, 2, 1, 1) self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(8, (), 100) self.pfb_interpolator_ccf_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate / 4) self.osmosdr_sink_0.set_center_freq(lo_freq_Hz[freq_chooser] + tune + fine_tune - (tx_freq[side_band]), 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.fft_filter_xxx_0_0_0_0_0 = filter.fft_filter_fff( 1, (firdes.band_pass(1, samp_rate / 32, 250, 3500, 400)), 1 ) self.fft_filter_xxx_0_0_0_0_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 32, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0_0_0 = blocks.multiply_const_vcc(((pwr[freq_chooser] * hi_lo),)) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((40 * 10,)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(chooser)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=tx_mode[side_band], output_index=0, ) self.band_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.band_pass(1, 47348, 150, 1500, 300, firdes.WIN_HAMMING, 6.76) ) self.audio_source_0_0 = audio.source(47348, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate / 32, analog.GR_COS_WAVE, tx_freq[side_band], 1, 0) self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, (0.070) * 9) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.audio_source_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_multiply_const_vxx_1_0_0_0, 0)) self.connect((self.blks2_valve_1, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.fft_filter_xxx_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0_0, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1)) self.connect((self.fft_filter_xxx_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.pfb_interpolator_ccf_0, 0), (self.osmosdr_sink_0, 0))
def graph (args): print os.getpid() nargs = len(args) if nargs == 2: infile = args[0] outfile = args[1] else: raise ValueError('usage: interp.py input_file output_file.ts\n') input_rate = 19.2e6 IF_freq = 5.75e6 tb = gr.top_block() # Read from input file srcf = blocks.file_source(gr.sizeof_short, infile) # Convert interleaved shorts (I,Q,I,Q) to complex is2c = blocks.interleaved_short_to_complex() # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE/2. NTAPS = 279 tt = filter.firdes.root_raised_cosine (1.0, input_rate / 3, symbol_rate, .1152, NTAPS) rrc = filter.fir_filter_ccf(1, tt) # Interpolate Filter our 6MHz wide signal centered at 0 ilp_coeffs = filter.firdes.low_pass(1, input_rate, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) ilp = filter.interp_fir_filter_ccf(3, ilp_coeffs) # Move the center frequency to 5.75MHz ( this wont be needed soon ) duc_coeffs = filter.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING ) duc = filter.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, -5.75e6, 19.2e6 ) # fpll input is float c2f = blocks.complex_to_float() # Phase locked loop fpll = atsc.fpll() # Clean fpll output lp_coeffs2 = filter.firdes.low_pass (1.0, input_rate, 5.75e6, 120e3, filter.firdes.WIN_HAMMING); lp_filter = filter.fir_filter_fff (1, lp_coeffs2) # Remove pilot ( at DC now ) iir = filter.single_pole_iir_filter_ff(1e-5) remove_dc = blocks.sub_ff() # Bit Timing Loop, Field Sync Checker and Equalizer btl = atsc.bit_timing_loop() fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() # Viterbi viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() # Write to output file outf = blocks.file_sink(gr.sizeof_char,outfile) # Connect it all together tb.connect( srcf, is2c, rrc, ilp, duc, c2f, fpll, lp_filter) tb.connect( lp_filter, iir ) tb.connect( lp_filter, (remove_dc, 0) ) tb.connect( iir, (remove_dc, 1) ) tb.connect( remove_dc, btl ) tb.connect( (btl, 0), (fsc, 0), (eq, 0), (fsd,0) ) tb.connect( (btl, 1), (fsc, 1), (eq, 1), (fsd,1) ) tb.connect( fsd, viterbi, deinter, rs_dec, derand, depad, outf ) tb.run()
def make_interpolator(): return filter.interp_fir_filter_ccf(interp, interp_taps)
def graph(args): print os.getpid() nargs = len(args) if nargs == 2: infile = args[0] outfile = args[1] else: raise ValueError('usage: interp.py input_file output_file.ts\n') input_rate = 19.2e6 IF_freq = 5.75e6 tb = gr.top_block() # Read from input file srcf = blocks.file_source(gr.sizeof_short, infile) # Convert interleaved shorts (I,Q,I,Q) to complex is2c = blocks.interleaved_short_to_complex() # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE / 2. NTAPS = 279 tt = filter.firdes.root_raised_cosine(1.0, input_rate / 3, symbol_rate, .1152, NTAPS) rrc = filter.fir_filter_ccf(1, tt) # Interpolate Filter our 6MHz wide signal centered at 0 ilp_coeffs = filter.firdes.low_pass(1, input_rate, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) ilp = filter.interp_fir_filter_ccf(3, ilp_coeffs) # Move the center frequency to 5.75MHz ( this won't be needed soon ) duc_coeffs = filter.firdes.low_pass(1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING) duc = filter.freq_xlating_fir_filter_ccf(1, duc_coeffs, -5.75e6, 19.2e6) # fpll input is float c2f = blocks.complex_to_float() # Phase locked loop fpll = atsc.fpll() # Clean fpll output lp_coeffs2 = filter.firdes.low_pass(1.0, input_rate, 5.75e6, 120e3, filter.firdes.WIN_HAMMING) lp_filter = filter.fir_filter_fff(1, lp_coeffs2) # Remove pilot ( at DC now ) iir = filter.single_pole_iir_filter_ff(1e-5) remove_dc = blocks.sub_ff() # Bit Timing Loop, Field Sync Checker and Equalizer btl = atsc.bit_timing_loop() fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() # Viterbi viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() # Write to output file outf = blocks.file_sink(gr.sizeof_char, outfile) # Connect it all together tb.connect(srcf, is2c, rrc, ilp, duc, c2f, fpll, lp_filter) tb.connect(lp_filter, iir) tb.connect(lp_filter, (remove_dc, 0)) tb.connect(iir, (remove_dc, 1)) tb.connect(remove_dc, btl) tb.connect((btl, 0), (fsc, 0), (eq, 0), (fsd, 0)) tb.connect((btl, 1), (fsc, 1), (eq, 1), (fsd, 1)) tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, outf) tb.run()
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, gain_mu=_def_gain_mu, mu=_def_mu, omega_relative_limit=_def_omega_relative_limit, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered CQPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of floats in [ -3 / -1 / +1 / +3 ] @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alphas: float @param gain_mu: for M&M block @type gain_mu: float @param mu: for M&M block @type mu: float @param omega_relative_limit: for M&M block @type omega_relative_limit: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "cqpsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._costas_alpha = costas_alpha self._mm_gain_mu = gain_mu self._mm_mu = mu self._mm_omega_relative_limit = omega_relative_limit self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol arity = pow(2,self.bits_per_symbol()) # Automatic gain control scale = (1.0/16384.0) self.pre_scaler = blocks.multiply_const_cc(scale) # scale the signal from full-range to +-1 #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.agc = analog.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * samples_per_symbol self.rrc_taps = filter.firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps) if not self._mm_gain_mu: sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15} self._mm_gain_mu = sbs_to_mm[samples_per_symbol] self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha fmin = -0.025 fmax = 0.025 self.receiver=digital.mpsk_receiver_cc(arity, pi/4.0, 2*pi/150, fmin, fmax, self._mm_mu, self._mm_gain_mu, self._mm_omega, self._mm_gain_omega, self._mm_omega_relative_limit) self.receiver.set_alpha(self._costas_alpha) self.receiver.set_beta(self._costas_beta) # Perform Differential decoding on the constellation self.diffdec = digital.diff_phasor_cc() # take angle of the difference (in radians) self.to_float = blocks.complex_to_arg() # convert from radians such that signal is in -3/-1/+1/+3 self.rescale = blocks.multiply_const_ff( 1 / (pi / 4) ) if verbose: self._print_verbage() if log: self._setup_logging() # Connect & Initialize base class self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, self.diffdec, self.to_float, self.rescale, self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Multi Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.audio_rate = audio_rate = 48000 self.wpm = wpm = 15 self.wbfm_on = wbfm_on = True self.usb_on = usb_on = True self.samp_rate = samp_rate = audio_rate * 40 self.q_offset = q_offset = 0 self.psk_on = psk_on = True self.phase = phase = 0 self.nbfm_on = nbfm_on = True self.magnitude = magnitude = 0 self.lsb_on = lsb_on = True self.i_offset = i_offset = 0 self.gain = gain = 25 self.cw_on = cw_on = True self.center_freq = center_freq = 441000000 self.am_on = am_on = True ################################################## # Blocks ################################################## self._wbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.wbfm_on, callback=self.set_wbfm_on, label="WBFM", true=True, false=False, ) self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1) self._usb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.usb_on, callback=self.set_usb_on, label="USB", true=True, false=False, ) self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1) _q_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._q_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, label="DC offset Q", converter=forms.float_converter(), proportion=0, ) self._q_offset_slider = forms.slider( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_q_offset_sizer, 3, 0, 1, 7) self._psk_on_check_box = forms.check_box( parent=self.GetWin(), value=self.psk_on, callback=self.set_psk_on, label="PSK31", true=True, false=False, ) self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1) _phase_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, label="Phase correction", converter=forms.float_converter(), proportion=0, ) self._phase_slider = forms.slider( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_phase_sizer, 0, 0, 1, 7) self._nbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.nbfm_on, callback=self.set_nbfm_on, label="NBFM", true=True, false=False, ) self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1) _magnitude_sizer = wx.BoxSizer(wx.VERTICAL) self._magnitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, label="Magnitude correction", converter=forms.float_converter(), proportion=0, ) self._magnitude_slider = forms.slider( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_magnitude_sizer, 1, 0, 1, 7) self._lsb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.lsb_on, callback=self.set_lsb_on, label="LSB", true=True, false=False, ) self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1) _i_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._i_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, label="DC offset I", converter=forms.float_converter(), proportion=0, ) self._i_offset_slider = forms.slider( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_i_offset_sizer, 2, 0, 1, 7) self._cw_on_check_box = forms.check_box( parent=self.GetWin(), value=self.cw_on, callback=self.set_cw_on, label="CW", true=True, false=False, ) self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1) self._am_on_check_box = forms.check_box( parent=self.GetWin(), value=self.am_on, callback=self.set_am_on, label="AM", true=True, false=False, ) self.GridAdd(self._am_on_check_box, 4, 2, 1, 1) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=192, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=samp_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 2, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 4, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.digital_map_bb_0 = digital.map_bb(([1, 0])) self.blocks_wavfile_source_0 = blocks.wavfile_source( "multi_tx.wav", True) self.blocks_vector_source_x_2 = blocks.vector_source_b( (0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c( (1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_6 = blocks.multiply_vcc(1) self.blocks_multiply_xx_5 = blocks.multiply_vcc(1) self.blocks_multiply_xx_4 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vcc( (i_offset + 1j * q_offset, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, )) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, ) self.analog_sig_source_x_6 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0) self.analog_sig_source_x_5 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0) self.analog_sig_source_x_4 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0) self.analog_sig_source_x_3_0 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0) self.analog_sig_source_x_3 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 2, tau=75e-6, max_dev=5e3, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0)) self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3)) self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0)) self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1)) self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Multi Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.audio_rate = audio_rate = 48000 self.wpm = wpm = 15 self.wbfm_on = wbfm_on = True self.usb_on = usb_on = True self.samp_rate = samp_rate = audio_rate * 40 self.q_offset = q_offset = 0 self.psk_on = psk_on = True self.phase = phase = 0 self.nbfm_on = nbfm_on = True self.magnitude = magnitude = 0 self.lsb_on = lsb_on = True self.i_offset = i_offset = 0 self.gain = gain = 25 self.cw_on = cw_on = True self.center_freq = center_freq = 441000000 self.am_on = am_on = True ################################################## # Blocks ################################################## self._wbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.wbfm_on, callback=self.set_wbfm_on, label="WBFM", true=True, false=False, ) self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1) self._usb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.usb_on, callback=self.set_usb_on, label="USB", true=True, false=False, ) self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1) _q_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._q_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, label="DC offset Q", converter=forms.float_converter(), proportion=0, ) self._q_offset_slider = forms.slider( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_q_offset_sizer, 3, 0, 1, 7) self._psk_on_check_box = forms.check_box( parent=self.GetWin(), value=self.psk_on, callback=self.set_psk_on, label="PSK31", true=True, false=False, ) self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1) _phase_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, label="Phase correction", converter=forms.float_converter(), proportion=0, ) self._phase_slider = forms.slider( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_phase_sizer, 0, 0, 1, 7) self._nbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.nbfm_on, callback=self.set_nbfm_on, label="NBFM", true=True, false=False, ) self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1) _magnitude_sizer = wx.BoxSizer(wx.VERTICAL) self._magnitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, label="Magnitude correction", converter=forms.float_converter(), proportion=0, ) self._magnitude_slider = forms.slider( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_magnitude_sizer, 1, 0, 1, 7) self._lsb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.lsb_on, callback=self.set_lsb_on, label="LSB", true=True, false=False, ) self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1) _i_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._i_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, label="DC offset I", converter=forms.float_converter(), proportion=0, ) self._i_offset_slider = forms.slider( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_i_offset_sizer, 2, 0, 1, 7) self._cw_on_check_box = forms.check_box( parent=self.GetWin(), value=self.cw_on, callback=self.set_cw_on, label="CW", true=True, false=False, ) self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1) self._am_on_check_box = forms.check_box( parent=self.GetWin(), value=self.am_on, callback=self.set_am_on, label="AM", true=True, false=False, ) self.GridAdd(self._am_on_check_box, 4, 2, 1, 1) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=192, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=samp_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 2, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 4, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.digital_map_bb_0 = digital.map_bb(([1,0])) self.blocks_wavfile_source_0 = blocks.wavfile_source("multi_tx.wav", True) self.blocks_vector_source_x_2 = blocks.vector_source_b((0,0, 1,1,0,1,1,0,1, 0,0, 1,0,1,0,1,1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1,1,0,1,0,1, 0,0, 1,1,1,0,1,1,1, 0,0, 1,1,1,1,1,1,1,1, 0,0, 1,1,1,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1, 0,0, 1,0,1, 0,0, 1,1, 0,0, 1,0,1,1,1, 0,0, 1,0,1, 0,0, 1,1,0,1, 0,0, 1,1,1,1, 0,0, 1,0,1,1,0,1,1, 0,0, 1,0,1,0,1,1,1, 0,0, 1,1,1,0,1), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c((1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_6 = blocks.multiply_vcc(1) self.blocks_multiply_xx_5 = blocks.multiply_vcc(1) self.blocks_multiply_xx_4 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vcc((i_offset + 1j * q_offset, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, )) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, ) self.analog_sig_source_x_6 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0) self.analog_sig_source_x_5 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0) self.analog_sig_source_x_4 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0) self.analog_sig_source_x_3_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0) self.analog_sig_source_x_3 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 2, tau=75e-6, max_dev=5e3, ) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0)) self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3)) self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0)) self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1)) self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))
def __init__(self, pre_bits=[0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0]): gr.top_block.__init__(self, "Psk Burst Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Psk Burst 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", "psk_burst_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.pre_bits = pre_bits ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100e3 self.ldpc_enc = ldpc_enc = fec.ldpc_encoder_make('/home/abraxas3d/goodies/share/gnuradio/fec/ldpc/271.127.3.112'); ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.interp_fir_filter_ccf(2, firdes.root_raised_cosine( 1, 2.0, 1, 0.35, 41)) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 8192, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,0) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 8192, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1,1) self.pyqt_meta_text_output_0 = pyqt.meta_text_output() self._pyqt_meta_text_output_0_win = self.pyqt_meta_text_output_0; self.top_layout.addWidget(self._pyqt_meta_text_output_0_win) self.pyqt_ctime_plot_0 = pyqt.ctime_plot('') self._pyqt_ctime_plot_0_win = self.pyqt_ctime_plot_0; self.top_grid_layout.addWidget(self._pyqt_ctime_plot_0_win, 1,0) self.mapper_mapper_msg_0 = mapper.mapper_msg(mapper.QPSK, ([0,1,3,2])) self.fec_async_encoder_0 = fec.async_encoder(ldpc_enc, False, True, True, 1500) self.es_source_0 = es.source(1*[gr.sizeof_gr_complex], 1, 2) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.05, frequency_offset=random.random()*1e-4, epsilon=1.0+random.random()*1e-4, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.burst_scheduler_0 = burst.burst_scheduler() self.burst_randomizer_0 = burst.randomizer(([0,14,15]), ([1,0,0,1,0,1,0,1,0,0,0,0,0,0,0]), 100000) self.burst_preamble_insert_0 = burst.preamble_insert((pre_bits)) self.burst_padder_0 = burst.padder(144) self.burst_framer_0 = burst.framer(144) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_random_pdu_0 = blocks.random_pdu(50, 256/2, chr(0xFF), 2) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/tmp/psk_ldpc_xmit.dat', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.burst_framer_0, 'packed_pdus')) self.msg_connect((self.burst_framer_0, 'unpacked_pdus'), (self.burst_padder_0, 'pdus')) self.msg_connect((self.burst_padder_0, 'pdus'), (self.burst_randomizer_0, 'pdus')) self.msg_connect((self.burst_preamble_insert_0, 'pdus'), (self.mapper_mapper_msg_0, 'pdus')) self.msg_connect((self.burst_randomizer_0, 'pdus'), (self.fec_async_encoder_0, 'in')) self.msg_connect((self.burst_scheduler_0, 'sched_pdu'), (self.es_source_0, 'schedule_event')) self.msg_connect((self.burst_scheduler_0, 'sched_pdu'), (self.pyqt_meta_text_output_0, 'pdus')) self.msg_connect((self.es_source_0, 'nproduced'), (self.burst_scheduler_0, 'nproduced')) self.msg_connect((self.fec_async_encoder_0, 'out'), (self.burst_preamble_insert_0, 'pdus')) self.msg_connect((self.mapper_mapper_msg_0, 'cpdus'), (self.burst_scheduler_0, 'sched_pdu')) self.msg_connect((self.mapper_mapper_msg_0, 'cpdus'), (self.pyqt_ctime_plot_0, 'cpdus')) self.connect((self.blocks_throttle_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.es_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.channels_channel_model_0_0, 0))
def __init__(self, rxPort=52002, txPort=52001): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.rxPort = rxPort self.txPort = txPort ################################################## # Variables ################################################## self.localOscillator = localOscillator = 14070000 self.threshold = threshold = -200 self.samp_rate = samp_rate = 48000 self.rxPhase = rxPhase = .84 self.rxMagnitude = rxMagnitude = 0.854 self.freqFine = freqFine = 0 self.freq = freq = localOscillator self.bandwidth = bandwidth = 50 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope") self.Add(self.notebook_0) _freqFine_sizer = wx.BoxSizer(wx.VERTICAL) self._freqFine_text_box = forms.text_box( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._freqFine_slider = forms.slider( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freqFine_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=localOscillator-samp_rate, maximum=localOscillator+samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, label="Signal Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, minimum=30, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bandwidth_sizer) self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=localOscillator, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76)) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001) self.blocks_transcendental_1 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25) self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25)) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=txPort, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=rxPort, server=False, ) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Rx Simulation") ################################################## # Variables ################################################## self.bw = bw = 250000 self.sync_words = sync_words = [8, 16] self.sf = sf = 7 self.samp_rate = samp_rate = bw self.pay_len = pay_len = 255 self.impl_head = impl_head = True self.has_crc = has_crc = True self.frame_period = frame_period = 10 self.cr = cr = 0 ################################################## # Blocks ################################################## self.lora_sdr_whitening_0 = lora_sdr.whitening() self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw, [8, 16]) self.lora_sdr_modulate_0.set_min_output_buffer(10000000) self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf) self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder( impl_head, cr, pay_len, has_crc) self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr) self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf) self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec() self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc() self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf) self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync( samp_rate, bw, sf, impl_head, [8, 16]) self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf, impl_head) self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening() self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf) self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif() self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccf( 4, (-0.128616616593872, -0.212206590789194, -0.180063263231421, 3.89817183251938e-17, 0.300105438719035, 0.636619772367581, 0.900316316157106, 1, 0.900316316157106, 0.636619772367581, 0.300105438719035, 3.89817183251938e-17, -0.180063263231421, -0.212206590789194, -0.128616616593872)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0.set_min_output_buffer(20000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=[1.0 + 0.0j], noise_seed=0, block_tags=True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 10, True) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern( "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches" ), frame_period) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.lora_sdr_whitening_0, 'msg')) self.msg_connect((self.lora_sdr_header_decoder_0, 'frame_info'), (self.lora_sdr_frame_sync_0, 'frame_info')) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.lora_sdr_frame_sync_0, 0)) self.connect((self.lora_sdr_add_crc_0, 0), (self.lora_sdr_hamming_enc_0, 0)) self.connect((self.lora_sdr_deinterleaver_0, 0), (self.lora_sdr_hamming_dec_0, 0)) self.connect((self.lora_sdr_dewhitening_0, 0), (self.lora_sdr_crc_verif_0, 0)) self.connect((self.lora_sdr_fft_demod_0, 0), (self.lora_sdr_gray_enc_0, 0)) self.connect((self.lora_sdr_frame_sync_0, 0), (self.lora_sdr_fft_demod_0, 0)) self.connect((self.lora_sdr_gray_decode_0, 0), (self.lora_sdr_modulate_0, 0)) self.connect((self.lora_sdr_gray_enc_0, 0), (self.lora_sdr_deinterleaver_0, 0)) self.connect((self.lora_sdr_hamming_dec_0, 0), (self.lora_sdr_header_decoder_0, 0)) self.connect((self.lora_sdr_hamming_enc_0, 0), (self.lora_sdr_interleaver_0, 0)) self.connect((self.lora_sdr_header_0, 0), (self.lora_sdr_add_crc_0, 0)) self.connect((self.lora_sdr_header_decoder_0, 0), (self.lora_sdr_dewhitening_0, 0)) self.connect((self.lora_sdr_interleaver_0, 0), (self.lora_sdr_gray_decode_0, 0)) self.connect((self.lora_sdr_modulate_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.lora_sdr_whitening_0, 0), (self.lora_sdr_header_0, 0))
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered QPSK modulation. The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: integer @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "cqpsk_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) ntaps = 11 * samples_per_symbol arity = 8 # turn bytes into k-bit vectors self.bytes2chunks = \ blocks.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) # 0 +45 1 [+1] # 1 +135 3 [+3] # 2 -45 7 [-1] # 3 -135 5 [-3] self.pi4map = [1, 3, 7, 5] self.symbol_mapper = digital.map_bb(self.pi4map) self.diffenc = digital.diff_encoder_bb(arity) self.chunks2symbols = digital.chunks_to_symbols_bc(psk.constellation[arity]) # pulse shaping filter self.rrc_taps = filter.firdes.root_raised_cosine( self._samples_per_symbol, # gain (sps since we're interpolating by sps) self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) if verbose: self._print_verbage() if log: self._setup_logging() # Connect & Initialize base class self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, self.chunks2symbols, self.rrc_filter, self)
def __init__(self): gr.top_block.__init__(self, "Usrp Experiment2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Usrp Experiment2 Tx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "usrp_experiment2_tx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.time_preamble = time_preamble = [0.125000+0.000000j, 0.522104-0.148216j, -0.495528+0.114832j, -0.267916+0.091700j, 0.236544-0.138456j, -0.098500+0.473800j, 0.476480-0.225344j, -0.187516+0.035372j, 0.051776-0.353552j, -0.104936+0.059916j, 0.228684+0.117504j, -0.530912+0.560756j, 0.359128+0.015872j, -0.132852+0.632840j, -0.105164-0.368872j, 0.368272-0.032412j, 0.125000+0.750000j, 0.463968+0.457792j, 0.151476-0.430948j, 0.685052+0.238524j, 0.494428+0.119428j, -0.557540-0.050056j, 0.416348+0.017368j, 0.104256-0.568836j, -0.301776-0.353552j, 0.079812+0.451516j, 0.439152+0.528072j, 0.642060+0.178484j, -0.090096+0.465096j, -0.446492+0.305776j, -0.111440-0.093688j, -0.538848-0.320228j, 0.125000+0.000000j, -0.538848+0.320228j, -0.111440+0.093688j, -0.446492-0.305776j, -0.090096-0.465096j, 0.642060-0.178484j, 0.439152-0.528072j, 0.079812-0.451516j, -0.301776+0.353552j, 0.104256+0.568836j, 0.416348-0.017368j, -0.557540+0.050056j, 0.494428-0.119428j, 0.685052-0.238524j, 0.151476+0.430948j, 0.463968-0.457792j, 0.125000-0.750000j, 0.368272+0.032412j, -0.105164+0.368872j, -0.132852-0.632840j, 0.359128-0.015872j, -0.530912-0.560756j, 0.228684-0.117504j, -0.104936-0.059916j, 0.051776+0.353552j, -0.187516-0.035372j, 0.476480+0.225344j, -0.098500-0.473800j, 0.236544+0.138456j, -0.267916-0.091700j, -0.495528-0.114832j, 0.522104+0.148216j] self.samp_rate = samp_rate = 3.125e6 self.preamble_len = preamble_len = 64 self.padding = padding = 12 self.packet_len = packet_len = 1024 self.length = length = 96 self.gain = gain = 15 self.freq = freq = 2.441e9 ################################################## # Blocks ################################################## self.timesvl_TimeSVL_1 = timesvl.TimeSVL(gr.sizeof_gr_complex*1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_1.txt') self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Preamble and transmitted signal", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #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_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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.mysvl_stream_demux_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,1022,1), False) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(2, firdes.low_pass( 1, samp_rate, samp_rate/4-samp_rate/32, samp_rate/32, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, samp_rate/2-samp_rate/32, samp_rate/32, firdes.WIN_HAMMING, 6.76)) self._gain_range = Range(0, 40, 1, 15, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win, 0, 2, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(2,3)] self._freq_range = Range(2.4e9, 2.5e9, 1e6, 2.441e9, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)] [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)] self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_c(time_preamble, True, 1, []) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, 1022,padding+1)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, 1048)) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((2.0/4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_1 = blocks.file_source(gr.sizeof_char*1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blks2_packet_encoder_1_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_1_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_1, 0), (self.blks2_packet_encoder_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_stream_mux_1, 2)) self.connect((self.blocks_stream_mux_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.timesvl_TimeSVL_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.timesvl_TimeSVL_1, 1)) self.connect((self.mysvl_stream_demux_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.mysvl_stream_demux_0, 2), (self.blocks_repeat_0_0, 0)) self.connect((self.mysvl_stream_demux_0, 1), (self.blocks_stream_mux_1, 1)) self.connect((self.timesvl_TimeSVL_1, 0), (self.mysvl_stream_demux_0, 0))