def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__(self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate / self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = gr.probe_density_b(1.0/self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__( self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate * self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = gr.probe_mpsk_snr_c(10.0 / self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = gr.probe_density_b(1.0 / self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def test_scrambler_descrambler(self): src_data = (1,)*1000 src = gr.vector_source_b(src_data, False) scrambler = gr.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler descrambler = gr.descrambler_bb(0x8a, 0x7F, 7) dst = gr.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.run() self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000 ################################################## # Blocks ################################################## self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.gr_descrambler_bb_0 = gr.descrambler_bb(0x8A, 0x7F, 7) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_throttle_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate) self.gr_throttle_0_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate*8) self.gr_throttle_0_0_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate*8*8) self.gr_uchar_to_float_0 = gr.uchar_to_float() self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.gr_vector_source_x_0 = gr.vector_source_b((0, 1, 3,7,255,3,1,0), True, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate*32, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, ) self.Add(self.wxgui_scopesink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_throttle_0, 0)) self.connect((self.const_source_x_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0_0, 0)) self.connect((self.gr_throttle_0_0, 0), (self.gr_packed_to_unpacked_xx_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.gr_throttle_0_0_0, 0)) self.connect((self.gr_throttle_0_0_0, 0), (self.gr_scrambler_bb_0, 0)) self.connect((self.gr_scrambler_bb_0, 0), (self.gr_throttle_0_0_0_0, 0)) self.connect((self.gr_throttle_0_0_0_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_uchar_to_float_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_uchar_to_float_0, 0))
def __init__(self, if_rate, # Incoming sample rate symbol_rate, # Original symbol rate excess_bw, # RRC excess bandwidth, typically 0.35-0.5 costas_alpha, # Costas loop 1st order gain, typically 0.01-0.2 costas_beta, # Costas loop 2nd order gain, typically alpha^2/4.0 costas_max, # Costas loop max frequency offset in radians/sample mm_gain_mu, # M&M loop 1st order gain, typically 0.001-0.2 mm_gain_omega, # M&M loop 2nd order gain, typically alpha^2/4.0 mm_omega_limit, # M&M loop max timing error ): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature grc_wxgui.top_block_gui.__init__(self, title="Top Block") self._if_rate = if_rate self._sps = int(self._if_rate/symbol_rate) print "IF sample rate:", n2s(self._if_rate) print "Symbol rate:", n2s(symbol_rate) print "Samples/symbol:", self._sps print "RRC bandwidth:", excess_bw # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth taps = gr.firdes.root_raised_cosine(1.0, # Gain self._sps, # Sampling rate 1.0, # Symbol rate excess_bw, # Roll-off factor 11*self._sps) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) # Create a Costas loop frequency/phase recovery block print "Costas alpha:", costas_alpha print "Costas beta:", costas_beta print "Costas max:", costas_max self._costas = gr.costas_loop_cc(costas_alpha, # PLL first order gain costas_beta, # PLL second order gain costas_max, # Max frequency offset rad/sample -costas_max, # Min frequency offset rad/sample 2) # BPSK # Create a M&M bit synchronization retiming block mm_mu = 0.5 mm_omega = self._sps print "MM gain mu:", mm_gain_mu print "MM gain omega:", mm_gain_omega print "MM omega limit:", mm_omega_limit self._mm = gr.clock_recovery_mm_cc(mm_omega, # Initial samples/symbol mm_gain_omega, # Second order gain mm_mu, # Initial symbol phase mm_gain_mu, # First order gain mm_omega_limit) # Maximum timing offset # Add an SNR probe on the demodulated constellation self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) # #Null for recuperate the out of snr # self.gr_null_sink_0 = gr.null_sink(gr.sizeof_double) # # self.connect(self._snr_probe, (self.gr_null_sink_0,0)) self.connect(self._mm, self._snr_probe) # Slice the resulting constellation into bits. # Get inphase channel and make decision about 0 self._c2r = gr.complex_to_real() self._slicer = gr.binary_slicer_fb() # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = gr.probe_density_b(1.0/symbol_rate) # #Null for recuperate the out of ber # self.gr_null_sink_1 = gr.null_sink(gr.sizeof_double) # # self.connect(self._ber, self.gr_null_sink_1) self.create_number_sink(self._sps) self.connect((self._snr_probe, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self._ber, 0), (self.wxgui_numbersink2_1, 0)) self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, self._ber)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Communication System Graphical Analyzer (LAPS/UFCG)") ################################################## # Default Variables ################################################## self.sps = 2 self.snr = 20 self.symbol_rate = 140000 self.mod_type = "DBPSK" self.view = 1 self.band= 200 self.excess_bw=0.35 self.fading_flag = False self.fdts = -8 self.fading_state_rx = False ################################################## # Blocks Definition ################################################## #A bit stream of 1's is generated at the source, scrambled, #modulated and sent to the input of an AWGN channel. #random.seed(42) #self.source = gr.vector_source_b([random.randint(0, 2) for i in range(0,10^8)], True) self.source = gr.vector_source_b((1,), True, 1) self.thottle = gr.throttle(gr.sizeof_char,10e5) self.scrambler = gr.scrambler_bb(0x40801, 0x92F72, 20) #Taxa de simbolos constante self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.modulator = utils.mods[self.mod_type](self.sps,excess_bw=self.excess_bw) self.channel = utils.channel(1/10.0**(self.snr/10.0),self.band,self.symbol_rate,self.sps) #The noisy signal is demodulated, descrambled and the BER #is estimated by the ber_estim block using the receiver #density of 0 bits. self.demodulator = utils.demods[self.mod_type](self.sps,excess_bw=self.excess_bw) self.descrambler = gr.descrambler_bb(0x40801, 0x92F72, 20) self.char2float = gr.char_to_float() self.mov_average = gr.moving_average_ff(524288, 1/524288., 10000) self.ber = utils.ber_estim() #self.ber = utils.ber_estim_simple(3) ################################################## # GUI Elements Definition ################################################## #Defines an adds FFT Window to GUI self.fft = fftsink.fft_sink_c(self.GetWin(), sample_rate=self.symbol_rate*self.sps, baseband_freq=5e6) self.GridAdd(self.fft.win, 0,3,4,3) self.ctr= gr.complex_to_real(1) #Defines and adds SNR slider to GUI _snr_sizer = wx.BoxSizer(wx.HORIZONTAL) self._snr_text_box = forms.text_box(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, label=" SNR (dB)", converter=forms.float_converter(), proportion=0) self._snr_slider = forms.slider(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, minimum=0, maximum=20, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(_snr_sizer, 4, 3, 1, 3) #Defines and adds bandwidth slider to GUI band_sizer = wx.BoxSizer(wx.HORIZONTAL) self.band_text_box = forms.text_box(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, label="Bandwidth (kHz)", converter=forms.float_converter(), proportion=0) self.band_slider = forms.slider(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, minimum=30, maximum=200, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(band_sizer, 5, 3, 1, 3) #Defines and adds Rayleigh GUI elements fading_sizer = wx.BoxSizer(wx.HORIZONTAL) self.fading_text_box = forms.text_box(parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, label='Fading/log(FdTs)', converter=forms.float_converter(), proportion=0) self.fading_slider = forms.slider(parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, minimum=-8, maximum=-2, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(fading_sizer, 6, 3, 1, 3) #Defines and adds modulation type chooser to GUI self._mod_type_chooser = forms.radio_buttons(parent=self.GetWin(), value=self.mod_type, callback=self.set_mod_type, label="Modulation", choices=["DBPSK", "DQPSK", "D8PSK"], labels=["DBPSK", "DQPSK", "D8PSK"], style=wx.RA_HORIZONTAL) self.GridAdd(self._mod_type_chooser, 7, 4, 1, 2) #Defines and adds signal source chooser self.sig_src_chooser = forms.radio_buttons(parent=self.GetWin(), value=self.view, callback=self.callback_view, label="Signal Source", choices=[0,1], labels=["Transmitter","Receiver"], style=wx.RA_VERTICAL) self.GridAdd(self.sig_src_chooser, 7,3,1,1) #Definition of the of constellation window and attachment to the GUI self.constel = constsink.const_sink_c(self.GetWin(), title="RX Constellation Plot", sample_rate=self.symbol_rate, const_size=256, mod=self.mod_type) self.GridAdd(self.constel.win,0,0,8,3) #Definition of the constellation sink window and attachment to the GUI self.number_sink = bersink.number_sink_f(self.GetWin(), sample_rate=self.symbol_rate) self.GridAdd(self.number_sink.win,8,0,1,6) ################################################## # Blocks Connections ################################################## #The necessary block connections to the system work as described above. self.connect(self.source, self.scrambler , self.thottle, self.pack) #self.connect(self.source , self.thottle, self.pack) self.connect(self.pack, self.modulator, self.channel, self.demodulator) self.connect(self.channel, self.fft) self.connect(self.demodulator.diffdec, self.constel) self.connect(self.demodulator, self.descrambler, self.char2float, self.mov_average) self.connect(self.mov_average, self.ber, self.number_sink)
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam']( constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt((10**(-snr_db / 10.)) / 2.) self.constellation_power = constellation_power = sqrt( sum([abs(i)**2 for i in constellation]) / constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30, 0, 10, 100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0, 0, 10, 10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1, 0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb( int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc( (1. / constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc( (constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex * 1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex * 1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb( 0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( const_object.base(), 6.28 / 100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
def __init__(self, if_rate, # Incoming sample rate symbol_rate, # Original symbol rate excess_bw, # RRC excess bandwidth, typically 0.35-0.5 costas_alpha, # Costas loop 1st order gain, typically 0.01-0.2 costas_beta, # Costas loop 2nd order gain, typically alpha^2/4.0 costas_max, # Costas loop max frequency offset in radians/sample mm_gain_mu, # M&M loop 1st order gain, typically 0.001-0.2 mm_gain_omega, # M&M loop 2nd order gain, typically alpha^2/4.0 mm_omega_limit, # M&M loop max timing error ): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._if_rate = if_rate self._sps = int(self._if_rate/symbol_rate) print "IF sample rate:", n2s(self._if_rate) print "Symbol rate:", n2s(symbol_rate) print "Samples/symbol:", self._sps print "RRC bandwidth:", excess_bw # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth taps = gr.firdes.root_raised_cosine(1.0, # Gain self._sps, # Sampling rate 1.0, # Symbol rate excess_bw, # Roll-off factor 11*self._sps) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) # Create a Costas loop frequency/phase recovery block print "Costas alpha:", costas_alpha print "Costas beta:", costas_beta print "Costas max:", costas_max self._costas = gr.costas_loop_cc(costas_alpha, # PLL first order gain costas_beta, # PLL second order gain costas_max, # Max frequency offset rad/sample -costas_max, # Min frequency offset rad/sample 2) # BPSK # Create a M&M bit synchronization retiming block mm_mu = 0.5 mm_omega = self._sps print "MM gain mu:", mm_gain_mu print "MM gain omega:", mm_gain_omega print "MM omega limit:", mm_omega_limit self._mm = gr.clock_recovery_mm_cc(mm_omega, # Initial samples/symbol mm_gain_omega, # Second order gain mm_mu, # Initial symbol phase mm_gain_mu, # First order gain mm_omega_limit) # Maximum timing offset # Add an SNR probe on the demodulated constellation self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self.connect(self._mm, self._snr_probe) # Slice the resulting constellation into bits. # Get inphase channel and make decision about 0 self._c2r = gr.complex_to_real() self._slicer = gr.binary_slicer_fb() # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = gr.probe_density_b(1.0/symbol_rate) self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, self._ber)
def __init__(self, options): gr.hier_block2.__init__(self, "bpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature grc_wxgui.top_block_gui.__init__(self, title="Top Block") self._samples_per_symbol = options.samples_per_symbol # Number of bits per symbol self._bits_per_symbol = 1 # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth taps = gr.firdes.root_raised_cosine(1.0, # Gain self._samples_per_symbol, # Sampling rate 1.0, # Symbol rate 0.35, # Roll-off factor 11*self._samples_per_symbol) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) # Create a Costas loop frequency/phase recovery block self._costas = digital.costas_loop_cc(6.28/100.0, 2) self.gr_null_sink_f1 = gr.null_sink(gr.sizeof_float*1) # Create a M&M bit synchronization retiming block 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 # Add an SNR probe on the demodulated constellation #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self._symbol_rate = options.data_rate / self._bits_per_symbol #self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate) #self._snr_probe = digital.mpsk_snr_est_cc(digital.SNR_EST_SIMPLE, alpha=10.0/self._symbol_rate) # Slice the resulting constellation into bits. # Get inphase channel and make decision about 0 self._c2r = gr.complex_to_real() self._slicer = digital.binary_slicer_fb() # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream # self._ber = gr.probe_density_b(1.0/symbol_rate) self._ber = grc_blks2.error_rate(type='BER', win_size=1000, bits_per_symbol=1) #self.create_number_sink(self._samples_per_symbol) self.gr_null_sink_f2 = gr.null_sink(gr.sizeof_float*1) #Create a vector source reference to calculate BER self._vector_source_ref = gr.vector_source_b(([1,]), True, 1) #create a comparator self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0,0, 1, 1, 0,0), 5, 0, True) #Connection of blocks #"""""""""""""""""""""""""""""""""-->_snr_probe-->gr_null_sink_cc # agc --> _rrc --> costas --> _mm --> _c2r --> _slicer --> _descrambler --> _ber --> gr_null_sink_f2 #"""""""""""""""""""""""""--> gr_null_sink_f1 "" _vector_source_ref--> # # self.connect(self, self._agc, self._rrc, self._costas, self._mm, # self._c2r, self._slicer, self._descrambler, self.comparator, (self._ber, 1)) # self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, (self._ber, 1)) self.connect((self._costas, 1), (self.gr_null_sink_f1, 0)) self.connect(self._mm, self._snr_probe) self.connect(self._vector_source_ref, (self._ber,0)) self.connect(self._ber, self.gr_null_sink_f2)
def descrambler(N): op = gr.descrambler_bb(0x8a, 0x7F, 7) tb = helper(N/1, op, gr.sizeof_char, gr.sizeof_char, 1, 1) return tb
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Communication System Graphical Analyzer (LAPS/UFCG)") ################################################## # Default Variables ################################################## self.sps = 2 self.snr = 20 self.symbol_rate = 140000 self.mod_type = "DBPSK" self.view = 1 self.band = 200 self.excess_bw = 0.35 self.fading_flag = False self.fdts = -8 self.fading_state_rx = False ################################################## # Blocks Definition ################################################## #A bit stream of 1's is generated at the source, scrambled, #modulated and sent to the input of an AWGN channel. #random.seed(42) #self.source = gr.vector_source_b([random.randint(0, 2) for i in range(0,10^8)], True) self.source = gr.vector_source_b((1, ), True, 1) self.thottle = gr.throttle(gr.sizeof_char, 10e5) self.scrambler = gr.scrambler_bb(0x40801, 0x92F72, 20) #Taxa de simbolos constante self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.modulator = utils.mods[self.mod_type](self.sps, excess_bw=self.excess_bw) self.channel = utils.channel(1 / 10.0**(self.snr / 10.0), self.band, self.symbol_rate, self.sps) #The noisy signal is demodulated, descrambled and the BER #is estimated by the ber_estim block using the receiver #density of 0 bits. self.demodulator = utils.demods[self.mod_type]( self.sps, excess_bw=self.excess_bw) self.descrambler = gr.descrambler_bb(0x40801, 0x92F72, 20) self.char2float = gr.char_to_float() self.mov_average = gr.moving_average_ff(524288, 1 / 524288., 10000) self.ber = utils.ber_estim() #self.ber = utils.ber_estim_simple(3) ################################################## # GUI Elements Definition ################################################## #Defines an adds FFT Window to GUI self.fft = fftsink.fft_sink_c(self.GetWin(), sample_rate=self.symbol_rate * self.sps, baseband_freq=5e6) self.GridAdd(self.fft.win, 0, 3, 4, 3) self.ctr = gr.complex_to_real(1) #Defines and adds SNR slider to GUI _snr_sizer = wx.BoxSizer(wx.HORIZONTAL) self._snr_text_box = forms.text_box(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, label=" SNR (dB)", converter=forms.float_converter(), proportion=0) self._snr_slider = forms.slider(parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.callback_snr, minimum=0, maximum=20, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(_snr_sizer, 4, 3, 1, 3) #Defines and adds bandwidth slider to GUI band_sizer = wx.BoxSizer(wx.HORIZONTAL) self.band_text_box = forms.text_box(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, label="Bandwidth (kHz)", converter=forms.float_converter(), proportion=0) self.band_slider = forms.slider(parent=self.GetWin(), sizer=band_sizer, value=self.band, callback=self.callback_band, minimum=30, maximum=200, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(band_sizer, 5, 3, 1, 3) #Defines and adds Rayleigh GUI elements fading_sizer = wx.BoxSizer(wx.HORIZONTAL) self.fading_text_box = forms.text_box( parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, label='Fading/log(FdTs)', converter=forms.float_converter(), proportion=0) self.fading_slider = forms.slider(parent=self.GetWin(), sizer=fading_sizer, value=self.fdts, callback=self.callback_fading, minimum=-8, maximum=-2, style=wx.RA_HORIZONTAL, proportion=1) self.GridAdd(fading_sizer, 6, 3, 1, 3) #Defines and adds modulation type chooser to GUI self._mod_type_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.mod_type, callback=self.set_mod_type, label="Modulation", choices=["DBPSK", "DQPSK", "D8PSK"], labels=["DBPSK", "DQPSK", "D8PSK"], style=wx.RA_HORIZONTAL) self.GridAdd(self._mod_type_chooser, 7, 4, 1, 2) #Defines and adds signal source chooser self.sig_src_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.view, callback=self.callback_view, label="Signal Source", choices=[0, 1], labels=["Transmitter", "Receiver"], style=wx.RA_VERTICAL) self.GridAdd(self.sig_src_chooser, 7, 3, 1, 1) #Definition of the of constellation window and attachment to the GUI self.constel = constsink.const_sink_c(self.GetWin(), title="RX Constellation Plot", sample_rate=self.symbol_rate, const_size=256, mod=self.mod_type) self.GridAdd(self.constel.win, 0, 0, 8, 3) #Definition of the constellation sink window and attachment to the GUI self.number_sink = bersink.number_sink_f(self.GetWin(), sample_rate=self.symbol_rate) self.GridAdd(self.number_sink.win, 8, 0, 1, 6) ################################################## # Blocks Connections ################################################## #The necessary block connections to the system work as described above. self.connect(self.source, self.scrambler, self.thottle, self.pack) #self.connect(self.source , self.thottle, self.pack) self.connect(self.pack, self.modulator, self.channel, self.demodulator) self.connect(self.channel, self.fft) self.connect(self.demodulator.diffdec, self.constel) self.connect(self.demodulator, self.descrambler, self.char2float, self.mov_average) self.connect(self.mov_average, self.ber, self.number_sink)
def __init__(self): gr.top_block.__init__(self, "Simple QAM Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Simple QAM Simulation") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) ################################################## # Variables ################################################## self.constellation_cardinality = constellation_cardinality = 16 self.const_object = const_object = constellations()['qam'](constellation_cardinality) self.snr_db = snr_db = 20 self.constellation = constellation = const_object.points() self.sps = sps = 8 self.samp_rate = samp_rate = 250000 self.noise_amp = noise_amp = sqrt( (10**(-snr_db/10.)) /2. ) self.constellation_power = constellation_power = sqrt(sum([abs(i)**2 for i in constellation])/constellation_cardinality) ################################################## # Blocks ################################################## self.tabid_0 = Qt.QTabWidget() self.tabid_0_widget_0 = Qt.QWidget() self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0) self.tabid_0_grid_layout_0 = Qt.QGridLayout() self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0) self.tabid_0.addTab(self.tabid_0_widget_0, "TX") self.tabid_0_widget_1 = Qt.QWidget() self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1) self.tabid_0_grid_layout_1 = Qt.QGridLayout() self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1) self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL") self.tabid_0_widget_2 = Qt.QWidget() self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2) self.tabid_0_grid_layout_2 = Qt.QGridLayout() self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2) self.tabid_0.addTab(self.tabid_0_widget_2, "RX") self.top_grid_layout.addWidget(self.tabid_0, 30,0,10,100) self.tabid_2 = Qt.QTabWidget() self.tabid_2_widget_0 = Qt.QWidget() self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0) self.tabid_2_grid_layout_0 = Qt.QGridLayout() self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0) self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based") self.tabid_2_widget_1 = Qt.QWidget() self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1) self.tabid_2_grid_layout_1 = Qt.QGridLayout() self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1) self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based") self.tabid_2_widget_2 = Qt.QWidget() self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2) self.tabid_2_grid_layout_2 = Qt.QGridLayout() self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2) self.tabid_2.addTab(self.tabid_2_widget_2, "BER") self.tabid_0_layout_2.addWidget(self.tabid_2) self.tabid_1 = Qt.QTabWidget() self.tabid_1_widget_0 = Qt.QWidget() self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0) self.tabid_1_grid_layout_0 = Qt.QGridLayout() self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0) self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based") self.tabid_1_widget_1 = Qt.QWidget() self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1) self.tabid_1_grid_layout_1 = Qt.QGridLayout() self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1) self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled") self.tabid_1_widget_2 = Qt.QWidget() self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2) self.tabid_1_grid_layout_2 = Qt.QGridLayout() self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2) self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based") self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0,0,10,10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win) self.qtgui_sink_x_0_1_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win) self.qtgui_sink_x_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name False, #plotfreq False, #plotwaterfall True, #plottime True, #plotconst ) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq False, #plotwaterfall True, #plottime False, #plotconst ) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win) self.gr_vector_source_x_0_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_vector_source_x_0 = gr.vector_source_b(([1,0]), True, 1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(int(log2(constellation_cardinality))) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0) self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc((1./constellation_power, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((constellation_power, )) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex*1, "rx_sym.32fc") self.gr_file_sink_0_1_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex*1, "tx_sym.32fc") self.gr_file_sink_0_1.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "rx.8b") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "tx.8b") self.gr_file_sink_0.set_unbuffered(False) self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19) self.gr_char_to_float_1_0 = gr.char_to_float(1, 1) self.gr_char_to_float_1 = gr.char_to_float(1, 1) self.gr_char_to_float_0 = gr.char_to_float(1, 1) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_scrambler_bb_0 = digital.scrambler_bb(0xe4001, 0x7fffF, 19) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(const_object.base(), 6.28/100, -0.25, +0.25) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation), 1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=samp_rate, bits_per_symbol=1, ) ################################################## # Connections ################################################## self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0)) self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0)) self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0)) self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))