What is the Sampling Rate for ADC?

Status
Not open for further replies.

maxustech

Member
Hi all,

I just started using Teensy 3.1 for a couple of days. My project is to use a microphone with teensy 3.1 and capture some high frequency voice (around 20KHz, almost the maximum for microphone). The microphone is connected to Pin A2 which is an analog pin, and I use the internal ADC from teensy. In order to get information at around 20KHz, I need to have a sampling rate of 44.1KHz for ADC, but when I check the API for analogread(), in arduino forum, it can read signal at 9.1KHz at most. Does it mean that my project cannot achieved by this setup?
And I am not so clear about whether the problem is the analogread() function cannot read signal fast enough, or the ADC sampling is not fast enough.
If the problem is at the analogread() function, please tell me an alternative way to do it.
Thanks.
 
Hi all,

I just started using Teensy 3.1 for a couple of days. My project is to use a microphone with teensy 3.1 and capture some high frequency voice (around 20KHz, almost the maximum for microphone). The microphone is connected to Pin A2 which is an analog pin, and I use the internal ADC from teensy. In order to get information at around 20KHz, I need to have a sampling rate of 44.1KHz for ADC, but when I check the API for analogread(), in arduino forum, it can read signal at 9.1KHz at most. Does it mean that my project cannot achieved by this setup?
And I am not so clear about whether the problem is the analogread() function cannot read signal fast enough, or the ADC sampling is not fast enough.
If the problem is at the analogread() function, please tell me an alternative way to do it.
Thanks.

Forget arduino forum.
Teensy is fast enough to handle sampling frequencies >44.1 kHz
To facilitate audio programming, Paul provides a node-red gui
http://www.pjrc.com/teensy/gui/
where internal audio and Pauls audio board is integrated and which is set at 44.1 kHz
 
Yes, for 44.1 kHz audio, you definitely should use the Teensy Audio Library.

The internal ADC on Teensy 3.1 is much faster than the ADC on regular Arduino boards. It can actually run at 400 kHz or higher. To achieve a consistent 44.1 kHz sample rate, the audio library configures one of the timers to automatically trigger the ADC. It also uses efficient DMA transfers to get the data into memory, so you can use it with the rest of the audio library. The result is highly reliable 44.1 kHz sampling with minimal CPU overhead.

The Teensy Audio Library is a large collection of audio processing objects. You can connect them in almost any way, to create audio processing systems. In your case, if you just want to get the ADC samples, you'll need the ADC input object and a recoding queue object, and one connection object between them. The queue object is how your sketch can read the actual audio data samples from the audio library. It delivers them to you in 128 sample buffers. If your sketch occasionally spends too much time with any one buffer (for example, writing them to a SD card which sometimes has longer delays), the queue object automatically keeps the incoming 128 sample buffers in a queue so you won't lose data. Of course, you do have to keep up with the full speed on average, since the queue is limited to only the amount of audio memory your sketch allocates to the library in setup().

To get started, look at File > Examples > Audio > Recorder.
 
Yes, for 44.1 kHz audio, you definitely should use the Teensy Audio Library.

The internal ADC on Teensy 3.1 is much faster than the ADC on regular Arduino boards. It can actually run at 400 kHz or higher. To achieve a consistent 44.1 kHz sample rate, the audio library configures one of the timers to automatically trigger the ADC. It also uses efficient DMA transfers to get the data into memory, so you can use it with the rest of the audio library. The result is highly reliable 44.1 kHz sampling with minimal CPU overhead.

The Teensy Audio Library is a large collection of audio processing objects. You can connect them in almost any way, to create audio processing systems. In your case, if you just want to get the ADC samples, you'll need the ADC input object and a recoding queue object, and one connection object between them. The queue object is how your sketch can read the actual audio data samples from the audio library. It delivers them to you in 128 sample buffers. If your sketch occasionally spends too much time with any one buffer (for example, writing them to a SD card which sometimes has longer delays), the queue object automatically keeps the incoming 128 sample buffers in a queue so you won't lose data. Of course, you do have to keep up with the full speed on average, since the queue is limited to only the amount of audio memory your sketch allocates to the library in setup().

To get started, look at File > Examples > Audio > Recorder.

Thanks Paul!It really helps!
So based on my understanding, the ADC in audio library runs at 44.1KHz without any extra configuration, am I right? I do not need to set a timer by myself?
And I actually want the signal to get into FFT objects after converted to digital, but if I connect the ADC to the queue object, I cannot connect FFT after it, What can I do?
 
So based on my understanding, the ADC in audio library runs at 44.1KHz without any extra configuration, am I right? I do not need to set a timer by myself?

Correct, the audio lib does all that.

And I actually want the signal to get into FFT objects after converted to digital, but if I connect the ADC to the queue object, I cannot connect FFT after it, What can I do?

The audio library has a 256 and 1024 point FFT object. Just connect the ADC object to one of those, and then read the FFT data in your sketch.

Really, you should give the audio library a try and become familiar with how it works. Pretty much all the hard work has already been done and packaged up into an incredibly flexible library. You just need to learn only a little about how to use the library.
 
Yeah, It's pretty easy to catch up with the sketch. But after set up the small outer circuit and based on the FFT example, what I can read from the serial line is always 0. I use MAX4466 as the microphone and the output from MAX4466 is about 15mV and after the circuit from the adc diagram, the input AC voltage to Pin A2, is less than 150mV. So maybe the input voltage is too small?
 
Status
Not open for further replies.
Back
Top