Datalogger Use

From DIDEAS Wiki
Jump to: navigation, search


This documentation discuss laboratory use the datalogger.

Programming the Datalogger

  • Complete the software and hardware setup as described in Datalogger_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. While downloading, use the Adapt3 to verify proper programming of the unit.

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

Automation and Makefile targets

In additional to compiling and downloading the datalogger project, the makefile can automate other activities. The start of the makefile contains constants that need to adjusted to your specific environment.

  • make SD : will format the SD card and write the timing00.txt file to the card
  • make file : will (overwrite) the timing00.txt file
  • make trans : will read the timing00.txt file from the SD card and run sd_translate, creating the local file sddata.txt

These automation targets make use of sync and cygintl-3.dll available from here. Place them in your executable path.

  • make clock : will run jtag_clock - which reads the PC clock - and programs that datalogger with the current time
  • sclock.bat : is a script that like make clock sets the datalogger time, but it also allows a 7 character string (serial number) to specified on the command line. This value is written to the SD card upon insertion.

Makefile editable constants

  • SD_DRIVE = H

Specifiys the drive letter of the SD card.

  • SD_SIZE = 1M

Size of the file to be written by genfile.

  • SD_OUT = sdtrans.txt

When running "make trans" this is the name of the file created by sd_translate.

  • SD_CLUS = 8192

Cluster size usen when formatting. Possibly sizes, 4096, 8192, 16K, 32K. Use the largest possible for maximum SD card space. If you don't care, edit the format command and remove following "/A:${SD_CLUS}"

  • SD_NAME = timing00.bin

Name of timing datafile on the SD card as used by genfile and sd_translate. Unfortunately, at this time, this variable doesn't actually change the name inside the datalogger firmware.