def __init__(self, options): """ Hierarchical block for DQPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ gr.hier_block2.__init__(self, "dqpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(0, 0, 0)) # Output self.sps = options.samples_per_symbol self.dqpsk_demod = digital.psk_demod( constellation_points=4, differential=True, samples_per_symbol=self.sps, excess_bw=0.35, phase_bw=(6.28)/100.0, timing_bw=(6.28)/100.0, gray_coded="gray", verbose=False, log=False, ) self.gr_null_sink_f = gr.null_sink(gr.sizeof_float*1) 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) self._ber = grc_blks2.error_rate(type='SER', win_size=1000, bits_per_symbol=1) self.connect(self, self.dqpsk_demod, self.comparator, (self._ber,0)) self.connect(self._vector_source_ref, (self._ber,1)) self.connect(self._ber, self.gr_null_sink_f)
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 __init__(self, options): """ Hierarchical block for O-QPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ try: #self.sps = kwargs.pop('sps') self.sps = 2 except KeyError: pass gr.hier_block2.__init__(self, "oqpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(0, 0, 0)) # Output # Demodulate FM sensitivity = (pi / 2) / self.sps #self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) self.fmdemod = gr.quadrature_demod_cf(1) # Low pass the output of fmdemod to allow us to remove # the DC offset resulting from frequency offset alpha = 0.0008/self.sps self.freq_offset = gr.single_pole_iir_filter_ff(alpha) self.sub = gr.sub_ff() # recover the clock omega = self.sps gain_mu=0.03 mu=0.5 omega_relative_limit=0.0002 freq_error=0.0 gain_omega = .25*gain_mu*gain_mu # critically damped # Descramble BERT sequence. A channel error will create 3 incorrect bits #self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler self.clock_recovery_f = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.gr_float_to_complex = gr.float_to_complex(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) self._ber = grc_blks2.error_rate(type='BER', win_size=1000, bits_per_symbol=1) self._slicer = digital.binary_slicer_fb() self.gr_null_sink_f = gr.null_sink(gr.sizeof_float*1) # Add an SNR probe on the demodulated constellation #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple self.gr_null_sink_cc = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_null_source = gr.null_source(gr.sizeof_float*1) ############################### ###-------> -->gr_float_to_complex--->_snr_probe --> gr_null_sink_cc ###---->fmdemod -->freq_offset--->sub-->clock_recovery --> _slicer -->_descrambler --> comparator -->_ber--> self.gr_null_sink_f ###'''''''''''''|-->----------------|-->' _vector_source_ref--> ############################# # Connect self.connect(self, self.fmdemod) self.connect(self.fmdemod, (self.sub, 0)) self.connect(self.fmdemod, self.freq_offset, (self.sub, 1)) #self.connect(self.sub, self.clock_recovery_f, self._slicer, self._descrambler, self.comparator, (self._ber, 0)) self.connect(self.sub, self.clock_recovery_f, self._slicer, self.comparator, (self._ber, 0)) # self.connect(self.clock_recovery_f, (self.gr_float_to_complex, 1)) # self.connect(self.gr_null_source, (self.gr_float_to_complex, 0)) # # self.connect(self.gr_float_to_complex, self._snr_probe, self.gr_null_sink_cc) self.connect(self._vector_source_ref, (self._ber,1)) self.connect(self._ber, self.gr_null_sink_f)