Esempio n. 1
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
Esempio n. 2
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):', 64, 1, 1020, 1)
        #         nyquist = sipw.drop_menu_widget('Nyquist Zone:', 1, [1,2])

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

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

        return accordion
Esempio n. 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
Esempio n. 4
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