file: lwr24_sdhc.html
23 April 2018

LWR24 SDHC CARD STORAGE FORMAT

*** IMPORTANT!! NOTE NUMERIC FORMAT CHANGE FROM OLDER ASIMET MODULES BELOW ***

The following describes the data storage and record format of SDHC memory cards used in ASIMET instrumentation with Ver5.xx and later firmware (on Microchip PIC24-based microcontroller hardware).

Three files are created when the SDHC card is initialized for the ASIMET module. Note that the last 3 digits of the 8 character filename are the serial number of the module. AELWRxxx.ID contains ID information from the module. This includes the firmware revision - the SDHC card will NOT store data from the module if the firmware version in the PIC24 FLASH does not match the firmware version written to the AELWRxxx.ID file; a warning is issued in the L (status command). AELWRxxx.INF is a user-writeable file of up to 500 characters of arbitrary text, accessed via the SDOK command. AELWRxxx.DAT is the file containing the one-hour records of module data.

Description of LWR data file

The SDHC data file (AELWRxxx.DAT) consumes as much of the SDHC card as needed to store the one-hour data records. Each record is 696 bytes long, containing the date and time written, record size info, 60 minutes of dome temperature data, 60 minutes of body temperature data, 60 minutes of IEEE single-precision thermopile voltage data, 60 minutes of longwave flux data, miscellaneous engineering & housekeeping data, some spare bytes, a flag which is set to 0xA5A5 when the record is written, and a 2 byte CRC (unsused) of the previous 694 bytes. The actual C language struct is reproduced here to show the format of the stored image.

/* this is the LWR data record structure, 696 bytes */
struct LWR_record
   {
    struct time_type time1;   /* 8 bytes of time */
    char record_size[6];         /* record size ascii */
    unsigned short rsize;        /* record size */
    unsigned short temp_dome[60];    /* 60 minutes of packed dome temp data: (ushort)(dome * 100) ==> 0 - 655.35 degK */
    unsigned short temp_body[60];    /* 60 minutes of packed body temp data: (ushort)(body * 100) ==> 0 - 655.35 degK */
    float volts_pile[60];            /* 60 minutes of thermopile voltage data */
    unsigned short lw_flux[60];      /* 60 minutes of packed LW_flux data: (short)(tpile * 10) ==> +/- 3276.7 microvolts */
    float v3_3,vbat;  		     /* rail & battery in volts DC */
    float brdtemp;  		     /* board temperature in degC */
    char version[24];		     /* firmware version (from code) */
    char brdversion[16]; 	     /* PC board version (from code) */
    char modser[4];      /* first 3 digits of module serial number (from eeprom) */
    char senser[8];      /* up to 7 digits of sensor serial number from (eeprom) */
    unsigned char unused[12];	/* future use */
    unsigned short used;     /* set to 0xA5A5 upon record write */
    unsigned short lwr_CRC;  /* CRC of previous 694 bytes (unused) */
   };

struct time_type { unsigned char sec; unsigned char min; unsigned char hour; unsigned char dow; /* day of week - NOT USED */ unsigned char day; unsigned char mon; unsigned int year; };

Note that time structure is NOT ANSI-compatible.

Data is written to the SDHC card immediately following the acquisition of data at the rollover to the 59th minute of each hour. This is reflected in the time stamp on each record, typically 1 second into minute 59.


*** IMPORTANT NOTE - CHANGE FROM OLDER ASIMET MODULES ***

The byte order of the numeric values stored by the ASIEPLWR24 firmware used on Microchip PIC24-based module boards is the same as Intel-based PC's. That is, a long integer (4 bytes) or short integer (2 bytes) stored by a PIC24-based module will be LS byte first in memory, and floats are stored with mantissa first. The is opposite to older VOS firmware for module boards based on Dallas Semi DS87C530 micros. See the float storage format below.


The "used" flag value is used to simplify finding the end of valid records the .DAT file; as each record is written, the "used" flag is set to A5A5h to provide a distinct pattern to search on for good records.


The CRC is NOT IMPLEMENTED.


"float" 4 byte values are IEEE-754 single-precision float.

Storage format for these float values is as follows:

      byte addr      +0         +1           +2         +3
      contents     MMMMMMMM   MMMMMMMM    EMMMMMMM   SEEEEEEE

            where S => Sign bit;  1 = negative,  0 = positive
                  E => Exponent (2's comp) with offset 127 (decimal)
                  M => 23-bit normal mantissa (highest bit always 1 and
                           therefore not stored)