Using PYNQ to control RFsoc4*2's dac_block' mixer

  • PYNQ 3.0.1 & RFsoc4*2 & Windows 10
  • I want to use PYNQ to configure mixer of the DAC converter in the board
  • After I set set the Mixer’s frequency of the DAC converter on the board, the frequency of the received signal does not shift.

Here is the detail:
First, I connect the output of the DAC block to the input of the ADC block.

# initial the base
myBase = Base()
myBase.initRFClks()

Base is a class that create by myself to represents the base class, and the code here just set the overly_file to “base.bit” and initial the rf clocks

myTransmitter = Transmitter(myBase,  ChannelSetting(0, 0.02, 30), ChannelSetting(1, 0.02, 30))
myTransmitter.configureTransmitter()
myTransmitter.enableTransmitter()

The code here is just set the both of the transmitter’s channel 0 and channel 1’s gain to 0.02, and the mixer’s frequency to 30 MHz. It will generate two 30 MHz frequency signals.
Settings for Mixer’s frequency:
{‘Freq’: 30.0,
‘PhaseOffset’: 0.0,
‘EventSource’: 0,
‘CoarseMixFreq’: 0,
‘MixerMode’: 2,
‘FineMixerScale’: 1,
‘MixerType’: 2}

In the next step, I change the receiver’s mixer setting to 100 MHz
Settings for receiver’s mixer’s frequency:
{‘Freq’: 99.99999999999417,
‘PhaseOffset’: 0.0,
‘EventSource’: 2,
‘CoarseMixFreq’: 0,
‘MixerMode’: 3,
‘FineMixerScale’: 1,
‘MixerType’: 2}

However, the frequency spectrum output for the data recived by the receiver is still at 30 Mhz instead of shifting for the frequency.

Here is the code I use for printing the frequency spectrum:

 def plot(self):
        number_samples =  len (self.data[0])
        window = np.array(np.blackman(number_samples)[:])
        wdata = []
        for i in range(0, len(self.data)):
            wdata.append(self.data[i]*window)
        fdata = []
        for i in range(0, len(wdata)):
            fdata.append(np.fft.fftshift(np.fft.fft(wdata[i])))
        magfigs = []
        for i in range(0, len(fdata)):
            title=''.join(['Frequency Magnitude Plot of ADC Channel ', str(i)])
            magfigs.append(self.plot_complex_spectrum(
                data = abs(fdata[i]), N = number_samples, fs = self.sampleFrequency,
                title = title,
                units = '|Y(f)|',
                fc = round(abs(self.base.base.radio.receiver.channel[i].adc_block.MixerSettings['Freq']))*1e6))
        display(ipw.VBox(magfigs))   

    def plot_complex_spectrum(self,data, N, fs, 
                          title='Complex Spectrum Plot', units='dBW', fc=0):
        plt_temp = (go.Scatter(x = np.arange(-fs/2, fs/2, fs/N) + fc,
                           y = data, name='Spectrum'))
        return go.FigureWidget(data = plt_temp,
                           layout = {'title': title, 
                                     'xaxis': {
                                         'title': 'Frequency (Hz)',
                                         'autorange': True},
                                     'yaxis': {
                                         'title': units}})

Thank you for much!

Hi,
Is this issue related to this previous request? ( Question about introduction Jupyter notebook and the 4x2 board)

Thank you that helps a lot. However, I still have problem that for the mixer. If I let the transmitter to generate a 30 MHz signal. I connect the transmitter to the receiver, and let ADC block to have a -30 MHz mixer frequency. Isn’t that will transfer the signal to the base band. However, when I look at FFT output of the signal, it will have two peaks: one at -1.69 GHz and the other one at 1.22 GHz.
However, if I change the mixer’s frequency in the ADC block to the -1199.304 (-1288 + 30 ) MHz, it will shift the signal to the base band (near 0 MHz). I don’t understand this.