Go Down

Topic: Analog Sample Rate (Read 5655 times) previous topic - next topic

dcb

#15
Dec 21, 2008, 12:00 am Last Edit: Dec 21, 2008, 06:55 am by dcb Reason: 1
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.


Go Up