Pages: 1 [2]   Go Down
Author Topic: Sampling rate verification  (Read 1000 times)
0 Members and 1 Guest are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The highest I can get is 38647hz (latency is not an issue here).

That confirms the 77k sample rate in the datasheet.

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino Rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

An Arduino development board costs €20~60. A pack of 20 Zener diodes to protect your board from almost certain damage costs less than €1...

Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino Rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got 31128hz.
Why do I get 29.4kHz on single conversion mode?  smiley-confuse smiley-mad

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.



* free_sampling_pre16.jpg (20.69 KB, 560x420 - viewed 36 times.)
« Last Edit: November 11, 2012, 10:37:13 am by chung » Logged

An Arduino development board costs €20~60. A pack of 20 Zener diodes to protect your board from almost certain damage costs less than €1...

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino Rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* free_sampling_pre16.jpg (140.09 KB, 1867x1400 - viewed 22 times.)
« Last Edit: November 11, 2012, 11:53:36 am by chung » Logged

An Arduino development board costs €20~60. A pack of 20 Zener diodes to protect your board from almost certain damage costs less than €1...

Pages: 1 [2]   Go Up
Jump to: