Go Down

### Topic: Sampling rate verification (Read 3345 times)previous topic - next topic

#### dc42

#15
##### Nov 11, 2012, 03:50 pm
You code uses the conversion complete interrupt to trigger a new conversion. By then you've probably missed the boat and need to wait an extra ADC clock cycle or two to start the new conversion. I think you need to put the ADC in continuous conversion mode to achieve the quoted maximum conversion rate.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### dhenry

#16
##### Nov 11, 2012, 03:52 pm
I got 31128hz.

You can do the math but you will find that it takes 250 ticks to finish adc and to flip the pin. So the pin flip has a period of 500 ticks -> 32Khz.

#### dhenry

#17
##### Nov 11, 2012, 04:01 pm
The highest I can get is 38647hz (latency is not an issue here).

That confirms the 77k sample rate in the datasheet.

#### chung

#18
##### Nov 11, 2012, 04:05 pm

You code uses the conversion complete interrupt to trigger a new conversion. By then you've probably missed the boat and need to wait an extra ADC clock cycle or two to start the new conversion. I think you need to put the ADC in continuous conversion mode to achieve the quoted maximum conversion rate.

Bingo! I switched to free-running mode and the frequency rose up to 38.46kHz!

#### chung

#19
##### Nov 11, 2012, 04:10 pmLast Edit: Nov 11, 2012, 04:37 pm by chung Reason: 1

I got 31128hz.

Why do I get 29.4kHz on single conversion mode?  :~ :0

Update...

OK, I figured out why I get a lower frequency... The signal I measure with my oscilloscope is noisy. Maybe, some capacity creates what is shown on the attached image.

After processing the data with Matlab, I also get 31kHz for the single conversion mode and 40.7kHz for the free running mode.

#### dhenry

#20
##### Nov 11, 2012, 04:39 pm
Hopefully by now you have figured out why the falling edge isn't so sharp.

#### chung

#21
##### Nov 11, 2012, 05:38 pmLast Edit: Nov 11, 2012, 05:53 pm by chung Reason: 1

Hopefully by now you have figured out why the falling edge isn't so sharp.

Yes, I just figured it out. I had connected a LED (and a resistor) between the output of the pin and the GND  smiley-lol. I removed the LED and now I get a nice square wave @38.17kHz.

Update: FIY: The highest achievable rate (wrt the generated pulse) in free-running mode was 121.4kHz.

Go Up