Hello everyone! I write from Spain. This is my first post. My english is very basic, sorry for this inconvenience. I am working with the analog inputs and I am trying to know what is the maximum speed capture. I have written this basic example to do tests but I just got 3754 measurements in 5 seconds. It really is not what I expected. I thougt that the amount would be at least 100 times more. Is there any way to speed up sampling? This is my basic example test code: Code: unsigned long time = 5000; // miliseg unsigned long save_millis = 0; unsigned long counter = 0; // loop counter int InA0; int InA1; int InA2; int InA3; int InA4; int InA5; void setup() { Serial.begin(115200); analogReadResolution(12); delay(10000); } void loop() { InA0 = analogRead(A0); InA1 = analogRead(A1); InA2 = analogRead(A2); InA3 = analogRead(A3); InA4 = analogRead(A4); InA5 = analogRead(A5); counter++; if( millis() >= (save_millis + time )){ Serial.print("counter ="); Serial.println(counter); Serial.println(InA0); Serial.println(InA1); Serial.println(InA2); Serial.println(InA3); Serial.println(InA4); Serial.println(InA5); counter = 0; save_millis = millis(); } } Thanks in advance.
What is the score if you only read 1 pin? It is a serial action. You could also set the resolution lower. If you need more speed then you have to go into the source of the analogRead function. You can find it in the board package in wiring_analog.c ( and deeper libraries) Edit: https://github.com/UDOOboard/arduino-board-package/tree/boardmanager/udoo/solox/variants/udooneo
When I only read 1 pin I get approx 21000 reads per 5 seconds. Setting the resolution had no influence.
Thank you for your replies waltervl. I am doing tests with UDOO QUAD and I'm getting 1,754.995 reads per minute with 7 analog inputs ( 146,249 reads in 5 seconds). The resolution is 12bits in my test. I will use UDOO QUAD for my proyect.
Just checked the reference manual that can be found here: http://www.udoo.org/docs-neo/Hardware_Reference/Overview.html chapter 14 The sample time can be between 0.7 us and 10 us, it depends on the configuration. So the Neo should be able to sample 10.000 to 100.000 samples a second. So it seems that there is a lot of delay on the line. Can someone tell or show us the configuration of the ADC?
You need to review the MQX layer to see how the ADC is setup, there are many options for long/short sampling rates depending on resolution, mcu bus frequency, fADCK, compare phase time and sample phase time. Not sure where you got the 0.7-10us range from?
I got the sample time range from the configuration examples in chapter 14.3.3.6. So it are just examples so I wanted to check how the Neo was configured. I will dive deeper in the MQX layer.