You Are Here: Home » AVR ATmega Projects » Memory - Storage Projects » SD card logger library with log rotation that fits on ATmega8

SD card logger library with log rotation that fits on ATmega8




This library implements an SD card Data Logger that runs on ATmega.
It has a small footprint, so it can be loaded on an ATmega8, leaving space for user code.
It supports SD and microSD cards formatted with FAT16.
It also features log rotation.SD card logger library with log rotation that fits on ATmega8The “Petit FAT File System Module” by ChaN (http://elm-chan.org/fsw/ff/00index_p.html) it is used to write on SD card. I’ve used the Petit library because i would like to build a small footprint logger. Even if it has a few limitations, those can be circumvented.

We had to format the card we would like to use with FAT16, and then load it with a predefined number of empty files of a know dimension. Once we have files on the card, we can write on those files.
You can create empty files by using the python helper provided in code.
Firmware side we will setup the file dimension, and file number. File dimension, can not be greater than 2^16 bytes because a uint16_t type variable it is used to store this information, also max number of files it is limited to 256, becayse a uint8_t variable it is used.

Given the number of files used by the logger and every file size, we just have to record the last written position and the file number we are using to implements the log rotation. When a file is filled up with logged data, it skips to the next one, if the file is the last one, we go back to first.
Note that Petit FAT File System Module write files using blocks, so the “seek to position” can be used only on the block dimension. Typically a block is 512 bytes.Schematic SD card logger library with log rotation that fits on ATmega8

For more detail: SD card logger library with log rotation that fits on ATmega8

Leave a Comment

You must be logged in to post a comment.

Read previous post:
A Pickup Winding machine built on an ATmega8
A Pickup Winding machine built on an ATmega8

The core of this project is an ATmega8. It features: wind counter slow startup automatic stop configurable motor speed configurable...

Close
Scroll to top