Hi all, I tried to read the ADC from an Apalis iMX6. It is working with a ixora carrier board. I put the reading process in a for-loop.
However, even when I set the loop length to be 1000, the actual time cost is ~8sec. i.e., The time interval between two data points is ~4ms (i.e., the sampling rate is about 250S/s). It is kind of slower than I expected, as in iMX6’s data sheet, the sampling rate of the ADC is supposed to be ~800kS/s, which should be ~100kS/s for each channel (assuming 8 channels in total). I would like to know if it is due to the setting of the ADC’s sampling rate? Or it is due to the time lag of the C code? Is there a way I can change the ADC’s sampling rate, or make the reading process faster?
fd = open("/sys/bus/iio/devices/iio:device0/in_voltage4_raw", O_RDONLY);
for(i=0;i<1000;i++)
{
read(fd, &value[i], 1);
gettimeofday(×tamp[i],NULL);
lseek(fd,0,SEEK_SET);
}
close(fd);