Example #1
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Test Split Cc")

        ##################################################
        # Variables
        ##################################################
        self.samp_up = samp_up = 512
        self.samp_rate = samp_rate = 1024
        self.samp_down = samp_down = 512
        self.samp_cw = samp_cw = 1024

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc(
            (10, ), (5, ), (1e12, ), (0, ), (0, ), samp_rate, 2.4e9, -10, True,
            True, "packet_len")
        self.radar_split_cc_0_1 = radar.split_cc(
            2, ((samp_cw, samp_up, samp_down)), "packet_len")
        self.radar_split_cc_0_0 = radar.split_cc(
            1, ((samp_cw, samp_up, samp_down)), "packet_len")
        self.radar_split_cc_0 = radar.split_cc(0,
                                               ((samp_cw, samp_up, samp_down)),
                                               "packet_len")
        self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c(
            samp_rate, samp_up, samp_down, samp_cw, 0, 250, 1, "packet_len")
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.radar_split_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.radar_split_cc_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.radar_split_cc_0_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.radar_static_target_simulator_cc_0, 0))
        self.connect((self.radar_split_cc_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.radar_split_cc_0_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.radar_split_cc_0_1, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.radar_static_target_simulator_cc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Usrp Echotimer Fmcw")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Usrp Echotimer Fmcw")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "usrp_echotimer_fmcw")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_up = samp_up = 1250000 / 4
        self.samp_rate = samp_rate = 5000000
        self.sweep_freq = sweep_freq = samp_rate / 2
        self.samp_down = samp_down = samp_up
        self.samp_cw = samp_cw = 1250000
        self.center_freq = center_freq = 2.4e9
        self.wait_to_start = wait_to_start = 0.05
        self.v_res_m_s = v_res_m_s = samp_rate / samp_cw * 3e8 / 2 / center_freq
        self.tx_gain = tx_gain = 55
        self.threshold = threshold = -150
        self.rx_gain = rx_gain = 55
        self.range_res_m = range_res_m = 3e8 / 2 / sweep_freq
        self.protect_samp = protect_samp = 0
        self.min_output_buffer = min_output_buffer = int(
            (samp_up + samp_down + samp_cw) * 2)
        self.meas_duration = meas_duration = (samp_cw + samp_up +
                                              samp_down) / float(samp_rate)
        self.max_output_buffer = max_output_buffer = 0
        self.freq_res_up = freq_res_up = samp_rate / samp_up
        self.freq_res_cw = freq_res_cw = samp_rate / samp_cw
        self.delay_samp = delay_samp = 61
        self.decim_fac = decim_fac = 5**4
        self.b210 = b210 = "A:B"

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 70, 1, 55, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 0, 0)
        self._threshold_range = Range(-200, 0, 1, -150, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, "threshold",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win, 1, 0)
        self._rx_gain_range = Range(0, 70, 1, 55, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 0, 1)
        self._protect_samp_range = Range(0, 100, 1, 0, 200)
        self._protect_samp_win = RangeWidget(self._protect_samp_range,
                                             self.set_protect_samp,
                                             "protect_samp", "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._protect_samp_win, 1, 1)
        self._delay_samp_range = Range(0, 100, 1, 61, 200)
        self._delay_samp_win = RangeWidget(self._delay_samp_range,
                                           self.set_delay_samp,
                                           'Number delay samples',
                                           "counter_slider", float)
        self.top_layout.addWidget(self._delay_samp_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim_fac,
            taps=None,
            fractional_bw=None,
        )
        self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc(
            samp_rate, center_freq, int(delay_samp), '', '', 'internal',
            'none', 'TX/RX', tx_gain, 0.1, wait_to_start, 0, '', '',
            'internal', 'none', 'RX2', rx_gain, 0.1, wait_to_start, 0,
            "packet_len")
        (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(3750000)
        self.radar_ts_fft_cc_2 = radar.ts_fft_cc(samp_down / decim_fac,
                                                 "packet_len")
        self.radar_ts_fft_cc_1 = radar.ts_fft_cc(samp_up / decim_fac,
                                                 "packet_len")
        self.radar_ts_fft_cc_0 = radar.ts_fft_cc(samp_cw / decim_fac,
                                                 "packet_len")
        self.radar_tracking_singletarget_0 = radar.tracking_singletarget(
            500, 1, v_res_m_s, 0.01, 0.001, 1, "kalman")
        self.radar_split_cc_0_0_0 = radar.split_cc(
            2, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0_0).set_min_output_buffer(3750000)
        self.radar_split_cc_0_0 = radar.split_cc(
            1, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0).set_min_output_buffer(3750000)
        self.radar_split_cc_0 = radar.split_cc(
            0, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0).set_min_output_buffer(3750000)
        self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c(
            samp_rate, samp_up, samp_down, samp_cw, -(sweep_freq) / 2,
            sweep_freq, 0.5, "packet_len")
        (self.radar_signal_generator_fmcw_c_0).set_min_output_buffer(3750000)
        self.radar_qtgui_time_plot_0_0 = radar.qtgui_time_plot(
            100, "velocity", (-2, 2), 60, "TRACKING")
        self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot(
            100, "range", (0, 20), 60, "TRACKING")
        self.radar_print_results_0 = radar.print_results(False, "")
        self.radar_find_max_peak_c_0_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, int(protect_samp), (), False,
            "packet_len")
        (self.radar_find_max_peak_c_0_0_0).set_min_output_buffer(3750000)
        self.radar_find_max_peak_c_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, int(protect_samp), (), False,
            "packet_len")
        (self.radar_find_max_peak_c_0_0).set_min_output_buffer(3750000)
        self.radar_find_max_peak_c_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, int(protect_samp), (), False,
            "packet_len")
        (self.radar_find_max_peak_c_0).set_min_output_buffer(3750000)
        self.radar_estimator_fmcw_0 = radar.estimator_fmcw(
            samp_rate / decim_fac, center_freq, sweep_freq,
            samp_up / decim_fac, samp_down / decim_fac, False)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(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(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_sink_x_0_0_0 = qtgui.sink_c(
            samp_up / decim_fac,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim_fac,  #bw
            'DOWN',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_0_win)

        self.qtgui_sink_x_0_0_0.enable_rf_freq(False)

        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            samp_up / decim_fac,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim_fac,  #bw
            'UP',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            samp_cw / decim_fac,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim_fac,  #bw
            "CW",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decim_fac)
        (self.blocks_tagged_stream_multiply_length_0
         ).set_min_output_buffer(3750000)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(3750000)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.radar_estimator_fmcw_0, 'Msg out'),
                         (self.radar_print_results_0, 'Msg in'))
        self.msg_connect((self.radar_estimator_fmcw_0, 'Msg out'),
                         (self.radar_tracking_singletarget_0, 'Msg in'))
        self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in CW'))
        self.msg_connect((self.radar_find_max_peak_c_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in UP'))
        self.msg_connect((self.radar_find_max_peak_c_0_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in DOWN'))
        self.msg_connect((self.radar_tracking_singletarget_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0, 'Msg in'))
        self.msg_connect((self.radar_tracking_singletarget_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0_0, 'Msg in'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.radar_usrp_echotimer_cc_0, 0))
        self.connect((self.radar_split_cc_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.radar_split_cc_0, 0), (self.radar_ts_fft_cc_0, 0))
        self.connect((self.radar_split_cc_0_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.radar_split_cc_0_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.radar_split_cc_0_0, 0), (self.radar_ts_fft_cc_1, 0))
        self.connect((self.radar_split_cc_0_0_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.radar_split_cc_0_0_0, 0),
                     (self.radar_ts_fft_cc_2, 0))
        self.connect((self.radar_ts_fft_cc_0, 0),
                     (self.radar_find_max_peak_c_0, 0))
        self.connect((self.radar_ts_fft_cc_1, 0),
                     (self.radar_find_max_peak_c_0_0, 0))
        self.connect((self.radar_ts_fft_cc_2, 0),
                     (self.radar_find_max_peak_c_0_0_0, 0))
        self.connect((self.radar_usrp_echotimer_cc_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
Example #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Simulator Fmcw Rcs")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simulator Fmcw Rcs")
        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", "simulator_fmcw_rcs")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_up = samp_up = 2**14
        self.samp_rate = samp_rate = 10000000
        self.sweep_freq = sweep_freq = samp_rate / 2
        self.samp_down = samp_down = samp_up
        self.samp_cw = samp_cw = 2**14
        self.center_freq = center_freq = 5.9e9
        self.velocity = velocity = 30
        self.value_range = value_range = 200
        self.v_res = v_res = samp_rate / samp_cw * 3e8 / 2 / center_freq
        self.threshold = threshold = -200
        self.rcs = rcs = 10
        self.range_res = range_res = 3e8 / 2 / sweep_freq
        self.protect_samp = protect_samp = 1
        self.min_output_buffer = min_output_buffer = int(
            (samp_up + samp_down + samp_cw) * 2)
        self.meas_duration = meas_duration = (samp_cw + samp_up +
                                              samp_down) / float(samp_rate)
        self.max_output_buffer = max_output_buffer = 0
        self.decim_fac = decim_fac = 2**5

        ##################################################
        # Blocks
        ##################################################
        self._velocity_range = Range(0, 100, 1, 30, 200)
        self._velocity_win = RangeWidget(self._velocity_range,
                                         self.set_velocity, "velocity",
                                         "counter_slider", float)
        self.top_layout.addWidget(self._velocity_win)
        self._value_range_range = Range(0, 1000, 1, 200, 200)
        self._value_range_win = RangeWidget(self._value_range_range,
                                            self.set_value_range, "range",
                                            "counter_slider", float)
        self.top_layout.addWidget(self._value_range_win)
        self._threshold_range = Range(-200, 0, 1, -200, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, "threshold",
                                          "counter_slider", float)
        self.top_layout.addWidget(self._threshold_win)
        self._rcs_range = Range(1, 100, 1, 10, 200)
        self._rcs_win = RangeWidget(self._rcs_range, self.set_rcs, "rcs",
                                    "counter_slider", float)
        self.top_layout.addWidget(self._rcs_win)
        self._protect_samp_range = Range(0, 100, 1, 1, 200)
        self._protect_samp_win = RangeWidget(self._protect_samp_range,
                                             self.set_protect_samp,
                                             "protect_samp", "counter_slider",
                                             float)
        self.top_layout.addWidget(self._protect_samp_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim_fac,
            taps=None,
            fractional_bw=None,
        )
        self.radar_ts_fft_cc_0_1 = radar.ts_fft_cc(samp_down / decim_fac,
                                                   "packet_len")
        self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(samp_up / decim_fac,
                                                   "packet_len")
        self.radar_ts_fft_cc_0 = radar.ts_fft_cc(samp_cw / decim_fac,
                                                 "packet_len")
        self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc(
            (value_range, ), (velocity, ), (rcs, ), (0, ), (0, ), samp_rate,
            center_freq, -10, True, True, "packet_len")
        (self.radar_static_target_simulator_cc_0).set_min_output_buffer(98304)
        self.radar_split_cc_0_0_0 = radar.split_cc(
            2, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0_0).set_min_output_buffer(98304)
        self.radar_split_cc_0_0 = radar.split_cc(
            1, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0).set_min_output_buffer(98304)
        self.radar_split_cc_0 = radar.split_cc(
            0, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0).set_min_output_buffer(98304)
        self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c(
            samp_rate, samp_up, samp_down, samp_cw, -sweep_freq / 2,
            sweep_freq, 1, "packet_len")
        (self.radar_signal_generator_fmcw_c_0).set_min_output_buffer(98304)
        self.radar_print_results_0 = radar.print_results(False, "")
        self.radar_find_max_peak_c_0_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_find_max_peak_c_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_find_max_peak_c_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_estimator_rcs_0 = radar.estimator_rcs(
            10, center_freq, 0, 0, 0, 1, 0.85, 1)
        self.radar_estimator_fmcw_0 = radar.estimator_fmcw(
            samp_rate / decim_fac, center_freq, sweep_freq,
            samp_up / decim_fac, samp_down / decim_fac, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        (self.blocks_throttle_0).set_min_output_buffer(98304)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decim_fac)
        (self.blocks_tagged_stream_multiply_length_0
         ).set_min_output_buffer(98304)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(
            (1.0 / (samp_down / decim_fac), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (1.0 / (samp_up / decim_fac), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (1.0 / (samp_cw / decim_fac), ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(98304)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        (self.blocks_add_xx_0).set_min_output_buffer(98304)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 10e-9, 0)
        (self.analog_noise_source_x_0).set_min_output_buffer(98304)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.radar_estimator_fmcw_0, 'Msg out'),
                         (self.radar_estimator_rcs_0, 'Msg in'))
        self.msg_connect((self.radar_estimator_rcs_0, 'Msg out'),
                         (self.radar_print_results_0, 'Msg in'))
        self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in CW'))
        self.msg_connect((self.radar_find_max_peak_c_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in UP'))
        self.msg_connect((self.radar_find_max_peak_c_0_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in DOWN'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.radar_find_max_peak_c_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.radar_find_max_peak_c_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.radar_find_max_peak_c_0_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.radar_static_target_simulator_cc_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.radar_split_cc_0, 0), (self.radar_ts_fft_cc_0, 0))
        self.connect((self.radar_split_cc_0_0, 0),
                     (self.radar_ts_fft_cc_0_0, 0))
        self.connect((self.radar_split_cc_0_0_0, 0),
                     (self.radar_ts_fft_cc_0_1, 0))
        self.connect((self.radar_static_target_simulator_cc_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.radar_ts_fft_cc_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.radar_ts_fft_cc_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.radar_ts_fft_cc_0_1, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
Example #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Simulator Fmcw")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simulator Fmcw")
        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", "simulator_fmcw")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_up = samp_up = 2**14
        self.samp_rate = samp_rate = 20000000
        self.sweep_freq = sweep_freq = samp_rate / 2
        self.samp_down = samp_down = samp_up
        self.samp_cw = samp_cw = 2**14
        self.center_freq = center_freq = 5.9e9
        self.velocity = velocity = 50
        self.value_range = value_range = 200
        self.v_res = v_res = samp_rate / samp_cw * 3e8 / 2 / center_freq
        self.threshold = threshold = -120
        self.range_res = range_res = 3e8 / 2 / sweep_freq
        self.protect_samp = protect_samp = 1
        self.min_output_buffer = min_output_buffer = int(
            (samp_up + samp_down + samp_cw) * 2)
        self.meas_duration = meas_duration = (samp_cw + samp_up +
                                              samp_down) / float(samp_rate)
        self.max_output_buffer = max_output_buffer = 0
        self.decim_fac = decim_fac = 2**5

        ##################################################
        # Blocks
        ##################################################
        self._velocity_range = Range(0, 100, 1, 50, 200)
        self._velocity_win = RangeWidget(self._velocity_range,
                                         self.set_velocity, "velocity",
                                         "counter_slider", float)
        self.top_layout.addWidget(self._velocity_win)
        self._value_range_range = Range(0, 1000, 1, 200, 200)
        self._value_range_win = RangeWidget(self._value_range_range,
                                            self.set_value_range, 'range',
                                            "counter_slider", float)
        self.top_layout.addWidget(self._value_range_win)
        self._threshold_range = Range(-120, 0, 1, -120, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, "threshold",
                                          "counter_slider", float)
        self.top_layout.addWidget(self._threshold_win)
        self._protect_samp_range = Range(0, 100, 1, 1, 200)
        self._protect_samp_win = RangeWidget(self._protect_samp_range,
                                             self.set_protect_samp,
                                             "protect_samp", "counter_slider",
                                             float)
        self.top_layout.addWidget(self._protect_samp_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim_fac,
            taps=None,
            fractional_bw=None,
        )
        self.radar_ts_fft_cc_0_1 = radar.ts_fft_cc(samp_down / decim_fac,
                                                   "packet_len")
        self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(samp_up / decim_fac,
                                                   "packet_len")
        self.radar_ts_fft_cc_0 = radar.ts_fft_cc(samp_cw / decim_fac,
                                                 "packet_len")
        self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc(
            (value_range, ), (velocity, ), (1e16, ), (0, ), (0, ), samp_rate,
            center_freq, -10, False, False, "packet_len")
        (self.radar_static_target_simulator_cc_0).set_min_output_buffer(98304)
        self.radar_split_cc_0_0_0 = radar.split_cc(
            2, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0_0).set_min_output_buffer(98304)
        self.radar_split_cc_0_0 = radar.split_cc(
            1, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0_0).set_min_output_buffer(98304)
        self.radar_split_cc_0 = radar.split_cc(
            0, ((samp_cw / decim_fac, samp_up / decim_fac,
                 samp_down / decim_fac)), "packet_len")
        (self.radar_split_cc_0).set_min_output_buffer(98304)
        self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c(
            samp_rate, samp_up, samp_down, samp_cw, -sweep_freq / 2,
            sweep_freq, 1, "packet_len")
        (self.radar_signal_generator_fmcw_c_0).set_min_output_buffer(98304)
        self.radar_print_results_0 = radar.print_results(False, "")
        self.radar_find_max_peak_c_0_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_find_max_peak_c_0_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_find_max_peak_c_0 = radar.find_max_peak_c(
            samp_rate / decim_fac, threshold, protect_samp, (), False,
            "packet_len")
        self.radar_estimator_fmcw_0 = radar.estimator_fmcw(
            samp_rate / decim_fac, center_freq, sweep_freq,
            samp_up / decim_fac, samp_down / decim_fac, False)
        self.qtgui_sink_x_0_1 = qtgui.sink_c(
            samp_cw / decim_fac,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim_fac,  #bw
            'CW',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_1_win)

        self.qtgui_sink_x_0_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            samp_cw / decim_fac,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim_fac,  #bw
            'CW',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        (self.blocks_throttle_0).set_min_output_buffer(98304)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decim_fac)
        (self.blocks_tagged_stream_multiply_length_0
         ).set_min_output_buffer(98304)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(98304)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        (self.blocks_add_xx_0).set_min_output_buffer(98304)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.1, 0)
        (self.analog_noise_source_x_0).set_min_output_buffer(98304)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.radar_estimator_fmcw_0, 'Msg out'),
                         (self.radar_print_results_0, 'Msg in'))
        self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in CW'))
        self.msg_connect((self.radar_find_max_peak_c_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in UP'))
        self.msg_connect((self.radar_find_max_peak_c_0_0_0, 'Msg out'),
                         (self.radar_estimator_fmcw_0, 'Msg in DOWN'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.qtgui_sink_x_0_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_split_cc_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.radar_static_target_simulator_cc_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.radar_signal_generator_fmcw_c_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.radar_split_cc_0, 0), (self.radar_ts_fft_cc_0, 0))
        self.connect((self.radar_split_cc_0_0, 0),
                     (self.radar_ts_fft_cc_0_0, 0))
        self.connect((self.radar_split_cc_0_0_0, 0),
                     (self.radar_ts_fft_cc_0_1, 0))
        self.connect((self.radar_static_target_simulator_cc_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.radar_ts_fft_cc_0, 0),
                     (self.radar_find_max_peak_c_0, 0))
        self.connect((self.radar_ts_fft_cc_0_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.radar_ts_fft_cc_0_0, 0),
                     (self.radar_find_max_peak_c_0_0, 0))
        self.connect((self.radar_ts_fft_cc_0_1, 0),
                     (self.radar_find_max_peak_c_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))