Sample rate and number of ADC channels

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone.

 

I am new to AVR and also to this interesting website/forums. I have a question regarding ADC. It is related to sampling rate and number of adc channels. Let's say the external crystal is 16MHz, and the prescaler is 128. then the frequency of ADC is 125 KHz, considering that a conversion rake about 13 adc clock, then we can sample approximately 9600 sample per second. my question is: If more than one channel is used, then this sampling rate will split between them? For example if two channels are used, then each channel can sample 4800 per second?

 

I appreciate if you can help me with this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, you need to select the mux, then take your reading.  If you only have one ADC peripheral, then it must be shared & the throughput is reduced.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can only read one ADC channel at a time..   Yes.   You can get a fresh 10-bit sample on a single channel every 13 ADC "clocks".

 

If you are changing the ADC channel you must allow for the SAH capacitor to charge to the new signal voltage.

In practice you would not expect to read several channels at full speed.

 

You can get 8-bit samples faster than 10-bit samples i.e. less ADC "clocks"

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Yes, you need to select the mux, then take your reading.  If you only have one ADC peripheral, then it must be shared & the throughput is reduced.

 Then you mean then sampling frequency will be shared between different channels?

thank you for your help

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

 

If you are changing the ADC channel you must allow for the SAH capacitor to charge to the new signal voltage.

In practice you would not expect to read several channels at full speed.

 

Thanks David. Can you give me a hint on how to let SAH capacitor to charge? should I use delay?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Life is easier if you just say what you want to do.   e.g. sample two audio signals,   sample five temperature sensors, ...

 

Note that some sensors really do not need to be sampled at a high rate e.g. temperature

But an audio signal probably does.

 

You can have several different signals. One on each ADC channel pin.

You can sample at different rates and the punter does not notice.    e.g. skip an audio sample to read a battery voltage.   (let the software guess the missing sample)

 

David.

Last Edited: Thu. Jul 11, 2019 - 09:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to point out that if you are still in the design phase and the core of your design is ADC use you may be using the wrong AVR if you have picked one with the 200kHx/13 clock limit. The Xmega have a much more advanced ADC capable of converting much faster. I haven't checked but I suspect the very recent Xtiny chips have probably inherited that same ADC.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Life is easier if you just say what you want to do.   e.g. sample two audio signals,   sample five temperature sensors, ...

 

Note that some sensors really do not need to be sampled at a high rate e.g. temperature

But an audio signal probably does.

 

You can have several different signals. One on each ADC channel pin.

You can sample at different rates and the punter does not notice.    e.g. skip an audio sample to read a battery voltage.   (let the software guess the missing sample)

 

David.

 

Actually, I have a current sensor and a microphone. The microphone is able to record up to 22khz signals. so I need to read two channels, while for microphone i need at least 22k sample per seconds

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The microphone is able to record up to 22khz signals. so I need to read two channels, while for microphone i need at least 22k sample per seconds

You need to pay attention to what is going on, since a 22KHz  freq would require at least 44KHz sampling (which won't happen with the classic AVR).

 

If you can get up to 15K samples/sec, then your allowable freq might be able to go as high as 7.5KHz. 

 

What exactly are you trying to do?  It's doubtful you need to do anything at that 22 KHz freq, unless audiophile (which the AVR isn't)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

madary wrote:
I have a current sensor and a microphone.

Ok, this sounds like an interesting application, can you expand on it?

You can run the ADC faster with lower resolution, say 250k at 8 bit and get close to 22KHz sample rate, but that means a max frequency input of around 11kHz.....

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you mention which AVR?

 

Let's assume the ubiquitous ATmega328P

ki0bk wrote:
You can run the ADC faster with lower resolution, say 250k at 8 bit
The m328p can hit a 1 MHz clock for 8 good bits.  That gives 1000000/13 = 76.923 kHz.  If you're sampling 2 channels, that gives a channel rate of 38.462 kHz.

 

david.prentice wrote:
If you are changing the ADC channel you must allow for the SAH capacitor to charge to the new signal voltage.
Not necessarily.  If the impedance of the signal sources is low enough, the 1.5 ADC clock period during the sample period is sufficient to do that.  One must do the analysis, however.

 

As per the datasheet, the internal resistance of the ADC path is between 1K and 100K.  The S/H cap is 14 pF.  You want the cap to charge to within 0.5 LSB.  This has been addressed in whole or in part in a number of previous threads:

https://www.avrfreaks.net/forum/avr-adc-analog-bandwith?page=all

https://www.avrfreaks.net/forum/adc-series-resistance?page=all

https://www.avrfreaks.net/forum/atmega8-adc-two-inputs?page=all

(In particular: https://www.avrfreaks.net/comment/1722371#comment-1722371 and https://www.avrfreaks.net/comment/1722446#comment-1722446)

 

There are others I haven't dug up.

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

madary wrote:

david.prentice wrote:

 

If you are changing the ADC channel you must allow for the SAH capacitor to charge to the new signal voltage.

In practice you would not expect to read several channels at full speed.

 

Thanks David. Can you give me a hint on how to let SAH capacitor to charge? should I use delay?

The simplest first thing to do is to set the ADC channel to the next channel number immediately after reading the current ADC value, rather than setting the ADC channel just before starting the conversion.  This give you some "free" SAH settling time, which may or may not be enough depending on what is driving the ADC channels.

 

So do this:

Start conversion

Read ADC value

Set MUX to next channel

...Do other stuff...

 

Rather than this:

Set MUX to next channel

Start conversion

Read ADC value

...Do other stuff...

 

Last Edited: Thu. Jul 11, 2019 - 05:45 PM