Pages: [1]   Go Down
Author Topic: Store data to SD-Card with specific structure  (Read 442 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: November 20, 2012, 11:24:26 am by nadabro » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int value;
file.write(&value, sizeof(value));

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

Code:
uint32_t size;
file.write(&size, sizeof(size));
Logged

Pages: [1]   Go Up
Jump to: