Arduino with really fast A-to-D

I am working on a research project with some professors at my university, and I am trying to find an Arduino board that fits our needs.

We have 4 analog signals that must all be read, do some small computations, and then output a single analog signal.

Ideally, we would like to be able to do this entire process at 100kHz, but anything above 60kHz is acceptable.

Is there an Arduino (or other similar device) that would allow us to do 4 analog reads at 100kHz?

Am I correct in that the analog inputs are multiplexed into the A-to-D system, meaning that the UNO, with a max of 77kHz, could only do 19.25kHz when reading all 4 inputs?

Use an external ADC such as MCP3004

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010529 See page 21, 3-byte SPI transfer to start the conversion and then read the result back.

Yes the uno uses multiplexing inside for its 6adc you should consider parallelism as a solution. Use 4 boards in parallel.

Next step is to use interrupt driven adc. Or async adc as the standard analogread is a blocking call. To speed up even more you could consider using only 8bit samples.

Can you give an example of the math involved?

meaning that the UNO, with a max of 77kHz, could only do 19.25kHz when reading all 4 inputs?

Where do you get that from? You can only get about 10KHz from a UNO. The Due is much faster but even that will not give you 400KHz analogue reading. Most multi input A/Ds use switching on the inputs.

What kind of accuracy do you need? If speed is more important than accuracy, you can get your samples faster.

Rob brought this up, but The Girino tells how you can get 1.5MHz samples, if you are OK with 8 bit samples. I don’t know where he got his calculations from, though. I calculate the max at 1.18MHz. Still, that’s 300KHz X 4 channels.

If that isn’t good enough, you could get a teensy 3.0. The spec sheet says it has 2 16 bit ADC circuits, and max speed for 16 bits is 3 MHz? If you get both circuits running at the same time and need 4 channels, I calculate 1.5 MHz. At US$19 each, those teensies look pretty sweet.

The limitation of the 328p's ADC speed is not related to the clock speed or a sw driver, but it is related to the internal ADC sample and hold system (S/H).

The ADC must sample the incoming signal such it charges an internal S/H capacitor (~14pF) through an internal resistor (up to 100kohm) to the exact voltage as it is at the analog input pin.

When the S/H cap is "charged" enough, ADC disconnects the S/H cap from the analog input and does the ADC conversion of the internal capacitor's voltage.

The value of this internal S/H component (its RC constant) is too big for a fast 10bit conversion (as you cannot charge the internal S/H capacitor fast enough via the internal resistor because the resistor is large in its value).

So even when you make the fastest conversion in your code, the internal S/H capacitor is not being fully charged (it means charged up to the level of the voltage at the analog input's pin) and you do the ADC conversion with much less precision (ie. 7bit only).

When the S/H cap is “charged” enough, ADC disconnects the S/H cap from the analog input and does the ADC conversion of the internal capacitor’s voltage.

No.
It switches over in a fixed time, fully charged or not.

The value of this internal S/H component (its RC constant) is too big for a fast 10bit conversion (as you cannot charge the internal S/H capacitor fast enough via the internal resistor because the resistor is large in its value).

No.

The speed of charging depends on the output impedance of the source voltage you are trying to measure. If this impedance is 10K or less then there is enough time to charge the S/H capacitor in the delay between the channel switch over and the start of the conversion.

I think (from reading the datasheet) that you need to discard one sample every time you change to a different analogue input pin. That would seriously slow things.

...R

Robin2: I think (from reading the datasheet) that you need to discard one sample every time you change to a different analogue input pin. That would seriously slow things.

...R

No you don't!!!

That is only when the voltage you want to read has an output impedance that is significantly greater than 10K

@GM:

No.
The speed of charging depends on the output impedance of the source voltage you are trying to measure. If this impedance is 10K or less then there is enough time to charge the S/H capacitor in the delay between the channel switch over and the start of the conversion.

No, that statement is not correct (when talking ADC clock speeds higher than arduino’s default one), have a look into the datasheet (Figure 23-8. Analog Input Circuitry)
The only requirement to have source impedance <10k when talking max achievable conversion speeds with 328p, is an urban myth…
The speed of charging depends on the output impedance of the source voltage you are trying to measure AND the internal charging resistor, which could be in 1k-100k range (as atmel says)…

Do you actually understand the data sheet. In 23.6.1 it says:-

The ADC is optimized for analog signals with an output impedance of approximately 10 k? or less. If such a source is used, the sampling time will be negligible.

It the goes on to say:-

If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely.

Please stop spouting rubbish.

First of all, you can't correct what I was thinking when I wrote something :)

Second, I may be wrong, but how am I supposed to interpret the following - especially the last paragraph? (I'm assuming that free-running mode is necessary to get fast sampling).

...R

23.5.1 ADC Input Channels When changing channel selections, the user should observe the following guidelines to ensure that the correct channel is selected:

In Single Conversion mode, always select the channel before starting the conversion. The chan- nel selection may be changed one ADC clock cycle after writing one to ADSC. However, the simplest method is to wait for the conversion to complete before changing the channel selection.

In Free Running mode, always select the channel before starting the first conversion. The chan- nel selection may be changed one ADC clock cycle after writing one to ADSC. However, the simplest method is to wait for the first conversion to complete, and then change the channel selection. Since the next conversion has already started automatically, the next result will reflect the previous channel selection. Subsequent conversions will reflect the new channel selection.

Grumpy_Mike: No you don't!!!

That is only when the voltage you want to read has an output impedance that is significantly greater than 10K

First of all, you can't correct what I was thinking when I wrote something

Why not if what you were thinking was wrong. :P

Second, I may be wrong, but how am I supposed to interpret the following

That refers to the free running mode and when to change the channel during the free running mode.

We are not talking about the free running mode here, that mode is used when you want to read one channel many times. Here the OP is wanting to read 4 inputs one after the other as fast as possible. Therefore using the free running mode is just simply the wrong thing to use.

Using the free running mode means that you have to discard a sample after you change channels because you are always doing a conversion and so a change in channel will disrupt the conversion that is taking place at the time. In normal operation the conversion does not start until until the channel change has taken place.

Ahhh …

I was confused by the earlier reference to the Girino performance because that does use free running mode.

Just out of curiosity what’s the highest sampling frequency without using free running mode?

…R

With arduino UNO fastest I've ever reach was using this settings: // ADCSRA = 0×82; // freq = 1/4, 4 MHz. 13 cycles x 0.25 usec = 3.25 usec. Close to 4 usec per one conversion if we add up 1.5 clock cycle for Sample and Hold (S/H). The another things, that slower down process, is absent of DMA in arduino, so for every conversion complete events you have to use interrupt subroutine, and store results to memory or do something with results. Interrupt itself + few lines of code to store sample takes time too, so the fastest you can get about 150 kHz. http://coolarduino.wordpress.com/2012/06/22/audio-input-to-arduino/

To OP: 150 kHz is approximate limits for arduino UNO and such boards, the would not be any time to do math or whatever you intend to do with samples. Using external ADC isn't a cure, as again - missing DMA would require to make transfer SPI - to - memory "manually" for every sample, and it would be even slower than internal ADC registers access time, unlikely you would get even 150 k. For your application, 250 - 400 kHz better to look at leaflab maple platform, or clones based on cortex-M3 (olimexino for example). They capable to sample 1 MHz with 12-bits resolution

Use a Due with an external memory-mapped ADC...except that's very hard to do because they didn't break out all the signals.


Rob

Beagle Bone Black?

The teensy 3.0 might be enough.

I can get about 100kHz sampling rate with 16-bit samples, and write to microSD card simultaneously.
I can capture multiple pins but I don’t know if it would work for 4. Probably not. I did not write my code very efficiently in places so there’s room for improvement.

If I could do the sampling with DMA (I think others have) it would probably be able to do much more.