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);
}
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.
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.
I get the value via SPI. This is a 24 bit value. This value I would like to have on the pc.
The fastest way to read the value of the ADC which is a 24bit word
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?
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.
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.
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?
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.
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.