Eric Ouyang
unread,Feb 17, 2012, 6:07:10 PM2/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to HomeBrew Robotics Club
Hi,
I am using Arduino Uno's Analog pin to detect a sound wave.
For each Analog reading, it takes ~ 110 us for Uno board to read.
If I change the sampling rate (for example, chapter 18 at "Arduino
CookBook" by Michael),
then each Analog reading can be shorten to 17 us.
However, for my application, I just want to know the exact time the
event occur.
Such as, an impulse sound wave will come in within every 2 second,
and I like to know the exact time it comes in.
If I use a loop to keep reading the analoge for the sound wave, such
as reading the Analog pin every 20 us
(20 us is small enough, for 2 second, it has 20000000/20 = 1 million
segments)
then it becomes a big trouble, because I do not know when will sound
come in, the sound may come in
any time within 2 second, so if I like to capture it, I will have to
do
1st reading at t=0, and analog reading takes 110 us (or 17us)
2nd reading will be at t=0+110us (or 17us) and analogue reading
takes 110us (or 17us)
3rd reading will be at t=0+110+110 ....
.......
..... (basically the problem is that analog reading takes too much
time)
My question!
Is there a way to use "hardware interrup" to read the Analog?
I am hoping there is a way that I can detect an analog signal and
know its exact timing using minimum
microcontroller CPU resources, and with simplest programming
approach.
Thanks alot