Pages: [1]   Go Down
Author Topic: How to read SD card?  (Read 531 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a column of Longitude values in  float  around 2000 values , i want to save these values into a column matrix in arduino program,ex: if 12.456 is my first value i want to save it in a variable as Long[0] and so on.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No Arduino has enough SRAM to do this. If you're intending to store this data as float or long, that's 8K, which would fill even the mega, leaving no memory for heap or stack. If it's fixed data, you could take a look at progmem to store it in flash.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Wildbill

  I have that longitude file in SD card.If not possible to save entire column in Array variable,i will do 2000 iterations to read  and write the updated value in SD card.But i have some problem i want to read 12.4565 as a single data but in Arduino it read each number as a data .How to read  as a single data?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How to read  as a single data?
You can't. There is no mechanism to read more than one character at a time. Now, there is nothing stopping YOU from saving those characters in an array, and then, when you KNOW you have reached the end of a packet, doing something with the NULL terminated (don't forget this part) character array.

Logged

italy
Offline Offline
Full Member
***
Karma: 2
Posts: 215
Muuuuu
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you can save each character and after convert with atoi function. You have to multiply numbers of the integer part in the second position by 10 on the third by 100 ecc and add them. the same for the value after the comma but dividing. For example [1][2][.][8] --> 1*10+2*1+0.1*8 =12.8 (this is not the c++ code is only to make you understand)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
you can save each character and after convert with atoi function.
That decimal point won't cause problems?

I'd use atof() myself...
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2723
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone experience with binary data in SD card files ?
Using unions and structs it should be possible to read / write any numerical data as a series of bytes.

Or is it just far more convenient to deal with something human (i.e. text editor) readable?
Logged

Pages: [1]   Go Up
Jump to: