Ejemplo n.º 1
0
    def __init__(self, freq_sample_delay_samps, freq_samps_to_avg,
                 mag_samps_to_avg, thresh):
        gr.hier_block2.__init__(
            self, "Sample and Hold Detector",
            gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]),
            gr.io_signaturev(4, 4, [
                gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1,
                gr.sizeof_float * 1
            ]))
        '''
        Constructor
        
        @param freq_sample_delay_samps - 
        @param freq_samps_to_avg - 
        @param mag_samps_to_avg - 
        @param thresh - 
        
        '''

        ##################################################
        # Parameters
        ##################################################
        self.freq_sample_delay_samps = freq_sample_delay_samps
        self.freq_samps_to_avg = freq_samps_to_avg
        self.mag_samps_to_avg = mag_samps_to_avg
        self.thresh = thresh

        ##################################################
        # Blocks
        ##################################################
        self.edge_detector = timing_utils.edge_detector_bb(
            timing_utils.RISING_EDGE)
        self.threshold = blocks.threshold_ff(thresh / 4.0, thresh, 0)
        self.samp_hold = blocks.sample_and_hold_ff()
        self.mag_avg = blocks.moving_average_ff(int(mag_samps_to_avg),
                                                1.0 / (mag_samps_to_avg), 4000)
        self.freq_avg = blocks.moving_average_ff(int(freq_samps_to_avg),
                                                 1.0 / (freq_samps_to_avg),
                                                 4000)
        self.f2c = blocks.float_to_char(1, 1)
        self.delay = blocks.delay(
            gr.sizeof_float * 1,
            int(freq_samps_to_avg - mag_samps_to_avg +
                freq_sample_delay_samps))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.delay, 0), (self.mag_avg, 0))
        self.connect((self.f2c, 0), (self.edge_detector, 0))
        self.connect((self.freq_avg, 0), (self.samp_hold, 0))
        self.connect((self.freq_avg, 0), (self, 1))
        self.connect((self.mag_avg, 0), (self.threshold, 0))
        self.connect((self.mag_avg, 0), (self, 3))
        self.connect((self.samp_hold, 0), (self, 0))
        self.connect((self.threshold, 0), (self.f2c, 0))
        self.connect((self.threshold, 0), (self, 2))
        self.connect((self, 0), (self.delay, 0))
        self.connect((self, 1), (self.freq_avg, 0))
        self.connect((self.edge_detector, 0), (self.samp_hold, 1))
Ejemplo n.º 2
0
	def _update_filtered(self, translated):
		if translated is not None and self._taps is not None:
			filtered = TimeData(numpy.complex64(scipy.signal.lfilter(self._taps, 1, translated.samples)), translated.sampling_rate)
			filtered_abs = filtered.abs

			data_source = filtered_abs.samples
			numpy_source = NumpySource(data_source)
			peak_detector = blocks.peak_detector_fb(1.0, 0.3, 10, 0.001)
			sample_and_hold = blocks.sample_and_hold_ff()
			multiply_const = blocks.multiply_const_vff((0.5, ))
			subtract = blocks.sub_ff(1)
			numpy_sink = NumpySink(numpy.float32)
			top = gr.top_block()
			top.connect((numpy_source, 0), (peak_detector, 0))
			top.connect((numpy_source, 0), (sample_and_hold, 0))
			top.connect((numpy_source, 0), (subtract, 0))
			top.connect((peak_detector, 0), (sample_and_hold, 1))
			top.connect((sample_and_hold, 0), (multiply_const, 0))
			top.connect((multiply_const, 0), (subtract, 1))
			top.connect((subtract, 0), (numpy_sink, 0))
			top.run()
			filtered = TimeData(numpy_sink.data, translated.sampling_rate)

			self.filtered_view.data = filtered
			# abs_min = filtered.abs.min
			# abs_max = filtered.abs.max
			# abs_mid = (abs_min + abs_max) / 2.0

			# self.burst.filtered = filtered.abs - abs_mid
			self.burst.filtered = filtered
		else:
			self.filtered_view.data = None
			self.burst.filtered = None
