Go Down

Topic: Store data to SD-Card with specific structure (Read 596 times) previous topic - next topic

nadabro

Nov 20, 2012, 05:22 pm Last Edit: Nov 20, 2012, 05:24 pm by nadabro Reason: 1
Hi.

I´m getting data from a A/D at 40SPS connected to a laptop, but i wish to store it in a SD-Card, to do some field tests. The issue is: i need to store the data to make it compatible with a software i use to plot the data, with the following structure:

-The software receives the ASCII data and stores in a *.Z file.
-It stores the data in a *.Z file per hour, one folder per day..but to make it easy, doesnt need to create folders: 0.z ; 1.z...15.z; 16.z...; 26.z;...; 30.z....
-Every Z file has a 4 byte header which tells how long the file is in samples.
-After the 4 byte header, it stores data in 16bit short words (1 sample, 1 16bit short word?).
-The *.Z file covers an entire hour so when reading it, the program figures out the sample rate by dividing the number of samples by 3600.


Before starting on the SD-Card to store the data, will the Arduino be able to work on the A/D code and save the data to a SD-Card?

If the Arduino be able to do this, how can programme it to store the data following that structure?

I aprecciate any help. If it helps, i can share some Z files.

Thanks.


pylon

Quote
Before starting on the SD-Card to store the data, will the Arduino be able to work on the A/D code and save the data to a SD-Card?


Yes, if your specification is complete, the Arduino is able to fulfill your requirements.

Quote
If the Arduino be able to do this, how can programme it to store the data following that structure?


I would read the values for perhaps a second, open the correct file, write all 40 values and close the file. Even better would be to get 256 values and store them because that fills a sector on the SD card and it will no die that fast. To write an integer use this:

Code: [Select]
int value;
file.write(&value, sizeof(value));


For the long value (4 bytes) you do the same with the other type:

Code: [Select]
uint32_t size;
file.write(&size, sizeof(size));

Go Up