Datalogger Use

From DIDEAS Wiki
Revision as of 16:36, 12 October 2005 by 146.115.56.212 (talk)
Jump to: navigation, search

[BACK]

Programming the Datalogger

  • Complete the software and hardware setup
  • From the datalogger source code directory, build and download the package by typing "make download". The download should take less than 1 minute. After the download, jtag-talk will be run and will program the clock.
  • some other commands:
  • make - just build the project, don't download
  • make clean - clean up the project in preparation for a total rebuild
  • make clock - start the "jtag_clock" program that will attempt to talk with the datalogger and set it's clock
  • reset - a batch script that resets the datalogger

SD Card Preparation

The SD Card preparation is essentially a process of wiping the card with a known value and also creating a single sequential file in the card's root directory.

The following information was created and verified using Windows 2000 SP4.

Format card using FAT16 and largest allowable cluster size:


format <drive_letter> /FS:FAT /A:16K /V:

(/A:8192 for 64MB MMC card)


A cluster size of 16K was the largest permitted with the SD 128MB card. Possibly a smaller cluster size will need to be used with a smaller SD card. (Large cluster size means that FAT is smaller (which isn't used anyway) - and thus more space is available for logging)


If format doesn't report the drive size, use chkdsk <drive letter> to determine the size of the SD card. The card size is reported in bytes, but then may also be given in "allocation units". If so - record the allocation units and the cluster size.


Use "genfile" to write a file named "timing00.bin" that fills the SD card. This binary file contains a single value 0xFF and is designed to overwrite previous data on the card and most importantly to cause windows to create a single FAT file chain the starts with cluster 2, 3, 4, 5, ..., last available cluster.


Example : genfile n:timing00.bin 7666C 0xFF 16k


Finally before removing the SD card, flush file system buffers. You can use the cygwin "sync" command, or rom explorer, right click on the drive letter representing the SD card, and select eject.

Shortening the Preparation Procedure

Format and genfile can take several minutes to complete for a large card.

When "wiping" the card, the procedure may be shortened if you know that only small portion of the card has been overwritten. For example its not necessary to reformat the card every time, nor is it necessary to use genfile to fill the entire card. However, it is necessary to format and fill the entire card before the first use.

How the datalogger chooses where to write data on the SD card

The datalogger only consults the SD card's FAT when the card is inserted and thus does not modify the FAT or follow it. (Using the FAT to direct the write activity would require additional RAM and/or require additional power / time to frequently read the FAT). At insertion the partition table, boot record, and root directory are analyzed ultimately to find the cluster number of a single file "timing00.bin". If the file doesn't exist then the logger stops and waits for a card insertion event. If the file is found then the starting cluster is read and from that the LBA (logical block address) of the start of the file is calculated. The datalogger will then use a binary search algorithm to search the card's complete data area to locate "end of file" (the size of the file in the FAT isn't used). End of file is defined as the last sector that does NOT start with 4 bytes of 0xFF. Writing will commence with the first LBA that does contain 0xFFFFFFFF and will continue sequentially though the entire data area of the card.

Storing Extra Data on the Card

  • The datalogger makes use of the first partition that is of type FAT16. Creating a non FAT16 partition, or a 2nd FAT16 may be used for alternative applications
  • Small amounts of information may be stored in the root directory as the filename. There are two restrictions.
  1. The datalogger file must be in the first sector of the root directory (with in the first 32 file name entries files)
  2. The maximum size of the root directory not be exceeded

(Remember - long file names take more than one directory entry)

  • Actual files may be placed in the same partition as the datalogger file so long as
  1. the clusters precede the first cluster of the datalogger file
  2. the datalogger file - cluster chain not be fragmented.


These requirements are easily accomplished by following the following preparation sequence:

  1. format the card
  2. write the non-datalogger files
  3. write the datalogger file