Beispiel #1
0
    def TransmitterSetup(self):

        #def on_modulation_change(change):
        #self.TransmitterTop.set_modulation(change['new'])

        def on_slider_change(change):
            self.dac_block.MixerSettings['Freq'] = change['new']
            self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)

#         def setNyquist(zone):
#             zone = int(zone['new'])
#             self.adc_block.NyquistZone = zone

#options= ['BPSK', 'QPSK', '8-PSK', '16-QAM']
#modsel = sipw.drop_menu_widget('Modulation:', options[1],options)

        freqsel = sipw.float_txt_widget('Tx Frequency (MHz):',
                                        self.dac_block.MixerSettings['Freq'],
                                        1, 1020, 1)
        #         nyquist = sipw.drop_menu_widget('Nyquist Zone:', 1, [1,2])

        accordion = sipw.accordion_widget('Transmit', [freqsel])

        #modsel.observe(on_modulation_change, names='value')
        freqsel.observe(on_slider_change, names='value')

        return accordion
Beispiel #2
0
    def OutputSetup(self):
        def outputType(value):
            switcher = {
                'Magnitude': 0,
                'PSD': 1,
            }
            num = switcher.get(value['new'], 0)
            self.SpectrumFFT.PSD.output_selection = num
            self.SpecPlot._updaterange = True

        # Output Controls
        options = ['Magnitude', 'PSD']
        output_drop = sipw.drop_menu_widget('Analysis:', options[1], options)
        accordion = sipw.accordion_widget('Output', [output_drop])

        output_drop.observe(outputType, names='value')

        return accordion
Beispiel #3
0
    def OutputSetup(self):
        def outputType(value):
            switcher = {
                'Magnitude': 0,
                'PSD': 1,
            }
            num = switcher.get(value['new'], 0)
            self.SpectrumFFT.PSD.output_selection = num
            self.SpecPlot._updaterange = True
            if num:
                self.SpecPlot._plot_spectrum.layout.yaxis[
                    'title'] = 'Power Spectral Density (dB/Hz)'
            else:
                self.SpecPlot._plot_spectrum.layout.yaxis[
                    'title'] = 'Magnitude'

        # Output Controls
        options = ['Magnitude', 'PSD']
        output_drop = sipw.drop_menu_widget('Analysis:', options[1], options)
        accordion = sipw.accordion_widget('Output', [output_drop])

        output_drop.observe(outputType, names='value')

        return accordion
Beispiel #4
0
    def AnalysisColumn(self):
        def peak_detect(change):
            self.SpecPlot._peakdetect = change['new']
            self.SpecPlot._plot_spectrum.data[1].visible = change['new']
            self.peak_flag = change['new']

        def update_spectrum_timer(value):
            self.TimerSpectrum = DmaTimer(self.update_voila,
                                          self.DataInspector.get_buffer_frame,
                                          value['new'])
            self.spectrogram_timer_slider.min = value['new']

        def update_spectrogram_timer(value):
            self.TimerSpectrogram = Timer(self.SpecPlot.add_frame_spectrogram,
                                          value['new'])

        def update_buffer(value):
            self.SpecPlot._buf = value['new']

        def update_range(value):
            self.SpecPlot._plot_spectrum.layout.yaxis.range = value['new']
            self.SpecPlot._plot_spectrogram.data[0].zmin = value['new'][0]
            self.SpecPlot._plot_spectrogram.data[0].zmax = value['new'][1]

        def updateAvg(value):
            self.SpecPlot._avg_window = np.full((value['new'], 2048),
                                                self.SpecPlot._data)

        image = sipw.image_widget("assets/strathclyde_logo.png")

        peak_toggle = sipw.check_box_widget('Peak Detection', False)

        style = {'description_width': 'initial'}
        self.peak_x = ipw.FloatText(value=0.0,
                                    description='x:',
                                    disabled=True,
                                    layout=ipw.Layout(width='auto'),
                                    style=style)
        self.peak_y = ipw.FloatText(value=0.0,
                                    description='y:',
                                    disabled=True,
                                    layout=ipw.Layout(width='auto'),
                                    style=style)

        self.spectrum_timer_slider = sipw.float_slide_widget(
            'Spectrum Timer:', 1 / 8, 1 / 8, 1 / 4, 1 / 4)
        self.spectrogram_timer_slider = sipw.float_slide_widget(
            'Spectrogram Timer:', 1 / 8, 1 / 8, 1 / 4, 1 / 4)
        spectrogram_buffer_slider = sipw.int_slide_widget(
            'Spectrogram Buffer:', 2, 1, 20, 1)
        plot_magnitude_range = sipw.int_range_widget('Range:', [-140, 0], -160,
                                                     0, 1)
        frame_avg = sipw.int_slide_widget('Frame Average: ', 1, 1, 32, 1)

        peak_toggle.observe(peak_detect, names='value')
        self.spectrum_timer_slider.observe(update_spectrum_timer,
                                           names='value')
        self.spectrogram_timer_slider.observe(update_spectrogram_timer,
                                              names='value')
        spectrogram_buffer_slider.observe(update_buffer, names='value')
        plot_magnitude_range.observe(update_range, names='value')
        frame_avg.observe(updateAvg, names='value')

        peak = sipw.accordion_widget('Peak Detection',
                                     [peak_toggle, self.peak_x, self.peak_y])
        plot_update = sipw.accordion_widget('Plot Settings', [
            self.spectrum_timer_slider, self.spectrogram_timer_slider,
            spectrogram_buffer_slider, plot_magnitude_range, frame_avg
        ])

        return ipw.VBox([image, plot_update, peak],
                        layout=ipw.Layout(width='auto'))
