I want to acquire 16 bit data (initially we can try for 8 bit too) at sampling rate of 2MSPS,
during acquisition all the data must be store into memory location so that after acquisition, we can send it to excel spreadsheet via serial.
My data format will be in binary (either 0 or 1), my data must be store with sample number and time if possible so that i can count that no missing event at all.
Suggest me how to code and need example code too, i refered to SUMP but i do not want to be use SUMP protocol.
Thanks a lot AWOL, can u suggest me any other controller? can i do with DUE or something else i am open for all. i have seen that people have done 3MSPS with UNO. i do not know how do they do it. on youtube videos i have seen somewhere..
How many samples do you want?
Even if you only had eight bit samples, you'd fill the available memory in a Uno in under a millisecond if you sample at 2MSPS.
(Eight bits is potentially easier than sixteen on a Uno because you can read a port in one instruction, but that would be port D which has two pins reserved for the serial interface, which, for you, is . . . awkward)
for (x=0; x<3000; x=x+1){
dataArray[x] = PIND; // only 8 bit port on Uno
}
I don't think that will run at 2 MSPS on a 16 MHz processor, needs more than 2 clocks per a pass thru loop. Need a '1284P with 16K SRAM or a 2560 with 8K SRAM.
Might be close if you had 3000 lines of
dataArray[0] = PIND; // check which 8 bit ports to use
dataArray[1] = PIND;
dataArray[2] = PIND;
:
:
dataArray[2998] = PIND;
dataArray[2999] = PIND;
16 bit samples, 1/2 the speed again, using two 8 bit ports of a '1284P or a 2560:
Okay, Thank you crossRoads. can u tell me what can be maximum Sampling rate and how much maximum data samples each line , i will achieve using both UNO and Mega. it seems that it is really difficult to achieve. should i go for Core Code.
is there any way to using MCP2317 parallel SPI. and then loading into memory of Microcontroller. is there anyway like this..?
I don't have an Arduino with me.
Do this (declaring things globally as needed)
byte dataArray[1000];
unsigned long startTime;
unsigned long endTime;
unsigned long elapsedTime;
unsigned int x;
void setup(){
startTime = micros();
for (x=0; x<1000; x=x+1){
dataArray[x] = PIND; // only 8 bit port on Uno
}
endTime = micros();
elapsedTime = endTime - startTime;
Serial.begin(9600);
Serial.print("1000 samples, time in uS = ");
Serial.println(elapsedTime);
}
void loop(){}
Ok, so one method will yield 3000 samples in 4.152mS, hardly close to 2MSPS.Try the next method:
byte dataArray[1000];
unsigned long startTime;
unsigned long endTime;
unsigned long elapsedTime;
unsigned int x;
void setup(){
startTime = micros();
dataArray[0] = PIND; // only 8 bit port on Uno
dataArray[1] = PIND; // only 8 bit port on Uno
dataArray[2] = PIND; // only 8 bit port on Uno
dataArray[3] = PIND; // only 8 bit port on Uno
// repeat until you get 1000 samples:
dataArray[998] = PIND; // only 8 bit port on Uno
dataArray[999] = PIND; // only 8 bit port on Uno
endTime = micros();
elapsedTime = endTime - startTime;
Serial.begin(9600);
Serial.print("1000 samples, time in uS = ");
Serial.println(elapsedTime);
}
void loop(){}
You can improve speed by disabling interrupts prior to starting sampling and then re-enabling then, but you'll need an oscilloscope or some other external tool to measure the time by measuring a pin going high at the start of capturing and low at the end of capturing.
Did you create the 1000 read lines?
If so, then 3000 byte samples will take 0.576mS
2 million samples/second = 1 million samples/0.5second = 1000/.0005second, so about 1/3 of what you wanted.
1/6 of what you wanted for ints.
can you tell me how to send this data out in excel sheet with actual time of each sample like we got 1000 samples 192 microseconds, so for each sample would be 1000/192=5.2083 microsecods means 8 bit or 1 byte data at rate of 5.2083 microseconds. so i want this time too.
Thank you so much for the support.
can i write this same problem on Arduino DUE forum.