I know this is an old thread, but I want to thank anyone that is still around for contributing. I ran the duemilanova using a prescale of 16 (thanks jmknapp!), and performed an analogRead on a 1K Hertz signal. Here is the result (100 samples of 1000 Hz sine wave):
Gives a 56K sample rate! Next up, prescale to 16, use a 20 MHz crystal, and rely on i2c to move the data. Were very close to a very usable $30 DAQ! Thanks guys.
Just for comparison, here are the same 100 samples of a 1000 Hz sine wave using the normal prescale of 128 (it automatically resets itself back to 128 when the arduino reboots/resets).
Here's the code ...
/*
Analog Input with prescale change
Reading a 1 kHz sine wave, 0 to 5 volts
Using analog 0
Results stored in memory for highest speed
using code from:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/11
with special thanks to jmknapp
*/
#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
int value[100]; // variable to store the value coming from the sensor
int i=0;
void setup()
{
Serial.begin(9600) ;
int start ;
int i ;
#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif
}
void loop()
{
for (i=0;i<100;i++)
{
value[i]=analogRead(0);
}
for (i=0;i<100;i++)
{
Serial.println(value[i]);
}
Serial.println();
Serial.println();
Serial.println();
delay(5000);
}
You'll (hopefully) find continuing progress at: