Fast reading of a ADC

Hi,

I have an ADC which can sample up to 250kSPS. I communicate with it via SPI.
My Question is what is the fastest possibility to get the data on the pc?
So should I write all the values in an arry and at the end I read the array? How many values can I wirte in one Array?

Second question is what is the fastest posibility to get every value immediately. Is there only the Serial.println command or is there a faster solution?
At the moment I do it like this, but this is very slow:

void Continuousconversation(long numbers){
  int Outputstate=1;
  digitalWrite(CS, LOW);

for (int i = 0; i <numbers; i++) {

Outputstate=1;
   while (Outputstate==1){
  Outputstate=digitalRead(DOUT);
 }
unsigned long Data_Register= readRegisterconversion(0b01000100, 3);

Serial.print(Data_Register);
Serial.print("\t"); 
Serial.println(Data_Register,BIN);
//delay(100);
}
digitalWrite(CS, HIGH);
}

Thanks for your answers.

How many values can I wirte in one Array?

How much memory do you have?

So should I write all the values in an arry and at the end I read the array?

At the end of what?

My Question is what is the fastest possibility to get the data on the pc?

For what purpose? As ASCII data or as binary data?

Second question is what is the fastest posibility to get every value immediately.

Get every value from what?

  1. I have a Arduino Nano. The size of one value of the ADC is 24 bit. So how many values can I store in an array? Because when I use 250kSPS there is a big number of values I get.

  2. At the moment it works like this: I get a value via SPI, then I send it to the PC via Serial.println, then I read the next value. This is too slow. The question is if there is a faster solution for this.
    If not I woult store all values in an array and at the end of the measurement I would read the array and send it to the pc. This is faster, but I woult get all the values only after the measurement.

  3. I get the value via SPI. This is a 24 bit value. This value I would like to have on the pc.

  4. The fastest way to read the value of the ADC which is a 24bit word

I have a Arduino Nano.

Which has a fixed amount of memory that YOU can look up.

The size of one value of the ADC is 24 bit.

which won't fit in a 16 bit int, so you'll need to use 32 bit longs.

So how many values can I store in an array?

Simple math. Free memory / size of one value = number of values.

Because when I use 250kSPS there is a big number of values I get.

What, exactly, are you using the 24 bit ADC to read?

  1. At the moment it works like this: I get a value via SPI, then I send it to the PC via Serial.println

Which converts the long to a string, and sends the string and a carriage return and a line feed.

The question is if there is a faster solution for this.

Of course. Send the data as binary, and let the PC deal with the 4 bytes.

If not I woult store all values in an array and at the end of the measurement

At what "end" Supposedly, you are reading a continuous stream of values that doesn't have an end. If "end" is defined as "when the array is full", say so.

  1. I get the value via SPI. This is a 24 bit value. This value I would like to have on the pc.

Fancy tap dancing + no code == no help.

  1. The fastest way to read the value of the ADC which is a 24bit word

Do you really have a choice? Can you really use something other than SPI? If so, why did you choose SPI in the first place?

Thanks for this :wink:

What would be the command to send it as binary code?

What would be the command to send it as binary code?

Serial.write("it");

How long do you want to read the data for ? Do you want to read the data continuously for a long time ? Or do you want to read a relatively short burst of data with as many samples as possible ?

Do you actually get, and can you actually use, 24 bits of resolution ? It's likely that you don't. You may be able to use the most significant 16 bits of the data, which will simplify matters and speed up considerably.

There seem to be 2 limiting factors here.

You can't send 250,000 bytes per second over a serial connection to a PC (never mind 250,000 INTs or LONGs).

That means if you want to read at the full speed you can only read as much can be temporarily saved on an Arduino. On an Uno that probably means 1000 bytes (i.e. 250 x 32bit samples).

I have a somewhat similar project - but using a high speed 8 bit ADC and I concluded that there was no role for an Arduino or other MCU. I wrote a PC program to read the data straight into the PC using an FTDI UM245R board. It's a while since I used it and I can't remember what the data rate is - I think it was better than 1 Msps.

...R

On an Uno that probably means 1000 bytes (i.e. 250 x 32bit samples).

333×24 bit samples, surely?

AWOL:

On an Uno that probably means 1000 bytes (i.e. 250 x 32bit samples).

333×24 bit samples, surely?

Perhaps, but I didn't know there was a 24bit data type. It hardly makes much difference.

...R

Robin2:

AWOL:

On an Uno that probably means 1000 bytes (i.e. 250 x 32bit samples).

333×24 bit samples, surely?

Perhaps, but I didn't know there was a 24bit data type. It hardly makes much difference.

...R

There isn't a 24 bit data type, but any gain in capacity (+33%!) must be worthwhile in such a resource-limited environment

There isn't a 24 bit data type, but any gain in capacity (+33%!) must be worthwhile in such a resource-limited environment

How do you envision a 33% gain in capacity, when the smallest appropriate data type is 4 bytes? Just asking.

PaulS:
How do you envision a 33% gain in capacity, when the smallest appropriate data type is 4 bytes? Just asking.

The smallest appropriate native data type is 32 bits. Nothing stopping you from defining a 24 bit type if you want, though.

The smallest appropriate data type is a byte, and you can use three of those to store each value.