## atmega16 ,bascom avr, ADC speed

18 posts / 0 new
Author
Message

hi all

here are the current settings adc

`Config Adc = Single , Prescaler = 2 , Reference = Avcc   `

with such settings the ADC operates at a frequency of approximately 50 000 hz

there are 2 questions

1 if the speed ADCs 50khz , the speed of the generator ADC - 50khz*1024= 50 Mhz ???

2 what are the settings you need to get even more high-speed ADCs.
I mean to get more speed 50khz?

What is a "generator"? Oh and your calculation makes little sense.

With the ADC clock at 50kHz the ADC clock period is 20us. It takes 13 clocks to make a conversion so your conversion time will be 260us. You can therefore make 3846 conversions per second so your sample rate is 3.846ksps.

```PORTB.1=0 'LED Off
For X = 0 To 50000 Step 1
Next X

PORTB.1=1 'LED ON
```

the led lights up after 1 second

then there was 50 000 transformations for 1 second?

You might want to review this recent thread:
https://www.avrfreaks.net/index.p...

In practical terms, the AVR8 ADC is good for about 10ksps. If you require a much higher sampling rate then it really isn't suitable.

The related question is what are you going to do with all this information? Where are you going to put it?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Quote:
The related question is what are you going to do with all this information? Where are you going to put it?

the main thing that was information,warehouse I'll find)

damn , I don't know, gives still atmega 10bit 50000 adc-conversions per second, or not?
or only 3.846ksps?

why do people write that ADC with 8 bit settings,can get the result 200 000 in second?

```PORTB.1=0 'LED Off
For X = 0 To 50000 Step 1
Next X

PORTB.1=1 'LED ON ```

and why the led lights up after 1 second,
because the variable is written 50000 results ADC?

The Mega16 data sheet says that the ADC can do 15 k Samples/Sec at full resolution.

The Xmega's, also supported by Bascom, can sample at much faster rates.

What clock speed are you running the uC at?

JC

`Config Adc = Single , Prescaler = 2 , Reference = Avcc`

Indeed, with this you can get 50000 conversions per second.

But!!

Quote:
the successive approximation circuitry requires an input clock frequency between 50
kHz and 200 kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the
input clock frequency to the ADC can be higher than 200 kHz to get a higher sample rate.
So your adc-clock is 20 times higher than recommended max 200 kHz.
The conversion results will hardly be usable ( I did not test).

I use crystal at 8MHz

```\$regfile = "m16def.dat"
\$crystal = 8000000
\$hwstack = 32
\$swstack = 10
\$framesize = 40
```

Quote:

The Mega16 data sheet says that the ADC can do 15 k Samples/Sec at full resolution.

Quote:
Indeed, with this you can get 50000 conversions per second.

Even here ,one says that it is impossible ,the other one says you can..where's the truth?

Quote:

Quote:
Indeed, with this you can get 50000 conversions per second.

Did you read the continuation to that?

Quote:

But!!
Quote:
the successive approximation circuitry requires an input clock frequency between 50
kHz and 200 kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the
input clock frequency to the ADC can be higher than 200 kHz to get a higher sample rate.

Also please understand the difference between the frequency of the input clock to the ADC and the sample frequency. The numbers 50 kHz, 200 kHz etc above are input clock frequencies.

As also is clear, both from the data sheet and earlier posts here, the ADC needs 13 such clocks to produce values of the maximum resolution.

Now it is down to simple maths: 200 kHz / 13 is what? Oh... 15.4 kHz. There is your max sampling frequency at full resolution.

It is also stated that the ADC uses "successive approximation", i.e. with each clock it determines the digital value with better precision. So you can read the ADC e.g. 10 clocks after it started the conversion. But your precision will suffer.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

for normal operation the desired settings \$crystal = 8000000 Prescaler = 32 ?

You can run an experiment. Use an avr with 4k ram (mega1280). Feed a sawtooth wave from 0 to 5V into the a/d. Fill up a buffer with 1024 samples. Dump buffer and check that a/d reads correct value at each sample. Increase sawtooth freq until a/d 'lags behind' and reports a reading that is too low. This is as fast as you can sample and get a good value.

Imagecraft compiler user

Quote:
for normal operation the desired settings \$crystal = 8000000 Prescaler = 32 ?

How come I dislike reading through a post, perhaps look things up and take time writing down an answer that I hope will clear things up as best possible ... just to get a totally unconnected answer in return?

I'm out.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Quote:
for normal operation the desired settings \$crystal = 8000000 Prescaler = 32 ?

Let Bascom set it for you.

`Config Adc = Single , Prescaler = Auto , Reference = Avcc`

Edit:

Quote:
PRESCALER
A numeric constant for the clock divider. Use AUTO to let the compiler generate the best value depending on the XTAL