Fast ADC measurement

Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
Post Reply
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Fast ADC measurement

Post by twesthoff »

I would like to know the fastest way to measure ADC values with a native mode device. Secondly, would an XMega device be much faster?

I would like to measure as many ADC values as possible during a 2ms interval. I would like to eliminate any loop overhead, so something like this comes to mind:

Code: Select all

Sub MeasureADC()
   a(1) = Getadc(5)
   a(2) = Getadc(5)
   a(3) = Getadc(5)
   a(4) = Getadc(5)
   a(5) = Getadc(5)
   a(6) = Getadc(5)
   ...
   a(20) = Getadc(5)
End Sub
Anyone think of any faster way?
[/code]
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Fast ADC measurement

Post by dkinzer »

twesthoff wrote:I would like to know the fastest way to measure ADC values with a native mode device.
The fastest method is to directly manipulate the ADC and configure it for free-running mode. In that mode, the ADC does continuous conversions and your code need only wait for the flag that indicate another conversion is complete. Provided that you can process the resulting data before the next conversion is completed, this will give the fastest series of conversions.

There was a previous post dealing with configuring for free-running mode:
http://www.zbasic.net/forum/about796.html
twesthoff wrote:Secondly, would an XMega device be much faster?
An xmega device will be faster by virtue of the fact that it runs twice as fast (or four times as fast compared to the 7.37MHz devices). However, it won't actually be two or four times the speed because the xmega has a 12-bit ADC while the mega/tiny devices have 10-bit ADC. This is because both ADCs require a fixed number of cycles per bit of resolution.
- Don Kinzer
Post Reply