AnsweredAssumed Answered

MATLAB HIL Example [ad9361_matlab.m] Questions

Question asked by ferdem on Jun 29, 2015
Latest reply on Jul 20, 2015 by ferdem

I'm studying on the example ad9361_matlab.m. I use it for the board FMCOMMS5 and ZC706, Zynq linux image is final version(April 2015). The example code captures data according to the specified buffer size, it is ok. I'm trying to understand the code first, then I want to make use it to stream data(with a reasonable sampling rate such as 1MSps or less) to my PC without losing any samples. I have a few questions.


1) ad9361_matlab.m Line 34: Why does the for loop repeat 5 times? It takes much more time than the actual duration of one data collection cycle.
for i = 1:5
output = stepImpl(s, input);
rssi1 = output{s.out_ch_no+1};
rssi2 = output{s.out_ch_no+2};

2) The code above captures one cycle correctly. I have thougth that if I succesively execute a code capturing one cycle, I can simply stream the  data. I have trimmed the code by canceling the loop and commenting out all parts(in iio_sys_object) which are not related to data read.

Execution time is shrinked but it is still two times the actual sampling duration and I have still some major problems with collecting data.

I have set the buffer size 1024000 and my sampling rate 1.024 MSps. As a result, the sampling duration should be 1 second.


I have realized the method reading the data in libiio_if.m Line 480:

I have focussed on this part because %99 of the execution time passes here.


   % Read the data
    calllib(obj.libname, 'iio_buffer_refill', obj.iio_buffer);
    buffer = calllib(obj.libname, 'iio_buffer_first', obj.iio_buffer, obj.iio_channel{1});
   setdatatype(buffer, 'int16Ptr', obj.iio_buf_size);
    for i = 1 : obj.data_ch_no
   data{i} = double(buffer.Value(i:obj.data_ch_no:end));



It takes 1sec or less at first execution(as expected) but subsequent executions takes almost 2 seconds meaning that I lose at least 1 second in between execution cycles. I can also see that in between the ('iio_buffer_refill') cycles 1 sec data is dropped out in my tests. What is the problem here?


3) Can I simply convert the example code ad9361_matlab.m to stream data at 1MSps by doing minor modifications on it? Is it correct to call 'iio_buffer_refill' in a loop to stream data or do I need to watch for some interrupts, flags to initiate 'iio_buffer_refill'?



Thank you, sincerely.