Pages: [1]   Go Down
Author Topic: 120,000 hz arduino only oscilloscope?  (Read 1804 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 1
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not looking for arduino language support for this, but if you know an answer give a shout out:
1. does the hardware behind analogRead need to be blocking?  
2. Does the performance of an analog read improve with a faster clock rate?
3. and if(!1) can you gang the analog read pins together and not have the reads interfere with each other if triggered at different (overlapping) times?

I'm just wondering because it seems that if you put the fastest crystal the atmega can stand (say 32mhz) and determine the max time for an analog read (say .05 microseconds @ 32mhz), then you could set up a timer to trigger a read every 1/6th of .05 microseconds, or 120,000 hz.  Or 60khz at standard arduino timings.  You would evenly space the reads between the analog pins as fast as possible.

Also, how does one autorange?  With an op amp and a pwm pin or something?

Anyway, I like to do mockups on my cheesey standard device, so this is how it might look on an inexpensive character display smiley  (32x20 resolution)



« Last Edit: July 03, 2008, 03:52:58 pm by dcb » Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
1. does the hardware behind analogRead need to be blocking?
I don't understand what you're asking.  The mega168 only has one ADC, which means you can only be performing a conversion on one channel at a time.  While the conversion is going on, the ADC hardware is by definition busy, but this does not occupy the processor in any way.

Quote
2. Does the performance of an analog read improve with a faster clock rate?
The ADC has its own clock (a prescaled version of the system clock).  To get maximum resolution (i.e. 10 bits), the ADC clock must be between 50 and 200 kHz.  If you don't need maximum resolution, you can run the ADC faster than 200 kHz, but the faster it is, the lower the resolution.  Note that the analog-to-digital conversion takes 13 ADC clock cycles while the ADC is running normally and 25 clock cycles to initialize the ADC and perform the first conversion.  This means that if you want maximum resolution, you will have a sample rate of around 15 kHz.

Quote
3. and if(!1) can you gang the analog read pins together and not have the reads interfere with each other if triggered at different (overlapping) times?
No.  The ADC spends nearly its entire conversion time measuring the voltage on the channel for which it is set.

Quote
I'm just wondering because it seems that if you put the fastest crystal the atmega can stand (say 32mhz)
The fastest the mega168 can run (according to its spec) is 20 MHz.  If you run it faster than this it might work (or seem to work, but it is out of spec and could lead to all sorts of obscure problems.

- Ben
Logged


0
Offline Offline
God Member
*****
Karma: 1
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Bens!  Thats exactly what I needed to know, though not what I hoped to hear smiley-wink
Logged

Houston, Republic of Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone explain what blocking means?
Logged

0
Offline Offline
God Member
*****
Karma: 1
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you call a function (i.e. analogRead), it does not return until the read is complete.  This is a very simple way to keep the order of operations in order.  Most everything in arduino is blocking, much easier to keep things straight especially for folks just learning.  So later in your program you don't need an "are you done with that analog read yet?" bit of code.  

The reasons why you might not want to block are usually performance oriented and a slightly more advanced topic.  But if a function took a long time to execute, you might want to do something else and check back later to see if the operation is done or not.  Or give it the name of a function to execute when it is completed.  That would be a non-blocking call.
« Last Edit: July 03, 2008, 05:51:59 pm by dcb » Logged

Pages: [1]   Go Up
Jump to: