AnsweredAssumed Answered

Configure AD9361 FIR filter from .ftr file with IIO

Question asked by ddk on Apr 20, 2018
Latest reply on May 7, 2018 by ddk
  • using ZC702 with FMCOMMS3
  • Linux analog 4.9.0-g0fa1a63 #18 SMP PREEMPT Fri Jan 26 08:34:30 GMT 2018 armv7l armv7l armv7l GNU/Linux


I'm using the Python bindings to configure the AD9361 via IIO and would like to configure the Filters from this interface in the application.


I'd like to use one of the .ftr files that the MATLAB Filter design Wizard creates, as this allows us to have a directory of them and apply them programmatically as needed.

I've found a section in the IIOScope source that seems to write the contents of the .ftr filter file directly into the device attribute ( from line 67 )

fseek(f, 0, SEEK_END);    //go to end of file
len = ftell(f);        //get file size
buf = malloc(len);    //allocate buffer
fseek(f, 0, SEEK_SET);    //go to start of file
len = fread(buf, 1, len, f); //read file contents into buffer
fclose(f);        //close file
// write entire file ocnytents into ad9361-phy filter_fir_config (iio:device1 attr filter_fir_config)
ret = iio_device_attr_write_raw(dev1,"filter_fir_config", buf, len);


I've done a similar thing in the python application, but the filter settings ( as well as rf_bandwidth and sampling rate ) don't seem to be applied ( when I check them using iio_info)


#read file contents
filterParams =
ctx = iio.Context()
# get device handle
phy = ctx.find_device("ad9361-phy")  # Register control
#write file contents to filter_fir_config attribute
phy.attrs["filter_fir_config"].value = str(filterParams) 

I've also seen that the Python binding uses "  _lib.iio_device_attr_write " when one sets the .value of an attribute, whereas the IIOScope source fir_filter file uses "iio_device_attr_write_raw".


Do I need to interpret the .ftr file and manually set attributes of the ad9361-phy device as well as those for Voltage0 ( RX0 ) - I didn't find where iioScope does this