Forum 2005-2010 (read only)
Analog Sample Rate
Topic: Analog Sample Rate
(Read 5698 times)
Re: Analog Sample Rate
Dec 21, 2008, 12:00 am
: Dec 21, 2008, 06:55 am by dcb
Ok, you are looking for 144 samples per second (hz) (or .007 period). Arduino analogRead can do about 10,000 per second so no problem there.
The trick to not losing samples is to use interrupts. You copy the data to send at the top of the loop (quickly, or use a double buffer approach) and send the copy in the main loop over the uart. Need to figure out how to generate an interrupt every 5 degrees. if 5 degrees and rpm isn't critical then use a timer interrupt (figure out how much time = 5 degrees of rotation). Otherwise it gets complicated.
The main loop will be treated as though it were a "lower priority" thread, where execution will be suspended and the readings taken (again quickly) and then resumed.