file: blogr24_sdhc_rec.html
12 Jul 2018

BLOGR24 SDHC Record Format - Firmware Version 5.50 or later

*** IMPORTANT!! NOTE NUMERIC FORMAT CHANGE FROM OLDER LOGR53 BUOY LOGGERS BELOW ***

The following describes the data storage and record format of SDHC memory cards used in MET BLOGR24 buoy loggers with Ver 5.50 and later firmware (on Microchip PIC24-based microcontroller hardware).

Three files are created when the SDHC card is initialized for the BLOGR24 buoy logger. BLOGR24.ID contains ID information from the BLOGR24 buoy logger. This includes the firmware revision - the SDHC card will NOT store data from the BLOGR24 logger if the firmware version in the PIC24 program FLASH does not match the firmware version written to the BLOGR24.ID file; a warning is issued in the STAT[D] (status) command.   BLOGR24.INF is a user-writeable file of up to 500 characters of arbitrary text, accessed via the SDOK command.   BLOGR24.DAT is the file containing the one-hour records of module data.

The firmware version 5.50 record format provides for storage of data at each 1 minute sample interval. 64 bytes binary are stored per record in fixed format. Storage is based upon a 'C' language structure shown here:


/* LOGR24 64 byte packed data record structure for storage to SD Card */
struct LOGR_record
   {
   unsigned char hour;   /* time is not packed for ease of verifying */
   unsigned char min;
   unsigned char day;
   unsigned char mon;
   unsigned char year;   /* year is offset from 2000 (no good after year 2255 :-) */
   unsigned char mux_parm;  /* which option parameter in this record - unused */
   unsigned short record;   /* sequential record number from startup */
   short we,wn;   /* wind speed m/sec */
                  /* (short)(we * 100) ==> +/- 327.67 m/s */
                  /* (short)(wn * 100) ==> +/- 327.67 m/s */
   unsigned short wsavg,wmax,wmin;      /* (ushort)(wsavg * 100) ==> 0 - 655.35 m/s */
                                        /* (ushort)(wmax * 100) ==> 0 - 655.35 m/s */
                                        /* (ushort)(wmin * 100) ==> 0 - 655.35 m/s */

   short vdavg,compass;  /* last vane degrees, last compass degrees */
                         /* (short)(vdavg * 10) ==> +/- 3276.7 degrees */
                         /* (short)(compass * 10) ==> +/- 3276.7 degrees */

   unsigned short bp;   /* barometer millibars */
               /* (ushort)((bp - 900.0) * 100) ==> 900.00 - 1555.35 mbar */

   short rh;  /* humidity %, deg C */
              /* (short)(rh * 100) ==> +/- 327.67 %RH */
   unsigned short th;  /* (ushort)((th + 20.0) * 1000) ==> -20.000 to +45.535 degC */

   short sr;  /* short wave w/m^2 */
              /* (ushort)(sr * 10) ==> +/- 3276.7 w/m^2 */

   unsigned short dome,body;  /* long wave dome and body thermistors
                                 deg Kelvin, thermopile microvolts */
                              /* (ushort)(dome * 100) ==> 0 - 655.35 degK */
                              /* (ushort)(body * 100) ==> 0 - 655.35 degK */
   short tpile;               /* (short)(tpile * 10) ==> +/- 3276.7 microvolts */

   short lwflux;  /* lwr flux */
                  /* (short)(lwflux * 10) ==> +/-3276.7 w/m^2 */

   short prlev;  /* precipitation values */
                 /* (short)(prlev * 100) ==> +/-327.67 mm */

   unsigned short sct; /* SeaCat sea temp deg C */
                       /* (ushort)((sct + 5.0) * 1000) ==> -5.000 to +60.535 degC */
   unsigned short scc; /* SeaCat conductivity Siemens */
                       /* (ushort)(scc * 10000) ==> 0.000 to +6.5535 Siemens/meter */

   short v3_3,vmain,vmet,vaux;  /* misc. battery */
                               /* (short)(bat1 * 1000) ==> +/- 32.767 VDC */

   unsigned long opt_parm;    /* optional value indicated in rec_mux - unused */
   unsigned short brdtemp;  /* (ushort)((brdtemp + 20.0) * 1000) ==> -20.000 to +45.535 degC */
   unsigned char ird_stat;	   /* iridium & wmo status values */
   unsigned char wmo_stat;
   unsigned short spare1;     /* optional spare value */
   unsigned short used;         /* set to 0xA5A5 upon record write */
   };


Records may be dumped via XMODE command (very slow!) or by directly reading the SD Card on a PC.


*** IMPORTANT NOTE - CHANGE FROM OLDER LOGR53 BUOY LOGGERS ***

The byte order of the numeric values stored by the BLOGR24 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 logger will be LS byte first in memory, and floats are stored with mantissa first. This is opposite to older buoy logger firmware on LOGR53 boards based on Dallas Semi DS87C530 micros.   See the float storage format below.


A typical 64 byte binary record looks something like this (in HEX-ASCII):

0A2215040C01CE00..........F20C7E34C3C4073515CD5B0700AF00000A5A5

Wow! So now what!

First, note the following:
All integers are 2 bytes, and longs are 4 bytes, stored LS byte first.

From the structures above, note that time is stored first, so:



TIME:
Bytes 0 - 4

0A2215040C is time as follows:



MUX'ED PARAMETER NUMBER (NOT USED - more detail later...):
Bytes 5

SEQUENTIAL RECORD NUMBER:
Bytes 6,7

A sequential record number is kept from power up - possibly useful for untangling problem data records with bad time



DATA VALUES (more detail later...):
Bytes 8 - 61

Refer to the 'C' structure above for position and packing of each 2-byte integer data value (remember, LS byte first)



USED TAG
Bytes 62 - 63

These bytes are used to indicate the end of a record written into SD Card storage. The "used" flag value is used to simplify finding the end of valid records in the .DAT file; as each record is written, the "used" flag is set to A5A5h to provide a distinct pattern to search on for all valid records.


"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)