Poll
Question: Help... Data Files ...
data files - 1 (100%)
create new - 0 (0%)
Total Voters: 0

Pages: [1] 2 3 ... 6   Go Down
Author Topic: FileLogger  (Read 7426 times)
0 Members and 1 Guest are viewing this topic.
Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've created a new library for Arduino to append data to files in microSD memory cards. It is based on previous work by David Cuartiello, and it has been used in GPSLogger by Raúl Hevia.

This project focus in just one simple functionality: logging data to a file in SD cards from Arduino boards.

We are trying to get it 1) fast and 2) small, so this library can be used in other projects based on arduino with little impact on memory resources and performance.

By now, it takes about 175 mSecs to append 512 bytes to the file, so transfer rate is about 2925 bytes per second.

The library memory footprint is:

    * 3764 bytes in program memory (Flash)
    * 542 bytes in data memory (SRAM)

Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The library has been contributed as OpenSource unde GPL license, you can find source code here:
http://code.google.com/p/arduino-filelogger
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the SD card need to be prepared in any fashion, does it need to be formatted a certain way, before using it with this library?

Does the card need to have a file created, with a particular label,  before using it with the library?

Can data be added to more than one file on the SD card?

Using FileLogger, where would data be entered on the arduino board (which pin, or pins)?

My Hardware/Libraries already has an MMC folder, I'm assuming that it will be different from MMC folder that the FileLogger requires, which would result in a conflict. (I'm assuming)

Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi prakat,

yes, the SD card need to be formated with FAT16.
You need to create a file in the root folder, the name is not important as you will give the name of the file when you call the function append(). In fact you can log to more than one file specifying differente file names. The only restriction for the files is that the size must not be zero (at least one character must be written before using the liberay).
This library has been tested with the microSD shield by Libelium: http://www.sensor-networks.org/index.php?page=0827727742
Anyway I guess this should  work with any SPI aware shield.
There should be no conflict with mmc library, as I didn't modify it.

Hope this help
Logged

Denver
Offline Offline
God Member
*****
Karma: 19
Posts: 778
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks edugarcia!
I am looking forward to trying this out.

So far, I can't get the example to compile. I get:
In function 'void loop()':
error: 'File_logger' was not declared in this scope


The 3 .o files were created when I started the IDE. Am I missing something?

John
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

John,

try to update from subversion, I changed the example some days ago and forgot to change the example code. The point is that from now on you should use FileLogger::append() instead of File_logger.append().

sorry about it,

Eduardo.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How is data read from the SD card?
Can data be entered directly to a PC from the card via USB ?

Thank you for your previous information.  smiley
Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Pakrat,

yes, data can be read directly from PC. You can open the file with any text editor (i.e. notepad).
Logged

Denver
Offline Offline
God Member
*****
Karma: 19
Posts: 778
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Eduardo,
What's your experience regarding when you can pull the card? Must power be off?
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

John,

in my experience you can pull the card anytime, I haven't had any special care about it and never lost data.
Anyway, I have found from time to time (maybe 1 in 20 times) that the system doesn't recognise the card after inserting it, so write fails (the function append() returns != 0). A friend has proposed a workaround: to write some header in the file before writing the real data. If this write fails, the led blinks five times to inform, so you should remove and re-insert the card. It isn't a perfect solution, but it works.
Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I've uploaded a new release of the library, V05.
I have removed from MMC the SPI related code, and I have coupled MMC to the Arduino SPI Library instead, as some of you have reported having problems with SPI and this library.
By the way, if you are using SPI in your projects, you can remove Spi.cpp from FileLogger library, it will work.
Together with some small changes in code, we have won 163 bytes in Flash memory in this release, so total size is 3601 bytes now.

Enjoy it,

Eduardo García.
Logged

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

Will this library tolerate the following scenario?

1 - I write several lines to the SD Card
2 - I remove the SD card and re-insert it
3 - I write more lines to the SD Card

I am trying it with your example code, and I get file errors when I try to write after re-inserting the card.  The only way to fix it seems to be resetting the Arduino.

Thanks.
Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

RB123,

I guess there is some conflict with the monitor serial libraries that I'm using to read keystrokes and write messages, so from time to time I have found such errors, but I think if you use fileLogger in a standalone application, with no monitor, it will work fine.
Anyway, there is a workaround: anytime you find errors writing after re-inserting the card, close and reopen the serial line (click on the icon at the upper right). This will not reset Arduino, only the serial line.
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@RB123, I had the same problem (I am using the SD card socket from Sparkfun, not MicroSD, with a Panasonic card). Also, mine is running on solar and if the voltage dropped and then came back up, the card would stop working.

I made a change in nanofat.cpp (this is a TOTAL hack, but I may go through it again when I have time). Basically it was erroring out in locateFileStart when it called mmc::readSector. I added code to line 183, after the second-to-last closing bracket in the function:
  
Code:
} [glow]else {
   mmc::initialize();
  }[/glow]

  return false;

So it will still return false to show it had an error, but it will reinitialize the card and usually works on the next write, although sometimes it take 2 writes to kick it back on.

I anybody with better coding skillz wants to improve on my hack, feel free.  smiley-grin
Logged

Santhià - Vercelli - Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm using FileLogger lib.
I would like to create a function for logging info bat i have a problem with variables:

my code:

Code:
void write_log(char msg[]){
 unsigned int length = (strlen(msg)+1);
  byte buffer[length];
  buffer = msg;
  FileLogger::append(FILE_LOG, buffer, length);
  }


on my loop:

Code:
write_log("test 123 prova 123");

but error generated
Code:
In function 'void write_log(char*)':
error: incompatible types in assignment of 'char*' to 'byte [(((unsigned int)(((int)length) + -0x000000001)) + 1)]


please help me?

thanks!!

Logged


Pages: [1] 2 3 ... 6   Go Up
Jump to: