# Using PYNQ to control RFsoc4\*2's dac\_block' mixer

**URL:** <https://discuss.pynq.io/t/using-pynq-to-control-rfsoc4-2s-dac-block-mixer/7646>\
**Category:** Support\
**Created:** [October 28, 2024, 8:29pm UTC](https://discuss.pynq.io/t/using-pynq-to-control-rfsoc4-2s-dac-block-mixer/7646 "2024-10-28T20:29:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowBobby](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/wowbobby/32/6417_2.png) [@wowBobby](https://discuss.pynq.io/u/wowBobby)\
**Post date:** [October 28, 2024, 8:29pm UTC](https://discuss.pynq.io/t/using-pynq-to-control-rfsoc4-2s-dac-block-mixer/7646/1 "2024-10-28T20:29:14Z")

</div>

- 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.

```auto
# 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

```auto
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.

 ![8](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/0/09e6171f30fa3e33a2027e8f7d3a9a3ce8e81ad7.png)

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

```auto
 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!

---

<div class="post-metadata">

**Author:** ![matthew](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@matthew](https://discuss.pynq.io/u/matthew)\
**Post date:** [October 29, 2024, 3:26pm UTC](https://discuss.pynq.io/t/using-pynq-to-control-rfsoc4-2s-dac-block-mixer/7646/2 "2024-10-29T15:26:03Z")

</div>

Hi,  
Is this issue related to this previous request? ( [Question about introduction Jupyter notebook and the 4x2 board](https://discuss.pynq.io/t/question-about-introduction-jupyter-notebook-and-the-4x2-board/7404))

---

<div class="post-metadata">

**Author:** ![wowBobby](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/wowbobby/32/6417_2.png) [@wowBobby](https://discuss.pynq.io/u/wowBobby)\
**Post date:** [October 29, 2024, 7:01pm UTC](https://discuss.pynq.io/t/using-pynq-to-control-rfsoc4-2s-dac-block-mixer/7646/3 "2024-10-29T19:01:02Z")

</div>

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.
