Post Go back to editing

Problem Transmitting my own waveform using py adi iio with help of ZCU102+FMCDAQ2-EBZ

Category: Software

Using ADI IIO Software I can transmit my own waveform but I wanted to use the py-adi iio library for doing show.

As per the guides for py-adi i wrote a code to transmit my own waveform (for testing purposes, I just made a sine wave for the time being)

import adi
import numpy as np

# Create radio
sdr = adi.DAQ2(uri="ip:192.168.1.21")
sdr.tx_enabled_channels = [0, 1]

# Create a sinewave waveform
N = 1024
fs = float(sdr.sample_rate)
fc = 40000000
ts = 1 / float(fs)
t = np.arange(0, N * ts, ts)
i = np.cos(2 * np.pi * t * fc) * 2 ** 14
q = np.sin(2 * np.pi * t * fc) * 2 ** 14
iq = i + 1 * q
fc = -30000000
i = np.cos(2 * np.pi * t * fc) * 2 ** 14
q = np.sin(2 * np.pi * t * fc) * 2 ** 14
iq2 = i + 1 * q

# Send data to both channels
sdr.tx([iq, iq2])

But every time i got this error:

IndexError                                Traceback (most recent call last)
/tmp/ipykernel_4053/1445205679.py in <module>
     19 iq2 = i + 1 * q
     20 # Send data to both channels
---> 21 sdr.tx([iq, iq2])

~/anaconda3/lib/python3.9/site-packages/adi/rx_tx.py in tx(self, data_np)
    538 
    539         if not self.__txbuf:
--> 540             self.disable_dds()
    541             self._tx_buffer_size = len(data) // stride
    542             self._tx_init_channels()

~/anaconda3/lib/python3.9/site-packages/adi/dds.py in disable_dds(self)
     81     def disable_dds(self):
     82         """Disable all DDS channels and set all output sources to zero."""
---> 83         self.dds_enabled = np.zeros(self._num_tx_channels * 2, dtype=bool)
     84 
     85     @property

~/anaconda3/lib/python3.9/site-packages/adi/dds.py in dds_enabled(self, value)
    121     @dds_enabled.setter
    122     def dds_enabled(self, value):
--> 123         self.__update_dds("raw", value)
    124 
    125     def dds_single_tone(self, frequency, scale, channel=0):

~/anaconda3/lib/python3.9/site-packages/adi/dds.py in __update_dds(self, attr, value)
     56                 return
     57             if attr == "raw":
---> 58                 chan.attrs[attr].value = str(int(value[indx]))
     59             else:
     60                 chan.attrs[attr].value = str(value[indx])

IndexError: index 4 is out of bounds for axis 0 with size 4

Can you help me out please?