Data acquisition/Logic Analyzer

Hi guys,

I have arduino mega and uno both.

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 .

2MSPS on a 16MHz processor is a bit optimistic, don't you think?

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..

Please feel free to suggest me the solution.

Thanks

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)

i need 3000 samples in single acquisition. i have arduino MEga 2560 and Arduino DUE , so can you suggest me something on these controllers too.

Thank you

You mean 3000 samples of digital data? Such as:

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:

for (x=0; x<6000; x=x+2){
dataArray[x] = PIND;
dataArray[x+1) = PINC;
}
[code]

And:
[code]
dataArray[0] = PIND;
dataArray[1] = PINC;
dataArray[2] = PIND;
dataArray[3] = PINC;
:
:
dataArray[5998] = PIND;
dataArray[5999] = PINC;

[/code]
[/code]

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..?

Thank you.

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(){}

What do you get for a time?

You may want to disable timer interrupts . . .

That'll make it hard to get a time from micros(), won't it?

I upload the code , and it shows 1000 samples, time in uS = 1384. it means it takes 1.384milliseonds to acquire 1K samples. isnt it? now what to do.

Thank you

But it'll make sampling more even

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.

i upload the code and got this "1000 samples, time in uS = 192" , i also pust cli() before start sampling and sei() after sampling.

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.

Looks like you need a faster processor.

Hello, can you tell me how do i send this data to excel sheet with acquisition time of each sample.

is there any way to do so?? if we cant do with time then atleast tell me how to send out these sampled data into excel sheet.

how to read this data, i want it to excel sheet. is there any way to store actual time for each sample.?? yes it is a 1/3 of what i need.

Sure, Need a faster machine tho. I'm only here for the slower 8-bit stuff.

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.

thank you