I get the same speed, using library version V1.2.3. With a little modification in the printout only, I run the sketch on different platforms.
Code: Select all
1000 samples in 112112 microseconds
Averaged 112.11 microseconds per sample
8919.65 Hz sampling rate
1000 samples in 112100 microseconds
Averaged 112.10 microseconds per sample
8920.61 Hz sampling rate
on an Arduino DUO
1000 samples in 4411 microseconds
Averaged 4.41 microseconds per sample
226705.97 Hz sampling rate
on an ATP with library V1.2.3
1000 samples in 78624 microseconds
Averaged 78.62 microseconds per sample
12718.76 Hz sampling rate
on an ATP with library V2.1.1
1000 samples in 120548 microseconds
Averaged 120.55 microseconds per sample
8295.45 Hz sampling rate
The DUO is very fast (same sketch).
Also notice the difference between an Artemis ATP on V1 ( 12718HZ) and same ATP, same sketch, but now with library V2.1.1 is 8295 hz (largely due to Mbed overhead)
The issue is with "only" 12Khz is the number of checks and settings that happen with each and every analogRead. Something could have changed since the last analogRead(), maybe setting the pin digital or what. So in order to be stable, and "better be save than sorry" the pin is re-init is performed for analog reading with each call.
Just for the fun I have made a special version (analogReadFast()) for version 1.2.3 where I removed the checks. It will only initialize the first time the pin and assumes only ONE and ONLY ONE ADC is used. I have then run the same sketch on ATP with library V1.2.3 and analogReadFast()
Code: Select all
1000 samples in 7227 microseconds
Averaged 7.23 microseconds per sample
138370.00 Hz sampling rate
Bang.. 138Khz !!
You can try it as well. Attached is a zip file with the installation instructions for V1.x only. It also includes more information & options about the analogReadFast() and the sketch that I have used. I don't expect this to become part of the product, but it shows the hardware can provide good speed.
You do not have the required permissions to view the files attached to this post.