Ejemplo n.º 3
0
	def _update_filtered(self, translated):
		if translated is not None and self._taps is not None:
			filtered = TimeData(numpy.complex64(scipy.signal.lfilter(self._taps, 1, translated.samples)), translated.sampling_rate)
			filtered_abs = filtered.abs

			data_source = filtered_abs.samples
			numpy_source = NumpySource(data_source)
			peak_detector = blocks.peak_detector_fb(1.0, 0.3, 10, 0.001)
			sample_and_hold = blocks.sample_and_hold_ff()
			multiply_const = blocks.multiply_const_vff((0.5, ))
			subtract = blocks.sub_ff(1)
			numpy_sink = NumpySink(numpy.float32)
			top = gr.top_block()
			top.connect((numpy_source, 0), (peak_detector, 0))
			top.connect((numpy_source, 0), (sample_and_hold, 0))
			top.connect((numpy_source, 0), (subtract, 0))
			top.connect((peak_detector, 0), (sample_and_hold, 1))
			top.connect((sample_and_hold, 0), (multiply_const, 0))
			top.connect((multiply_const, 0), (subtract, 1))
			top.connect((subtract, 0), (numpy_sink, 0))
			top.run()
			filtered = TimeData(numpy_sink.data, translated.sampling_rate)

			self.filtered_view.data = filtered
			# abs_min = filtered.abs.min
			# abs_max = filtered.abs.max
			# abs_mid = (abs_min + abs_max) / 2.0

			# self.burst.filtered = filtered.abs - abs_mid
			self.burst.filtered = filtered
		else:
			self.filtered_view.data = None
			self.burst.filtered = None
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        gr.hier_block2.__init__(
            self, "freq_timing_estimator_hier",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
    def test_001(self):
        src_data        = 10*[0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1]
        ctrl_data       = 10*[1,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
        expected_result = 10*(0,0,0,0,4,5,6,7,8,9,9,9,9,9,9,9,9,9)

        src  = blocks.vector_source_f(src_data)
        ctrl = blocks.vector_source_b(ctrl_data)
        op = blocks.sample_and_hold_ff()
        dst = blocks.vector_sink_f()

        self.tb.connect(src,  (op,0))
        self.tb.connect(ctrl, (op,1))
        self.tb.connect(op, dst)
        self.tb.run()

        result = dst.data()
        self.assertFloatTuplesAlmostEqual(expected_result, result, places=6)
Ejemplo n.º 6
0
    def __init__(self, fft_length, cp_length, logging=False):
        """
        OFDM synchronization using PN Correlation:
        T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing
        Synchronization for OFDM," IEEE Trans. Communications, vol. 45,
        no. 12, 1997.
        """

        gr.hier_block2.__init__(self, "ofdm_sync_pn",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature

        self.input = blocks.add_const_cc(0)

        # PN Sync

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length/2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc();
        self.corr = blocks.multiply_cc();

        # Create a moving sum filter for the corr output
        self.moving_sum_filter = filter.fir_filter_ccf(1, [1.0] * (fft_length//2))

        # Create a moving sum filter for the input
        self.inputmag2 = blocks.complex_to_mag_squared()
        self.inputmovingsum = filter.fir_filter_fff(1, [1.0] * (fft_length//2))

        self.square = blocks.multiply_ff()
        self.normalize = blocks.divide_ff()

        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = blocks.complex_to_mag_squared()
        self.angle = blocks.complex_to_arg()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.sub1 = blocks.add_const_ff(-1)
        self.pk_detect = blocks.peak_detector_fb(0.20, 0.20, 30, 0.001)

        self.connect(self, self.input)

        # Calculate the frequency offset from the correlation of the preamble
        self.connect(self.input, self.delay)
        self.connect(self.input, (self.corr,0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr,1))
        self.connect(self.corr, self.moving_sum_filter)
        self.connect(self.moving_sum_filter, self.c2mag)
        self.connect(self.moving_sum_filter, self.angle)
        self.connect(self.angle, (self.sample_and_hold,0))

        # Get the power of the input signal to normalize the output of the correlation
        self.connect(self.input, self.inputmag2, self.inputmovingsum)
        self.connect(self.inputmovingsum, (self.square,0))
        self.connect(self.inputmovingsum, (self.square,1))
        self.connect(self.square, (self.normalize,1))
        self.connect(self.c2mag, (self.normalize,0))

        # Create a moving sum filter for the corr output
        matched_filter_taps = [1.0/cp_length for i in range(cp_length)]
        self.matched_filter = filter.fir_filter_fff(1,matched_filter_taps)
        self.connect(self.normalize, self.matched_filter)
        
        self.connect(self.matched_filter, self.sub1, self.pk_detect)
        #self.connect(self.matched_filter, self.pk_detect)
        self.connect(self.pk_detect, (self.sample_and_hold,1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self,0))
        self.connect(self.pk_detect, (self,1))

        if logging:
            self.connect(self.matched_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat"))
            self.connect(self.normalize, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat"))
            self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat"))
Ejemplo n.º 7
0
    def __init__(self, seq1, seq2, factor, lookahead, alpha, freqs):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.lookahead = lookahead
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, self.lookahead, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
Ejemplo n.º 8
0
    def __init__(self, fft_length, cp_length, kstime, logging=False):
        """
        OFDM synchronization using PN Correlation and initial cross-correlation:
        F. Tufvesson, O. Edfors, and M. Faulkner, "Time and Frequency Synchronization for OFDM using
        PN-Sequency Preambles," IEEE Proc. VTC, 1999, pp. 2203-2207.

        This implementation is meant to be a more robust version of the Schmidl and Cox receiver design.
        By correlating against the preamble and using that as the input to the time-delayed correlation,
        this circuit produces a very clean timing signal at the end of the preamble. The timing is
        more accurate and does not have the problem associated with determining the timing from the
        plateau structure in the Schmidl and Cox.

        This implementation appears to require that the signal is received with a normalized power or signal
        scaling factor to reduce ambiguities introduced from partial correlation of the cyclic prefix and
        the peak detection. A better peak detection block might fix this.

        Also, the cross-correlation falls apart as the frequency offset gets larger and completely fails
        when an integer offset is introduced. Another thing to look at.
        """

        gr.hier_block2.__init__(self, "ofdm_sync_pnac",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature

        self.input = blocks.add_const_cc(0)

        symbol_length = fft_length + cp_length

        # PN Sync with cross-correlation input

        # cross-correlate with the known symbol
        kstime = [k.conjugate() for k in kstime[0:fft_length//2]]
        kstime.reverse()
        self.crosscorr_filter = filter.fir_filter_ccc(1, kstime)
        
        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length/2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc();
        self.corr = blocks.multiply_cc();

        # Create a moving sum filter for the input
        self.mag = blocks.complex_to_mag_squared()
        self.power = filter.fir_filter_fff(1, [1.0] * int(fft_length))

        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = blocks.complex_to_mag_squared()
        self.angle = blocks.complex_to_arg()
        self.compare = blocks.sub_ff()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.threshold = blocks.threshold_ff(0,0,0)      # threshold detection might need to be tweaked
        self.peaks = blocks.float_to_char()

        self.connect(self, self.input)

        # Cross-correlate input signal with known preamble
        self.connect(self.input, self.crosscorr_filter)

        # use the output of the cross-correlation as input time-shifted correlation
        self.connect(self.crosscorr_filter, self.delay)
        self.connect(self.crosscorr_filter, (self.corr,0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr,1))
        self.connect(self.corr, self.c2mag)
        self.connect(self.corr, self.angle)
        self.connect(self.angle, (self.sample_and_hold,0))
        
        # Get the power of the input signal to compare against the correlation
        self.connect(self.crosscorr_filter, self.mag, self.power)

        # Compare the power to the correlator output to determine timing peak
        # When the peak occurs, it peaks above zero, so the thresholder detects this
        self.connect(self.c2mag, (self.compare,0))
        self.connect(self.power, (self.compare,1))
        self.connect(self.compare, self.threshold)
        self.connect(self.threshold, self.peaks, (self.sample_and_hold,1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self,0))
        self.connect(self.peaks, (self,1))

        if logging:
            self.connect(self.compare, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-compare_f.dat"))
            self.connect(self.c2mag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-theta_f.dat"))
            self.connect(self.power, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-inputpower_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-epsilon_f.dat"))
            self.connect(self.threshold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-threshold_f.dat"))
            self.connect(self.peaks, blocks.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat"))
            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pnac-input_c.dat"))
Ejemplo n.º 9
0
    def __init__(self, seq1, seq2, factor, alpha, samp_rate, freqs):
        """
        Description:

        This block is functionally equivalent to the frequency_timing_estimator block, except from the fact that each filter is matched to a sequence that can be written as the kronecker product of seq1 and seq2.

        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). 
             alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1).
             samp_rate: the sample rate of the system, which is used in the kronecker_filter.
             freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= cdma.kronecker_filter(seq1,seq2,samp_rate,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
Ejemplo n.º 10
0
    def __init__(self, seq1, seq2, factor, alpha, freqs):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(
            self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(
                3, 3,
                [gr.sizeof_char * 1, gr.sizeof_float * 1, gr.sizeof_float * 1
                 ]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1

        ##################################################
        # Blocks
        ##################################################
        self._filter = [0] * self.n
        self._c2mag2 = [0] * self.n
        for i in range(self.n):
            #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
            #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
            self._filter[i] = filter.freq_xlating_fft_filter_ccc(
                1, numpy.kron(seq1, seq2), self.freqs[i], 1)
            self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(
            self.factor, self.factor, 0, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short * 1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs),
                                                                      1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
            self.connect((self, 0), (self._filter[i], 0))
            self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
            self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
            self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1),
                     (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0),
                     (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0),
                     (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
    def __init__(self, seq1, seq2, factor, alpha, freqs, debug_onoff, debug_port, prefix):
        """
        Description:
frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing.


        Args:
	     seq1: sequence1 of kronecker filter, which is the given training sequence. 
	     seq2: sequence2 of kronecker filter, which is the pulse for each training symbol.
             factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak.
             alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1).
             freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(self,
            "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.seq1 = seq1
        self.seq2 = seq2
        self.factor = factor
        self.alpha = alpha
        self.freqs = freqs
        self.n = n = len(freqs)
        self.on = 1
        self.debug_onoff = debug_onoff # 1: dump ports info to file 0: no debug output
        self.debug_port = debug_port # 0-n_filt-1 is the output of each filter branck; n_filter is the output of maximum
        self.prefix = prefix

        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i])
          #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, 0, self.alpha, self.on)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()
	    
        if self.debug_onoff == True:
            num_of_file_sinks = len(self.debug_port)
            self._filesink = [0]*num_of_file_sinks
            for i in range(num_of_file_sinks):
                if self.debug_port[i] == self.n:
                    filename = prefix+"max.dat"
                    
                else:
                    filename = prefix+"filter"+str(i)+".dat"
                print filename
                self._filesink[i] = blocks.file_sink(gr.sizeof_float*1, filename, False)
                self._filesink[i].set_unbuffered(False)

    	# this is the block for bundling the outputs of each branch of filters and the input of peak detector	
        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
        if self.debug_onoff == True:
            for i in range(num_of_file_sinks):
                port_index = self.debug_port[i]
                if port_index == self.n:
                    self.connect((self.blocks_max, 0), (self._filesink[i], 0))
                else:
                    self.connect((self._c2mag2[port_index], 0), (self._filesink[i], 0))
    def __init__(self, fft_length, cp_length, kstime, logging=False):
        """
        OFDM synchronization using PN Correlation and initial cross-correlation:
        F. Tufvesson, O. Edfors, and M. Faulkner, "Time and Frequency Synchronization for OFDM using
        PN-Sequency Preambles," IEEE Proc. VTC, 1999, pp. 2203-2207.

        This implementation is meant to be a more robust version of the Schmidl and Cox receiver design.
        By correlating against the preamble and using that as the input to the time-delayed correlation,
        this circuit produces a very clean timing signal at the end of the preamble. The timing is 
        more accurate and does not have the problem associated with determining the timing from the
        plateau structure in the Schmidl and Cox.

        This implementation appears to require that the signal is received with a normalized power or signal
        scalling factor to reduce ambiguities intorduced from partial correlation of the cyclic prefix and
        the peak detection. A better peak detection block might fix this.

        Also, the cross-correlation falls apart as the frequency offset gets larger and completely fails
        when an integer offset is introduced. Another thing to look at.
        """

        gr.hier_block2.__init__(
            self,
            "ofdm_sync_pnac",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature2(2, 2, gr.sizeof_float,
                             gr.sizeof_char))  # Output signature

        self.input = blocks.add_const_cc(0)

        symbol_length = fft_length + cp_length

        # PN Sync with cross-correlation input

        # cross-correlate with the known symbol
        kstime = [k.conjugate() for k in kstime[0:fft_length // 2]]
        kstime.reverse()
        self.crosscorr_filter = filter.fir_filter_ccc(1, kstime)

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length / 2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc()
        self.corr = blocks.multiply_cc()

        # Create a moving sum filter for the input
        self.mag = blocks.complex_to_mag_squared()
        movingsum_taps = (fft_length // 1) * [
            1.0,
        ]
        self.power = filter.fir_filter_fff(1, movingsum_taps)

        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = blocks.complex_to_mag_squared()
        self.angle = blocks.complex_to_arg()
        self.compare = blocks.sub_ff()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.threshold = blocks.threshold_ff(
            0, 0, 0)  # threshold detection might need to be tweaked
        self.peaks = blocksx.float_to_char()

        self.connect(self, self.input)

        # Cross-correlate input signal with known preamble
        self.connect(self.input, self.crosscorr_filter)

        # use the output of the cross-correlation as input time-shifted correlation
        self.connect(self.crosscorr_filter, self.delay)
        self.connect(self.crosscorr_filter, (self.corr, 0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr, 1))
        self.connect(self.corr, self.c2mag)
        self.connect(self.corr, self.angle)
        self.connect(self.angle, (self.sample_and_hold, 0))

        # Get the power of the input signal to compare against the correlation
        self.connect(self.crosscorr_filter, self.mag, self.power)

        # Compare the power to the correlator output to determine timing peak
        # When the peak occurs, it peaks above zero, so the thresholder detects this
        self.connect(self.c2mag, (self.compare, 0))
        self.connect(self.power, (self.compare, 1))
        self.connect(self.compare, self.threshold)
        self.connect(self.threshold, self.peaks, (self.sample_and_hold, 1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self, 0))
        self.connect(self.peaks, (self, 1))

        if logging:
            self.connect(
                self.compare,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-compare_f.dat"))
            self.connect(
                self.c2mag,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-theta_f.dat"))
            self.connect(
                self.power,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-inputpower_f.dat"))
            self.connect(
                self.angle,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-epsilon_f.dat"))
            self.connect(
                self.threshold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-threshold_f.dat"))
            self.connect(
                self.peaks,
                blocks.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat"))
            self.connect(
                self.sample_and_hold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pnac-sample_and_hold_f.dat"))
            self.connect(
                self.input,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_pnac-input_c.dat"))
Ejemplo n.º 13
0
    def __init__(self, fft_length, cp_length, logging=False):
        """
        OFDM synchronization using PN Correlation:
        T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing
        Synchronization for OFDM," IEEE Trans. Communications, vol. 45,
        no. 12, 1997.
        """

        gr.hier_block2.__init__(
            self,
            "ofdm_sync_pn",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature2(2, 2, gr.sizeof_float,
                             gr.sizeof_char))  # Output signature

        self.input = blocks.add_const_cc(0)

        # PN Sync

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length / 2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc()
        self.corr = blocks.multiply_cc()

        # Create a moving sum filter for the corr output
        self.moving_sum_filter = filter.fir_filter_ccf(1, [1.0] *
                                                       (fft_length // 2))

        # Create a moving sum filter for the input
        self.inputmag2 = blocks.complex_to_mag_squared()
        self.inputmovingsum = filter.fir_filter_fff(1,
                                                    [1.0] * (fft_length // 2))

        self.square = blocks.multiply_ff()
        self.normalize = blocks.divide_ff()

        # Get magnitude (peaks) and angle (phase/freq error)
        self.c2mag = blocks.complex_to_mag_squared()
        self.angle = blocks.complex_to_arg()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        #ML measurements input to sampler block and detect
        self.sub1 = blocks.add_const_ff(-1)
        self.pk_detect = blocks.peak_detector_fb(0.20, 0.20, 30, 0.001)

        self.connect(self, self.input)

        # Calculate the frequency offset from the correlation of the preamble
        self.connect(self.input, self.delay)
        self.connect(self.input, (self.corr, 0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr, 1))
        self.connect(self.corr, self.moving_sum_filter)
        self.connect(self.moving_sum_filter, self.c2mag)
        self.connect(self.moving_sum_filter, self.angle)
        self.connect(self.angle, (self.sample_and_hold, 0))

        # Get the power of the input signal to normalize the output of the correlation
        self.connect(self.input, self.inputmag2, self.inputmovingsum)
        self.connect(self.inputmovingsum, (self.square, 0))
        self.connect(self.inputmovingsum, (self.square, 1))
        self.connect(self.square, (self.normalize, 1))
        self.connect(self.c2mag, (self.normalize, 0))

        # Create a moving sum filter for the corr output
        matched_filter_taps = [1.0 / cp_length for i in range(cp_length)]
        self.matched_filter = filter.fir_filter_fff(1, matched_filter_taps)
        self.connect(self.normalize, self.matched_filter)

        self.connect(self.matched_filter, self.sub1, self.pk_detect)
        #self.connect(self.matched_filter, self.pk_detect)
        self.connect(self.pk_detect, (self.sample_and_hold, 1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self, 0))
        self.connect(self.pk_detect, (self, 1))

        if logging:
            self.connect(
                self.matched_filter,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat"))
            self.connect(
                self.normalize,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat"))
            self.connect(
                self.angle,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-epsilon_f.dat"))
            self.connect(
                self.pk_detect,
                blocks.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
            self.connect(
                self.sample_and_hold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-sample_and_hold_f.dat"))
            self.connect(
                self.input,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_pn-input_c.dat"))
Ejemplo n.º 14
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.mod_index0 = mod_index0 = 0.5
        self.fs0 = fs0 = 100000
        self.freq0 = freq0 = 2500
        self.fpor0 = fpor0 = 30000
        self.fmod0 = fmod0 = 2000
        self.dutycycle0 = dutycycle0 = 0.5
        self.amplitud0 = amplitud0 = 1
        self.syh_on = syh_on = True
        self.switch_on = switch_on = True
        self.seniales_control_iguales = seniales_control_iguales = 0
        self.samp_rate = samp_rate = 300000
        self.mod_index = mod_index = mod_index0
        self.input_signal = input_signal = 0
        self.input_freq = input_freq = freq0
        self.fs = fs = fs0
        self.fpor = fpor = fpor0
        self.fmod = fmod = fmod0
        self.filtro_recuperador_on = filtro_recuperador_on = True
        self.filtro_antialiasing_on = filtro_antialiasing_on = True
        self.dutycycle = dutycycle = dutycycle0
        self.amplitud = amplitud = amplitud0

        ##################################################
        # Blocks
        ##################################################
        self.main_tab = Qt.QTabWidget()
        self.main_tab_widget_0 = Qt.QWidget()
        self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.main_tab_widget_0)
        self.main_tab_grid_layout_0 = Qt.QGridLayout()
        self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0)
        self.main_tab.addTab(self.main_tab_widget_0, '')
        self.top_grid_layout.addWidget(self.main_tab)
        self.gui_tab_configuracion = Qt.QTabWidget()
        self.gui_tab_configuracion_widget_0 = Qt.QWidget()
        self.gui_tab_configuracion_layout_0 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.gui_tab_configuracion_widget_0)
        self.gui_tab_configuracion_grid_layout_0 = Qt.QGridLayout()
        self.gui_tab_configuracion_layout_0.addLayout(
            self.gui_tab_configuracion_grid_layout_0)
        self.gui_tab_configuracion.addTab(self.gui_tab_configuracion_widget_0,
                                          'Streamline')
        self.gui_tab_configuracion_widget_1 = Qt.QWidget()
        self.gui_tab_configuracion_layout_1 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.gui_tab_configuracion_widget_1)
        self.gui_tab_configuracion_grid_layout_1 = Qt.QGridLayout()
        self.gui_tab_configuracion_layout_1.addLayout(
            self.gui_tab_configuracion_grid_layout_1)
        self.gui_tab_configuracion.addTab(self.gui_tab_configuracion_widget_1,
                                          'Inputs')
        self.main_tab_grid_layout_0.addWidget(self.gui_tab_configuracion, 0, 0,
                                              1, 1)
        for r in range(0, 1):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        _syh_on_check_box = Qt.QCheckBox("Sample and hold on")
        self._syh_on_choices = {True: 1, False: 0}
        self._syh_on_choices_inv = dict(
            (v, k) for k, v in self._syh_on_choices.iteritems())
        self._syh_on_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _syh_on_check_box, "setChecked",
            Qt.Q_ARG("bool", self._syh_on_choices_inv[i]))
        self._syh_on_callback(self.syh_on)
        _syh_on_check_box.stateChanged.connect(
            lambda i: self.set_syh_on(self._syh_on_choices[bool(i)]))
        self.gui_tab_configuracion_grid_layout_0.addWidget(
            _syh_on_check_box, 0, 0, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.gui_tab_configuracion_grid_layout_0.setColumnStretch(c, 1)
        _switch_on_check_box = Qt.QCheckBox("Llave analogica on")
        self._switch_on_choices = {True: 1, False: 0}
        self._switch_on_choices_inv = dict(
            (v, k) for k, v in self._switch_on_choices.iteritems())
        self._switch_on_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _switch_on_check_box, "setChecked",
            Qt.Q_ARG("bool", self._switch_on_choices_inv[i]))
        self._switch_on_callback(self.switch_on)
        _switch_on_check_box.stateChanged.connect(
            lambda i: self.set_switch_on(self._switch_on_choices[bool(i)]))
        self.gui_tab_configuracion_grid_layout_0.addWidget(
            _switch_on_check_box, 0, 1, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_0.setColumnStretch(c, 1)
        self._seniales_control_iguales_options = (
            0,
            1,
        )
        self._seniales_control_iguales_labels = (
            'Iguales',
            'Invertidas',
        )
        self._seniales_control_iguales_tool_bar = Qt.QToolBar(self)
        self._seniales_control_iguales_tool_bar.addWidget(
            Qt.QLabel('Relacion seniales control' + ": "))
        self._seniales_control_iguales_combo_box = Qt.QComboBox()
        self._seniales_control_iguales_tool_bar.addWidget(
            self._seniales_control_iguales_combo_box)
        for label in self._seniales_control_iguales_labels:
            self._seniales_control_iguales_combo_box.addItem(label)
        self._seniales_control_iguales_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._seniales_control_iguales_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._seniales_control_iguales_options.index(i)))
        self._seniales_control_iguales_callback(self.seniales_control_iguales)
        self._seniales_control_iguales_combo_box.currentIndexChanged.connect(
            lambda i: self.set_seniales_control_iguales(
                self._seniales_control_iguales_options[i]))
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._seniales_control_iguales_tool_bar, 0, 1, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._mod_index_range = Range(0, 1, 0.05, mod_index0, 200)
        self._mod_index_win = RangeWidget(self._mod_index_range,
                                          self.set_mod_index,
                                          'Indice de modulacion (solo AM)',
                                          "counter_slider", float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._mod_index_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._input_signal_options = (
            0,
            1,
            2,
            3,
        )
        self._input_signal_labels = (
            'Seno',
            'Diente de sierra',
            'Seno 3/2',
            'Senial AM',
        )
        self._input_signal_tool_bar = Qt.QToolBar(self)
        self._input_signal_tool_bar.addWidget(Qt.QLabel("input_signal" + ": "))
        self._input_signal_combo_box = Qt.QComboBox()
        self._input_signal_tool_bar.addWidget(self._input_signal_combo_box)
        for label in self._input_signal_labels:
            self._input_signal_combo_box.addItem(label)
        self._input_signal_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._input_signal_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._input_signal_options.index(i)))
        self._input_signal_callback(self.input_signal)
        self._input_signal_combo_box.currentIndexChanged.connect(
            lambda i: self.set_input_signal(self._input_signal_options[i]))
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._input_signal_tool_bar, 0, 0, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._input_freq_range = Range(freq0 / 10, freq0 * 10, freq0 / 100,
                                       freq0, 200)
        self._input_freq_win = RangeWidget(
            self._input_freq_range, self.set_input_freq,
            'Frecuencia senial de entrada (no AM ni sen32)', "counter_slider",
            float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._input_freq_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._fs_range = Range(400, 130000, 100, fs0, 200)
        self._fs_win = RangeWidget(self._fs_range, self.set_fs,
                                   'Frecuencia de muestreo ', "counter_slider",
                                   float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._fs_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._fpor_range = Range(100, 130000, 100, fpor0, 200)
        self._fpor_win = RangeWidget(self._fpor_range, self.set_fpor,
                                     'Frecuencia portadora (solo AM)',
                                     "counter_slider", float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._fpor_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._fmod_range = Range(100, 130000, 100, fmod0, 200)
        self._fmod_win = RangeWidget(self._fmod_range, self.set_fmod,
                                     'Frecuencia moduladora (solo AM)',
                                     "counter_slider", float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._fmod_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        _filtro_recuperador_on_check_box = Qt.QCheckBox(
            "Filtro recuperador on")
        self._filtro_recuperador_on_choices = {True: 1, False: 0}
        self._filtro_recuperador_on_choices_inv = dict(
            (v, k) for k, v in self._filtro_recuperador_on_choices.iteritems())
        self._filtro_recuperador_on_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _filtro_recuperador_on_check_box, "setChecked",
            Qt.Q_ARG("bool", self._filtro_recuperador_on_choices_inv[i]))
        self._filtro_recuperador_on_callback(self.filtro_recuperador_on)
        _filtro_recuperador_on_check_box.stateChanged.connect(
            lambda i: self.set_filtro_recuperador_on(
                self._filtro_recuperador_on_choices[bool(i)]))
        self.gui_tab_configuracion_grid_layout_0.addWidget(
            _filtro_recuperador_on_check_box, 0, 2, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_0.setRowStretch(r, 1)
        for c in range(2, 3):
            self.gui_tab_configuracion_grid_layout_0.setColumnStretch(c, 1)
        _filtro_antialiasing_on_check_box = Qt.QCheckBox(
            "Filtro antialiasing on")
        self._filtro_antialiasing_on_choices = {True: 1, False: 0}
        self._filtro_antialiasing_on_choices_inv = dict(
            (v, k)
            for k, v in self._filtro_antialiasing_on_choices.iteritems())
        self._filtro_antialiasing_on_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _filtro_antialiasing_on_check_box, "setChecked",
            Qt.Q_ARG("bool", self._filtro_antialiasing_on_choices_inv[i]))
        self._filtro_antialiasing_on_callback(self.filtro_antialiasing_on)
        _filtro_antialiasing_on_check_box.stateChanged.connect(
            lambda i: self.set_filtro_antialiasing_on(
                self._filtro_antialiasing_on_choices[bool(i)]))
        self.gui_tab_configuracion_grid_layout_0.addWidget(
            _filtro_antialiasing_on_check_box, 0, 3, 1, 1)
        for r in range(0, 1):
            self.gui_tab_configuracion_grid_layout_0.setRowStretch(r, 1)
        for c in range(3, 4):
            self.gui_tab_configuracion_grid_layout_0.setColumnStretch(c, 1)
        self._dutycycle_range = Range(0.05, 0.95, 0.05, dutycycle0, 200)
        self._dutycycle_win = RangeWidget(self._dutycycle_range,
                                          self.set_dutycycle, 'Duty cycle',
                                          "counter_slider", float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._dutycycle_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self._amplitud_range = Range(0, 5, 0.2, amplitud0, 200)
        self._amplitud_win = RangeWidget(self._amplitud_range,
                                         self.set_amplitud, 'Amplitud',
                                         "counter_slider", float)
        self.gui_tab_configuracion_grid_layout_1.addWidget(
            self._amplitud_win, 4, 1, 1, 1)
        for r in range(4, 5):
            self.gui_tab_configuracion_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.gui_tab_configuracion_grid_layout_1.setColumnStretch(c, 1)
        self.senoidal = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE,
                                            input_freq, 1, 0)
        self.sen32 = blocks.wavfile_source('sen32.wav', True)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Output",  #name
            6  #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.1, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        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(True)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = [
            'Salida filtro antialias', 'Salida sample and hold',
            'Salida llave analogica', 'Salida filtro recuperador', 'Entrada',
            'Output', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "magenta", "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(6):
            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.main_tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1,
                                              0, 1, 1)
        for r in range(1, 2):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            6  #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(True)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        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(True)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not False)

        labels = [
            'Salida filtro antialias', 'Salida sample and hold',
            'Salida llave analogica', 'Salida filtro recuperador', 'Entrada',
            'Output', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "magenta", "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(6):
            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.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 2,
                                              0, 1, 1)
        for r in range(2, 3):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.portadora = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE,
                                             fpor, 1, 0)
        self.moduladora = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE,
                                              fmod, 1, 0)
        self.filtro_recuperador = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, freq0 * 18, freq0 * 18 * 0.5,
                            firdes.WIN_HAMMING, 6.76))
        self.filtro_antialiasing = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, freq0 * 18, freq0 * 18 * 0.5,
                            firdes.WIN_HAMMING, 6.76))
        self.diente_de_sierra = analog.sig_source_f(samp_rate,
                                                    analog.GR_SAW_WAVE,
                                                    input_freq, 1, 0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            dutycycle, dutycycle, 0)
        self.blocks_sample_and_hold_xx_0 = blocks.sample_and_hold_ff()
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff(
            (amplitud, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (mod_index, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (seniales_control_iguales, ))
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((1, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=seniales_control_iguales,
            output_index=0,
        )
        self.blks2_selector_0_1 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=4,
            num_outputs=1,
            input_index=input_signal,
            output_index=0,
        )
        self.blks2_selector_0_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=filtro_antialiasing_on,
            output_index=0,
        )
        self.blks2_selector_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=filtro_recuperador_on,
            output_index=0,
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=switch_on,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=syh_on,
            output_index=0,
        )
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SAW_WAVE, fs, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blks2_selector_0_0, 0))
        self.connect((self.blks2_selector_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blks2_selector_0_0, 0),
                     (self.blks2_selector_0_0_0, 0))
        self.connect((self.blks2_selector_0_0, 0),
                     (self.filtro_recuperador, 0))
        self.connect((self.blks2_selector_0_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 5))
        self.connect((self.blks2_selector_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 5))
        self.connect((self.blks2_selector_0_0_0_0, 0),
                     (self.blks2_selector_0, 0))
        self.connect((self.blks2_selector_0_0_0_0, 0),
                     (self.blocks_sample_and_hold_xx_0, 0))
        self.connect((self.blks2_selector_0_1, 0),
                     (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blks2_selector_1, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_sample_and_hold_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blks2_selector_1, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blks2_selector_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blks2_selector_0_1, 3))
        self.connect((self.blocks_sample_and_hold_xx_0, 0),
                     (self.blks2_selector_0, 1))
        self.connect((self.blocks_sample_and_hold_xx_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_sample_and_hold_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blks2_selector_1, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_selector_0_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.filtro_antialiasing, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 4))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_time_sink_x_0, 4))
        self.connect((self.diente_de_sierra, 0), (self.blks2_selector_0_1, 1))
        self.connect((self.filtro_antialiasing, 0),
                     (self.blks2_selector_0_0_0_0, 1))
        self.connect((self.filtro_antialiasing, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.filtro_antialiasing, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.filtro_recuperador, 0),
                     (self.blks2_selector_0_0_0, 1))
        self.connect((self.filtro_recuperador, 0),
                     (self.qtgui_freq_sink_x_0, 3))
        self.connect((self.filtro_recuperador, 0),
                     (self.qtgui_time_sink_x_0, 3))
        self.connect((self.moduladora, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.portadora, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.sen32, 0), (self.blks2_selector_0_1, 2))
        self.connect((self.senoidal, 0), (self.blks2_selector_0_1, 0))
Ejemplo n.º 15
0
    def __init__(self, ts, factor, alpha, samp_rate, freqs):
        """
	Description:
        This block is designed to perform frequency and timing acquisition for a known training sequence in the presense of frequency and timing offset and noise. Its input is a complex stream.  It has three outputs: 
 1)  a stream of flags (bytes) indicating the begining of the training sequence (to be used from subsequent blocks to "chop" the incoming stream,
 2)  a stream with the current acquired frequency offset, and
 3)  a stream with the current acquired peak of the matched filter 

	Internally, it consists of a user defined number of parallel matched filters (as many as the size of the freqs vector), each consistng of a frequency Xlating FIR filter with sample rate samp_rate, filter taps matched to the training sequence ts, and center frequency freqs[i]. The filter outputs are magnitude squared and passed through a max block and then through a peak detector. 
 
	Args:
	     ts: the training sequence. For example, in DSSS system, it's the chip-based spread training sequence. 
	     factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended.  In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). 
	     alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1).
	     samp_rate: the sample rate of the system, which is used in the freq_xlating_fir_filter.
	     freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt).
        """

        gr.hier_block2.__init__(
            self, "freq_timing_estimator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.ts = ts
        self.factor = factor
        self.alpha = alpha
        self.samp_rate = samp_rate
        self.freqs = freqs
        self.n = n = len(freqs)
        ##################################################
        # Blocks
        ##################################################
        self._filter=[0]*self.n
        self._c2mag2=[0]*self.n
        for i in range(self.n):
          self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate)
          self._c2mag2[i] = blocks.complex_to_mag_squared(1)

        self.blocks_max = blocks.max_ff(1)
        self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha)

        self.blocks_argmax = blocks.argmax_fs(1)
        self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1)
        self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1)
        self.blocks_sample_and_hold = blocks.sample_and_hold_ff()

        ##################################################
        # Connections
        ##################################################
        for i in range(self.n):
          self.connect((self, 0), (self._filter[i], 0))
          self.connect((self._filter[i], 0), (self._c2mag2[i], 0))
          self.connect((self._c2mag2[i], 0), (self.blocks_max, i))
          self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i))
        self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0))
        self.connect((self.blocks_peak_detector, 0), (self, 0))
        self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0))
        self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0))
        self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0))
        self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1))
        self.connect((self.blocks_sample_and_hold, 0), (self, 1))
        self.connect((self.blocks_max, 0), (self, 2))
Ejemplo n.º 16
0
    def __init__(self):
        gr.top_block.__init__(self, "Simulation G3")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simulation G3")
        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", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.variable_qtgui_chooser_0 = variable_qtgui_chooser_0 = 0
        self.samplenholdcheck = samplenholdcheck = True
        self.samp_rate = samp_rate = 300000
        self.m = m = 0.5
        self.llaveAnalcheck = llaveAnalcheck = True
        self.fportadora = fportadora = 3000
        self.fp = fp = 10500
        self.fmoduladora = fmoduladora = 300
        self.faacheck = faacheck = True
        self.dutycycle = dutycycle = 0.5
        self.UIF = UIF = 1500
        self.SR = SR = 20000
        self.FR = FR = True
        self.AMPLITUD = AMPLITUD = 1

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_chooser_0_options = (0, 1, 2, 3, )
        self._variable_qtgui_chooser_0_labels = ('Sine', 'Triangle', 'SIN3/2', 'AM', )
        self._variable_qtgui_chooser_0_tool_bar = Qt.QToolBar(self)
        self._variable_qtgui_chooser_0_tool_bar.addWidget(Qt.QLabel('Signal'+": "))
        self._variable_qtgui_chooser_0_combo_box = Qt.QComboBox()
        self._variable_qtgui_chooser_0_tool_bar.addWidget(self._variable_qtgui_chooser_0_combo_box)
        for label in self._variable_qtgui_chooser_0_labels: self._variable_qtgui_chooser_0_combo_box.addItem(label)
        self._variable_qtgui_chooser_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_options.index(i)))
        self._variable_qtgui_chooser_0_callback(self.variable_qtgui_chooser_0)
        self._variable_qtgui_chooser_0_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_variable_qtgui_chooser_0(self._variable_qtgui_chooser_0_options[i]))
        self.top_grid_layout.addWidget(self._variable_qtgui_chooser_0_tool_bar, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        _samplenholdcheck_check_box = Qt.QCheckBox('Sample and Hold')
        self._samplenholdcheck_choices = {True: True, False: False}
        self._samplenholdcheck_choices_inv = dict((v,k) for k,v in self._samplenholdcheck_choices.iteritems())
        self._samplenholdcheck_callback = lambda i: Qt.QMetaObject.invokeMethod(_samplenholdcheck_check_box, "setChecked", Qt.Q_ARG("bool", self._samplenholdcheck_choices_inv[i]))
        self._samplenholdcheck_callback(self.samplenholdcheck)
        _samplenholdcheck_check_box.stateChanged.connect(lambda i: self.set_samplenholdcheck(self._samplenholdcheck_choices[bool(i)]))
        self.top_grid_layout.addWidget(_samplenholdcheck_check_box, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._m_range = Range(0, 1, 0.05, 0.5, 200)
        self._m_win = RangeWidget(self._m_range, self.set_m, 'Modulation coefficient', "counter", float)
        self.top_grid_layout.addWidget(self._m_win, 5, 4, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        _llaveAnalcheck_check_box = Qt.QCheckBox('Analog Switch')
        self._llaveAnalcheck_choices = {True: True, False: False}
        self._llaveAnalcheck_choices_inv = dict((v,k) for k,v in self._llaveAnalcheck_choices.iteritems())
        self._llaveAnalcheck_callback = lambda i: Qt.QMetaObject.invokeMethod(_llaveAnalcheck_check_box, "setChecked", Qt.Q_ARG("bool", self._llaveAnalcheck_choices_inv[i]))
        self._llaveAnalcheck_callback(self.llaveAnalcheck)
        _llaveAnalcheck_check_box.stateChanged.connect(lambda i: self.set_llaveAnalcheck(self._llaveAnalcheck_choices[bool(i)]))
        self.top_grid_layout.addWidget(_llaveAnalcheck_check_box, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fportadora_range = Range(500, 3000, 100, 3000, 200)
        self._fportadora_win = RangeWidget(self._fportadora_range, self.set_fportadora, 'Carrier frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._fportadora_win, 4, 4, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fmoduladora_range = Range(1, 500, 10, 300, 200)
        self._fmoduladora_win = RangeWidget(self._fmoduladora_range, self.set_fmoduladora, 'Modulator frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._fmoduladora_win, 3, 4, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        _faacheck_check_box = Qt.QCheckBox('Anti-Alias Filter')
        self._faacheck_choices = {True: True, False: False}
        self._faacheck_choices_inv = dict((v,k) for k,v in self._faacheck_choices.iteritems())
        self._faacheck_callback = lambda i: Qt.QMetaObject.invokeMethod(_faacheck_check_box, "setChecked", Qt.Q_ARG("bool", self._faacheck_choices_inv[i]))
        self._faacheck_callback(self.faacheck)
        _faacheck_check_box.stateChanged.connect(lambda i: self.set_faacheck(self._faacheck_choices[bool(i)]))
        self.top_grid_layout.addWidget(_faacheck_check_box, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._dutycycle_range = Range(0.05, 0.95, 0.05, 0.5, 50)
        self._dutycycle_win = RangeWidget(self._dutycycle_range, self.set_dutycycle, 'Duty cycle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._dutycycle_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._UIF_range = Range(100, 20000, 10, 1500, 200)
        self._UIF_win = RangeWidget(self._UIF_range, self.set_UIF, 'Frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._UIF_win, 3, 1, 2, 3)
        for r in range(3, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._SR_range = Range(100, 50000, 100, 20000, 200)
        self._SR_win = RangeWidget(self._SR_range, self.set_SR, 'Sample Rate', "counter_slider", float)
        self.top_grid_layout.addWidget(self._SR_win, 1, 1, 2, 3)
        for r in range(1, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        _FR_check_box = Qt.QCheckBox('Recover Filter')
        self._FR_choices = {True: True, False: False}
        self._FR_choices_inv = dict((v,k) for k,v in self._FR_choices.iteritems())
        self._FR_callback = lambda i: Qt.QMetaObject.invokeMethod(_FR_check_box, "setChecked", Qt.Q_ARG("bool", self._FR_choices_inv[i]))
        self._FR_callback(self.FR)
        _FR_check_box.stateChanged.connect(lambda i: self.set_FR(self._FR_choices[bool(i)]))
        self.top_grid_layout.addWidget(_FR_check_box, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._AMPLITUD_range = Range(1, 15, 1, 1, 200)
        self._AMPLITUD_win = RangeWidget(self._AMPLITUD_range, self.set_AMPLITUD, 'Amplitude', "counter", float)
        self.top_grid_layout.addWidget(self._AMPLITUD_win, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.sen32 = blocks.wavfile_source('sen32.wav', True)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	5 #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, False)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        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(True)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Input', 'AAF', 'Sample and Hold', 'Analog Switch', 'RF',
                  'poronga', 'Poronga Char', '', '', '']
        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(5):
            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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 6, 0, 1, 4)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	5 #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(True)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['Input', 'AAF', 'Sample and Hold', 'Analog Switch', 'FR',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "black", "magenta", "dark red",
                  "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(5):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 8, 0, 1, 4)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate, fp, 2500, firdes.WIN_HAMMING, 6.76))
        self.filtro_antialiasing = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate, fp, 2500, firdes.WIN_HAMMING, 6.76))
        self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1-dutycycle, 1-dutycycle, 0)
        self.blocks_sample_and_hold_xx_0 = blocks.sample_and_hold_ff()
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((AMPLITUD, ))
        self.blocks_multiply_const_vxx_0_1_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((m/2, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((m/2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_float_to_char_0_2 = blocks.float_to_char(1, 1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.blks2_selector_0_1_0_0_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=FR,
        	output_index=0,
        )
        self.blks2_selector_0_1_0_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=llaveAnalcheck,
        	output_index=0,
        )
        self.blks2_selector_0_1_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=samplenholdcheck,
        	output_index=0,
        )
        self.blks2_selector_0_1_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=faacheck,
        	output_index=0,
        )
        self.blks2_selector_0_1 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=4,
        	num_outputs=1,
        	input_index=variable_qtgui_chooser_0,
        	output_index=0,
        )
        self.analog_sig_source_x_0_2_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, fportadora-fmoduladora, AMPLITUD, 0)
        self.analog_sig_source_x_0_2_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, fportadora + fmoduladora, AMPLITUD, 0)
        self.analog_sig_source_x_0_2 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, fportadora, AMPLITUD, 0)
        self.analog_sig_source_x_0_0_0_0 = analog.sig_source_f(samp_rate, analog.GR_SAW_WAVE, SR, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_TRI_WAVE, UIF, AMPLITUD, -AMPLITUD/2)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, UIF, AMPLITUD, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blks2_selector_0_1, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_2_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_sig_source_x_0_2_1, 0), (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.blks2_selector_0_1, 0), (self.blks2_selector_0_1_0, 0))
        self.connect((self.blks2_selector_0_1, 0), (self.filtro_antialiasing, 0))
        self.connect((self.blks2_selector_0_1, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blks2_selector_0_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blks2_selector_0_1_0, 0), (self.blocks_throttle_0_0, 0))
        self.connect((self.blks2_selector_0_1_0_0, 0), (self.blks2_selector_0_1_0_0_0, 0))
        self.connect((self.blks2_selector_0_1_0_0, 0), (self.blocks_throttle_0_0_0, 0))
        self.connect((self.blks2_selector_0_1_0_0_0, 0), (self.blks2_selector_0_1_0_0_0_0, 0))
        self.connect((self.blks2_selector_0_1_0_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blks2_selector_0_1_0_0_0, 0), (self.qtgui_freq_sink_x_0, 3))
        self.connect((self.blks2_selector_0_1_0_0_0, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blks2_selector_0_1_0_0_0_0, 0), (self.qtgui_freq_sink_x_0, 4))
        self.connect((self.blks2_selector_0_1_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 4))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_char_0_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blks2_selector_0_1, 3))
        self.connect((self.blocks_float_to_char_0_2, 0), (self.blocks_sample_and_hold_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0_1, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_1_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blks2_selector_0_1, 2))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blks2_selector_0_1_0_0_0, 1))
        self.connect((self.blocks_sample_and_hold_xx_0, 0), (self.blks2_selector_0_1_0_0, 1))
        self.connect((self.blocks_sample_and_hold_xx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_multiply_const_vxx_0_1_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.filtro_antialiasing, 0), (self.blks2_selector_0_1_0, 1))
        self.connect((self.filtro_antialiasing, 0), (self.blks2_selector_0_1_0_0, 0))
        self.connect((self.filtro_antialiasing, 0), (self.blocks_sample_and_hold_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_0_1_0_0_0_0, 1))
        self.connect((self.sen32, 0), (self.blocks_multiply_const_vxx_0_2, 0))
Ejemplo n.º 17
0
    def __init__(self, fft_length, cp_length, snr, kstime, logging):
        ''' Maximum Likelihood OFDM synchronizer:
        J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation
        of Time and Frequency Offset in OFDM Systems," IEEE Trans.
        Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997.
        '''

        gr.hier_block2.__init__(self, "ofdm_sync_ml",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature

        self.input = blocks.add_const_cc(0)

        SNR = 10.0**(snr / 10.0)
        rho = SNR / (SNR + 1.0)
        symbol_length = fft_length + cp_length

        # ML Sync

        # Energy Detection from ML Sync

        self.connect(self, self.input)

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length)
        self.connect(self.input, self.delay)

        # magnitude squared blocks
        self.magsqrd1 = blocks.complex_to_mag_squared()
        self.magsqrd2 = blocks.complex_to_mag_squared()
        self.adder = blocks.add_ff()

        moving_sum_taps = [rho / 2 for i in range(cp_length)]
        self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps)

        self.connect(self.input,self.magsqrd1)
        self.connect(self.delay,self.magsqrd2)
        self.connect(self.magsqrd1,(self.adder,0))
        self.connect(self.magsqrd2,(self.adder,1))
        self.connect(self.adder,self.moving_sum_filter)


        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc();
        self.mixer = blocks.multiply_cc();

        movingsum2_taps = [1.0 for i in range(cp_length)]
        self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps)

        # Correlator data handler
        self.c2mag = blocks.complex_to_mag()
        self.angle = blocks.complex_to_arg()
        self.connect(self.input,(self.mixer,1))
        self.connect(self.delay,self.conjg,(self.mixer,0))
        self.connect(self.mixer,self.movingsum2,self.c2mag)
        self.connect(self.movingsum2,self.angle)

        # ML Sync output arg, need to find maximum point of this
        self.diff = blocks.sub_ff()
        self.connect(self.c2mag,(self.diff,0))
        self.connect(self.moving_sum_filter,(self.diff,1))

        #ML measurements input to sampler block and detect
        self.f2c = blocks.float_to_complex()
        self.pk_detect = blocks.peak_detector_fb(0.2, 0.25, 30, 0.0005)
        self.sample_and_hold = blocks.sample_and_hold_ff()

        # use the sync loop values to set the sampler and the NCO
        #     self.diff = theta
        #     self.angle = epsilon

        self.connect(self.diff, self.pk_detect)

        # The DPLL corrects for timing differences between CP correlations
        use_dpll = 0
        if use_dpll:
            self.dpll = gr.dpll_bb(float(symbol_length),0.01)
            self.connect(self.pk_detect, self.dpll)
            self.connect(self.dpll, (self.sample_and_hold,1))
        else:
            self.connect(self.pk_detect, (self.sample_and_hold,1))

        self.connect(self.angle, (self.sample_and_hold,0))

        ################################
        # correlate against known symbol
        # This gives us the same timing signal as the PN sync block only on the preamble
        # we don't use the signal generated from the CP correlation because we don't want
        # to readjust the timing in the middle of the packet or we ruin the equalizer settings.
        kstime = [k.conjugate() for k in kstime]
        kstime.reverse()
        self.kscorr = filter.fir_filter_ccc(1, kstime)
        self.corrmag = blocks.complex_to_mag_squared()
        self.div = blocks.divide_ff()

        # The output signature of the correlation has a few spikes because the rest of the
        # system uses the repeated preamble symbol. It needs to work that generically if
        # anyone wants to use this against a WiMAX-like signal since it, too, repeats.
        # The output theta of the correlator above is multiplied with this correlation to
        # identify the proper peak and remove other products in this cross-correlation
        self.threshold_factor = 0.1
        self.slice = blocks.threshold_ff(self.threshold_factor, self.threshold_factor, 0)
        self.f2b = blocks.float_to_char()
        self.b2f = blocks.char_to_float()
        self.mul = blocks.multiply_ff()

        # Normalize the power of the corr output by the energy. This is not really needed
        # and could be removed for performance, but it makes for a cleaner signal.
        # if this is removed, the threshold value needs adjustment.
        self.connect(self.input, self.kscorr, self.corrmag, (self.div,0))
        self.connect(self.moving_sum_filter, (self.div,1))

        self.connect(self.div, (self.mul,0))
        self.connect(self.pk_detect, self.b2f, (self.mul,1))
        self.connect(self.mul, self.slice)

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self,0))
        self.connect(self.slice, self.f2b, (self,1))


        if logging:
            self.connect(self.moving_sum_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat"))
            self.connect(self.diff, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat"))
            self.connect(self.corrmag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat"))
            self.connect(self.kscorr, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat"))
            self.connect(self.div, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat"))
            self.connect(self.mul, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat"))
            self.connect(self.slice, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat"))
            self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat"))
            if use_dpll:
                self.connect(self.dpll, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat"))

            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat"))
Ejemplo n.º 18
0
    def __init__(self, fft_length, cp_length, snr, kstime, logging):
        ''' Maximum Likelihood OFDM synchronizer:
        J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation
        of Time and Frequency Offset in OFDM Systems," IEEE Trans.
        Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997.
        '''

        gr.hier_block2.__init__(
            self,
            "ofdm_sync_ml",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature2(2, 2, gr.sizeof_float,
                             gr.sizeof_char))  # Output signature

        self.input = blocks.add_const_cc(0)

        SNR = 10.0**(snr / 10.0)
        rho = SNR / (SNR + 1.0)
        symbol_length = fft_length + cp_length

        # ML Sync

        # Energy Detection from ML Sync

        self.connect(self, self.input)

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length)
        self.connect(self.input, self.delay)

        # magnitude squared blocks
        self.magsqrd1 = blocks.complex_to_mag_squared()
        self.magsqrd2 = blocks.complex_to_mag_squared()
        self.adder = blocks.add_ff()

        moving_sum_taps = [rho / 2 for i in range(cp_length)]
        self.moving_sum_filter = filter.fir_filter_fff(1, moving_sum_taps)

        self.connect(self.input, self.magsqrd1)
        self.connect(self.delay, self.magsqrd2)
        self.connect(self.magsqrd1, (self.adder, 0))
        self.connect(self.magsqrd2, (self.adder, 1))
        self.connect(self.adder, self.moving_sum_filter)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc()
        self.mixer = blocks.multiply_cc()

        movingsum2_taps = [1.0 for i in range(cp_length)]
        self.movingsum2 = filter.fir_filter_ccf(1, movingsum2_taps)

        # Correlator data handler
        self.c2mag = blocks.complex_to_mag()
        self.angle = blocks.complex_to_arg()
        self.connect(self.input, (self.mixer, 1))
        self.connect(self.delay, self.conjg, (self.mixer, 0))
        self.connect(self.mixer, self.movingsum2, self.c2mag)
        self.connect(self.movingsum2, self.angle)

        # ML Sync output arg, need to find maximum point of this
        self.diff = blocks.sub_ff()
        self.connect(self.c2mag, (self.diff, 0))
        self.connect(self.moving_sum_filter, (self.diff, 1))

        #ML measurements input to sampler block and detect
        self.f2c = blocks.float_to_complex()
        self.pk_detect = blocks.peak_detector_fb(0.2, 0.25, 30, 0.0005)
        self.sample_and_hold = blocks.sample_and_hold_ff()

        # use the sync loop values to set the sampler and the NCO
        #     self.diff = theta
        #     self.angle = epsilon

        self.connect(self.diff, self.pk_detect)

        # The DPLL corrects for timing differences between CP correlations
        use_dpll = 0
        if use_dpll:
            self.dpll = gr.dpll_bb(float(symbol_length), 0.01)
            self.connect(self.pk_detect, self.dpll)
            self.connect(self.dpll, (self.sample_and_hold, 1))
        else:
            self.connect(self.pk_detect, (self.sample_and_hold, 1))

        self.connect(self.angle, (self.sample_and_hold, 0))

        ################################
        # correlate against known symbol
        # This gives us the same timing signal as the PN sync block only on the preamble
        # we don't use the signal generated from the CP correlation because we don't want
        # to readjust the timing in the middle of the packet or we ruin the equalizer settings.
        kstime = [k.conjugate() for k in kstime]
        kstime.reverse()
        self.kscorr = filter.fir_filter_ccc(1, kstime)
        self.corrmag = blocks.complex_to_mag_squared()
        self.div = blocks.divide_ff()

        # The output signature of the correlation has a few spikes because the rest of the
        # system uses the repeated preamble symbol. It needs to work that generically if
        # anyone wants to use this against a WiMAX-like signal since it, too, repeats.
        # The output theta of the correlator above is multiplied with this correlation to
        # identify the proper peak and remove other products in this cross-correlation
        self.threshold_factor = 0.1
        self.slice = blocks.threshold_ff(self.threshold_factor,
                                         self.threshold_factor, 0)
        self.f2b = blocks.float_to_char()
        self.b2f = blocks.char_to_float()
        self.mul = blocks.multiply_ff()

        # Normalize the power of the corr output by the energy. This is not really needed
        # and could be removed for performance, but it makes for a cleaner signal.
        # if this is removed, the threshold value needs adjustment.
        self.connect(self.input, self.kscorr, self.corrmag, (self.div, 0))
        self.connect(self.moving_sum_filter, (self.div, 1))

        self.connect(self.div, (self.mul, 0))
        self.connect(self.pk_detect, self.b2f, (self.mul, 1))
        self.connect(self.mul, self.slice)

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self, 0))
        self.connect(self.slice, self.f2b, (self, 1))

        if logging:
            self.connect(
                self.moving_sum_filter,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat"))
            self.connect(
                self.diff,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat"))
            self.connect(
                self.angle,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_ml-epsilon_f.dat"))
            self.connect(
                self.corrmag,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_ml-corrmag_f.dat"))
            self.connect(
                self.kscorr,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_ml-kscorr_c.dat"))
            self.connect(
                self.div,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat"))
            self.connect(
                self.mul,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat"))
            self.connect(
                self.slice,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat"))
            self.connect(
                self.pk_detect,
                blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat"))
            if use_dpll:
                self.connect(
                    self.dpll,
                    blocks.file_sink(gr.sizeof_char,
                                     "ofdm_sync_ml-dpll_b.dat"))

            self.connect(
                self.sample_and_hold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_ml-sample_and_hold_f.dat"))
            self.connect(
                self.input,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_ml-input_c.dat"))
Ejemplo n.º 19
0
    def __init__(self, fft_length, cp_length, kstime, overrate, logging=True):
        """
        OFDM synchronization using PN Correlation:
        T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing
        Synchonization for OFDM," IEEE Trans. Communications, vol. 45,
        no. 12, 1997.
        """

        gr.hier_block2.__init__(
            self,
            "ofdm_sync_pn",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature2(2, 2, gr.sizeof_float,
                             gr.sizeof_char))  # Output signature

        self.input = blocks.add_const_cc(0)

        # cross-correlate with the known symbol
        kstime = [k.conjugate() for k in kstime]
        kstime.reverse()
        self.crosscorr_filter = filter.fir_filter_ccc(1, kstime)

        # PN Sync
        self.corrmag = blocks.complex_to_mag_squared()
        self.delay = blocks.delay(gr.sizeof_gr_complex,
                                  fft_length * overrate / 2)

        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc()
        self.corr = blocks.multiply_cc()

        #self.sub = blocks.add_const_ff(-1)
        self.pk_detect = blocks.peak_detector_fb(0.40, 0.25,
                                                 fft_length * overrate,
                                                 0.00000000000)

        self.connect(self, self.input)
        self.connect(self.input, self.crosscorr_filter)
        self.connect(self.crosscorr_filter, self.corrmag)

        #self.inputmag = blocks.complex_to_mag_squared()
        #self.normalize = blocks.divide_ff()
        #self.inputmovingsum = filter.fir_filter_fff(1, [1.0] * (fft_length//2))
        self.square = blocks.multiply_ff()

        #self.connect(self.input,self.inputmag,self.inputmovingsum)
        self.connect(self.corrmag, (self.square, 0))
        self.connect(self.corrmag, (self.square, 1))
        self.dsquare = blocks.multiply_ff()
        self.connect(self.square, (self.dsquare, 0))
        self.connect(self.square, (self.dsquare, 1))
        self.connect(self.dsquare, self.pk_detect)

        # Create a moving sum filter for the corr output
        self.moving_sum_filter = filter.fir_filter_ccf(
            1, [1.0] * (fft_length * overrate // 2))

        # Get magnitude (peaks) and angle (phase/freq error)
        self.angle = blocks.complex_to_arg()

        self.sample_and_hold = blocks.sample_and_hold_ff()

        # Calculate the frequency offset from the correlation of the preamble
        self.connect(self.input, self.delay)
        self.connect(self.input, (self.corr, 0))
        self.connect(self.delay, self.conjg)
        self.connect(self.conjg, (self.corr, 1))
        self.connect(self.corr, self.moving_sum_filter)
        self.connect(self.moving_sum_filter, self.angle)
        self.connect(self.angle, (self.sample_and_hold, 0))
        self.connect(self.pk_detect, (self.sample_and_hold, 1))

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self, 0))
        self.connect(self.pk_detect, (self, 1))

        if logging:
            self.connect(
                self.dsquare,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-dsquare.dat"))
            self.connect(
                self.corrmag,
                blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-corrmag.dat"))
            self.connect(
                self.angle,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-epsilon_f.dat"))
            self.connect(
                self.pk_detect,
                blocks.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
            self.connect(
                self.sample_and_hold,
                blocks.file_sink(gr.sizeof_float,
                                 "ofdm_sync_pn-sample_and_hold_f.dat"))
            self.connect(
                self.input,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 "ofdm_sync_pn-input_c.dat"))
Ejemplo n.º 20
0
    def __init__(self):
        gr.top_block.__init__(self, "Adxl345 Sound Effect Attempt 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adxl345 Sound Effect Attempt 1")
        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", "adxl345_sound_effect_attempt_1")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.variable_0 = variable_0 = 0
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1028, #size
            samp_rate, #samp_rate
            "Audio", #name
            2 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.250)
        self.qtgui_time_sink_x_0_0.set_y_axis(-2, 2)

        self.qtgui_time_sink_x_0_0.set_y_label("Acceleration", "g")

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(True)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)


        labels = ['X Accel', 'Y Accel', 'Z Accel', '', '',
            '', '', '', '', '']
        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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.iio_attr_source_0_0 = iio.attr_source("local:", "adxl345", "accel_y", "raw", 10, 32, 1, 0, False, int("0x123",0), False)
        self.blocks_vco_f_0_0 = blocks.vco_f(samp_rate, 50, 1)
        self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 50, 1)
        self.blocks_sample_and_hold_xx_0 = blocks.sample_and_hold_ff()
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_b(100, analog.GR_SQR_WAVE, 10, 1, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_sample_and_hold_xx_0, 1))
        self.connect((self.blocks_sample_and_hold_xx_0, 0), (self.blocks_vco_f_0, 0))
        self.connect((self.blocks_sample_and_hold_xx_0, 0), (self.blocks_vco_f_0_0, 0))
        self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_vco_f_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_vco_f_0_0, 0), (self.audio_sink_0, 1))
        self.connect((self.blocks_vco_f_0_0, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.iio_attr_source_0_0, 0), (self.blocks_sample_and_hold_xx_0, 0))