Beispiel #5
0
    def ReceiverSetup(self):
        def changeADC(adc):
            adc_new = adc['new']

            adc_new_bin = np.binary_repr(adc_new, width=2)
            tile = int(adc_new_bin[0])
            block = int(adc_new_bin[1])

            self.adc_tile = self.rf.adc_tiles[tile]
            self.adc_block = self.adc_tile.blocks[block]

            im = MMIO(0x00_A004_6000, 4096)
            re = MMIO(0x00_A004_7000, 4096)
            re.write(0x40, adc_new)
            re.write(0x0, 0x2)
            im.write(0x40, adc_new)
            im.write(0x0, 0x2)

            update_widgets_and_graph()

        def update_widgets_and_graph():
            #             self.nyquist.value = self.adc_block.NyquistZone
            self.rx_nco_txt.value = np.ceil(
                self.adc_block.MixerSettings['Freq'])
            update_nco_and_graph(self.adc_block, self.rx_nco_txt.value)

        def update_nco_and_graph(rf_block, nco_freq):
            lim = self._fs / 2  #+ (nco_freq * 1e6)
            div = (self._fs) / 2048
            self._fc = nco_freq
            self.SpecPlot._x_data = np.arange(-lim, lim,
                                              div) + (nco_freq * 1e6)
            self.SpecPlot._x_data_spectrogram = np.take(
                self.SpecPlot._x_data, self.SpecPlot.indices_2)
            self.SpecPlot._range = [
                min(self.SpecPlot._x_data),
                max(self.SpecPlot._x_data)
            ]
            self.SpecPlot._updaterange = True

            rf_block.MixerSettings['Freq'] = nco_freq
            rf_block.UpdateEvent(xrfdc.EVENT_MIXER)

        def update_downsampler_and_nco_slider(freq_res):

            freq_res = float(freq_res['new'])
            """Firstly, update the virtual sampling frequency"""
            self._fs = np.round(freq_res * 2048)
            """Get the downsampling factor for the given frequency resolution"""
            L = int(np.floor(self._axi_fs / self._fs))
            """If the downsampling factor is equal to 1, then disable the Low-Pass filters.
               Else, the lowpass filter should be generated and the coefficients written to the FIRs."""
            if L == 1:
                self.BandwidthSelector.BWSelector.enable = 0
            else:
                w, h, coeffs = self.BandwidthSelector.generate_lowpass(
                    self._axi_fs,
                    self._axi_fs / (2 * L) - self._axi_fs * 0.025,
                    self._axi_fs * 0.025, 256)
                """Only need one half as filter is symmetric"""
                self._coeffs = coeffs[0:128:1]
                self.BandwidthSelector.reload(self._coeffs)
                self.BandwidthSelector.config(0)
                self.BandwidthSelector.BWSelector.enable = 1
            """Set the downsample factor after updating the FIR coefficients"""
            self.BandwidthSelector.set_downsample(L)
            """Finally update the range of the SpecPlot so that it accurately represents the bandwidth"""
            lim = self._fs / 2
            div = (self._fs) / 2048
            self.SpecPlot._x_data = np.arange(-lim, lim, div) + self._fc * 1e6
            self.SpecPlot._x_data_spectrogram = np.take(
                self.SpecPlot._x_data, self.SpecPlot.indices_2)
            self.SpecPlot._range = [
                min(self.SpecPlot._x_data),
                max(self.SpecPlot._x_data)
            ]
            self.SpecPlot._updaterange = True
            """Update Scaler in PSD - Hotfix"""
            #self.SpectrumAnalyser.SpectrumFFT.PSD.write(0x104, int(struct.unpack('!i',struct.pack('!f',float(1/(self._fs*self.SpectrumWindow.scale_factor))))[0]))
            self.SpectrumAnalyser.SpectrumFFT.PSD.write(
                0x108,
                int(struct.unpack('!i', struct.pack('!f', float(div)))[0]))

        def unwrap_slider_val(callback):
            return lambda slider_val: callback(slider_val['new'])


#         def setNyquist(zone):
#             zone = int(zone['new'])
#             self.adc_block.NyquistZone = zone

# Receive Controls

        options = [0, 1, 2]
        rx_adc_drop = sipw.drop_menu_widget('ADC', options[0], options)
        self.rx_nco_txt = sipw.float_txt_widget('Center Frequency (MHz):', 64,
                                                1, 1024, 1)
        optgen = [16e6, 32e6, 64e6, 128e6, 256e6]
        options = [i / 2048 for i in optgen]
        rx_res_drop = sipw.drop_menu_widget('Resolution (Hz):', options[3],
                                            options)
        #         self.nyquist = sipw.drop_menu_widget('Nyquist Zone:', 2, [1,2])
        accordion = sipw.accordion_widget(
            'Receive', [rx_adc_drop, self.rx_nco_txt, rx_res_drop])

        rx_adc_drop.observe(changeADC, names='value')
        self.rx_nco_txt.observe(unwrap_slider_val(
            lambda v: update_nco_and_graph(self.adc_block, v)),
                                names='value')
        rx_res_drop.observe(update_downsampler_and_nco_slider, names='value')
        #         self.nyquist.observe(setNyquist, names='value')

        return accordion