Hi Everyone,
While working on an application that continuously acquires data from multiple channels using the AD7124 on a CN0554 board, I noticed that sometimes the order of the channels is mixed up. I thought that was an issue with my code, but then I observed the same behavior when using the iio_readdev example that comes with the libiio distribution. I tried the following test.
- I applied 1000 mV to channel "voltage0-voltage1", 2000 mV to channel "voltage2-voltage3", 3000 mV to "voltage4-voltage5", and 4000 mV to "channel6-channel7".
- Set the sampling rate to 19200 for those channels
- Run the command: ./iio_readdev -u ip:localhost ad7124-8 voltage0-voltage1 voltage2-voltage3 voltage4-voltage5 voltage6-voltage7 | ./showout -n 4, where showout is a simple program that gets the binary output dumped by iio_readdev and converts it into readable values (the code of this program is reported below)
At the beginning the output is as expected, e.g.,
1000.25 1998.33 3006.18 4008.38,
however after sometime, typically within 30 seconds, the order of the values changes, e.g.,
1999.74 3007.41 4008.81 1001.40,
i.e. the order of the channels is a circular permutation of the original order.
The iio_readdev app basically dumps the entire buffer without de-interleaving the data. However, I observed the same behavior even when the code iterates over the samples channel by channel (using the functions iio_buffer_first(), iio_buffer_step() and iio_buffer_end() ).
Has anybody come across this behavior? It seems that the libiio loses track of the correct slot assigned to a channel.
Thanks,
Massimo
Here is the code for printing the values dumped by the iio_readdev app.