Packet transmission with libiio


I want to transmit data from MATLAB over radio in frames using libiio and ad9361 in non-cyclic mode and have no RF signals in the channel while there are no more frames to transmit.

There are three issues regarding this setup I've stumbled upon:

  • sine tone is transmitted automatically at startup.
  • ad9361 core repeats the last transmitted samples if there's no new data incoming.
  • if DMA buffers are released using tx.release(), then the board switches to DDS.

This is what I've found so far and what is left unsolved:

  • I can disable oscilloscope autostart as described here. But will matlab initialize all the required parameters of ad9361 and do the calibrations?
  • Second issue can be corrected by adding some zeros at the end of the buffer. But what is the minimal number necessary? Also there's LO leakage if I do it this way, which is significantly bad for me.
  • In this question I've read that writing 0 to the out_volatgeX_raw device attributes will solve it, but can I do it after release function in MATLAB? OR I can somehow change the default behavior?

Thank you in advance,

  • 0
    •  Analog Employees 
    on May 31, 2019 7:15 PM over 1 year ago

    1. Yes, this is independent of IIO-Scope

    2. To reduce LO leakage you can increase TX attenuation or power-down TX. Recent HDL has been updated to pass zeros after DMA finishes. You can easily test this with digital loopback enabled.

    3. You would have to modify some of the base classes. In adi.common.RxTx, after line 113 you could add "obj.ToggleDDS(false)" which would do this. This would also require adding a class to adi.common.RxTx as well. Changing line 1 to "classdef (Abstract) RxTx < matlabshared.libiio.base & adi.common.DDS"

                  Or maxing out the TX attenuation or powering down TX would do the same.


  • Hello, Travis!
    Thank you for the reply.

    1. Ok, so I was right that it is the osc that enables DDS upon boot? Without it Tx will remain in disabled state? Btw, while using the previous generation of MATLAB API, we had different results from the loopback if osc was disabled.
    2. a) Huh, I doubt I can increase attenuation right after the buffer was fully transmiited. Attenuation's changed from PL, but the data is sent from PS, there's no easy way to sync them. So the best I can get is
      tx.AttenuationChannel0 = -50;
      pause(3); % doing computations, for example
      tx.AttenuationChannel0 = -10;

      b) Does 2018_R1 release support zero passing?

    3. Are you sure? Not to line 87 of the same file? I checked with MATLAB debugger, tx.release() calls releaseChanBuffers, but not configureChanBuffers. I remember somewhere on the wiki there was a diagram that described the interaction between dma-dds-disabled states and how to operate with them using attributes. Could you please guide me to it?
  • +1
    •  Analog Employees 
    on Jun 3, 2019 8:11 PM over 1 year ago in reply to Sinill57

    1. It depends, if OSC is not loaded the DDSs are used by default. If OSC loads then it will default to whatever was OSCs last saved profile. APIs are a bit different now.

    2. If you need to do this quickly the best way is to use the TDD state machine controlled by some logic in the FPGA. Yes, I believe this is in R1 2018, I just don't have a board with me at the moment. There is an easy way to check though. Turn on digital loopback and send a non-cyclic buffer through.

    3. Yes sorry, you are correct. For the DDS/DMA state look here under Enable/Disable DDS channel:


    1. This one's clear, thank you.

    2. For TDD mode usage, is this wiki page the main source of knowledge? I've only worked with FDD before, would be great to read some docs first.

    3. The diagram on the wiki page clearly shows that from zero state I can only move to  DDS state. Maybe then on line 113 I should first call obj.ToggleDDS(true) and only after it enableChannel?
Reply Children
No Data