0
\$\begingroup\$

I'm planning to make a data logger project with 3-axis sensor and SD card. I would like to store 3200 samples per every second on SD card. Currently I could able to store only 630 samples per second.

Someone told me writing in binary format is the solution.

Then I did accordingly.

fwrite(readings,sizeof(int16_t),6,logFile);

I can see .bin file with more data size compared to .txt or printf.

How can I get the readable ASCII format from .bin file?

I tried by using fread.

FILE *logFile = fopen(fileName,"rb");
int readings[6];
nr = fread(readings,sizeof(int16_t),6,logFile);

How can I see the readable ASCII data?.

Thank you.

\$\endgroup\$
  • 1
    \$\begingroup\$ What library are you using? This isnt code from the Arduino SD library. Edit your post and show the rest of your code \$\endgroup\$ – SoreDakeNoKoto Jan 19 '16 at 11:45
  • 1
    \$\begingroup\$ You may want to change the title of your question. You ask about reading binary data from a .bin file, not writing data to a sd-card, as this works already (as I have understood). \$\endgroup\$ – jwsc Jan 19 '16 at 12:22
  • \$\begingroup\$ regarding the writing of the data to the sd-card. If you buffer the data in memory, (for instance, have a buffer that is large enough to hold 1 second of data) read the data from the sensor into the 'appropriate' location(s) in the buffer. then, switch to a second buffer for reading the data while writing the first buffer to the sd-card, then when the second buffer is full, switch back to the first buffer for input (I.E. use double buffering) then the throughput will be massively increased \$\endgroup\$ – user3629249 Jan 19 '16 at 15:29
1
\$\begingroup\$

how can I see the readable ASCII data?

use something similar to:

printf( "\n"); 
for( int i=0; i<6; i++) 
{ 
    printf("%d ", readings[i]);
}
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.