Jump to content


Photo

Faster analogread ?


  • Please log in to reply
3 replies to this topic

#1 Hitoshi

Hitoshi

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 23 June 2015 - 12:26 PM

Hi, I'm using Arduino IDE on my pcDuino v1

I'm a beginner with Arduino boards or pcDuino, I would like to record signals on sd card or usb key for example.

My program works but I would like to increase the data capture frequency and the function "analogRead" is a little too slow.

I tried to read on /proc/adc5 without using analogRead but I got the same time.

 

For one capture (+ write on buffer) I get an average of 21-24µs with a data capture frequency of 10 kHz

 

Do you know a method to get faster values ?

 

Thanks.



#2 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 23 June 2015 - 09:52 PM

Without looking at the code I can not say for sure but I am guessing that you are trying to sample, write, sample, write. The file save is likely slowing you down.

 

Try writing a test program that samples and saves to an array. Record the time, then do 10,000 samples or more, and when done record the time again. I was able to achieve higher results then that using a python script so I know a compiled C program will do better.

 

I don't know what your expectations are for sampling speed but you must remember that there is a full OS between you and the metal and it will not be as fast as without the OS. 



#3 Hitoshi

Hitoshi

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 30 June 2015 - 01:24 PM

Hi, thank you for your answer.

Finally I chose Arduino Due, results are more accurate (no full OS in background) and analogRead is faster than on pcDuino

The only problem is the speed for writing values on SD card (with a SD shield), with high data capture frequency (20 kHz), the buffer is full in about 1 second and after for writing the buffer it takes 190ms



#4 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 30 June 2015 - 11:49 PM

File write speed will always be the bottle neck.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users