file: wxt24_sdhc.html
19 Dec 2017

SDHC CARD STORAGE FORMAT - VAISALA24 (WXT520) Weather Module

*** 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. ??? in each filename is replaced with the first 3 digits of the serial number specified in the UOK command under Menu #2 - MODSER.   ASWXT???.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 ASWXT???.ID file; a warning is issued in the L (status command).   ASWXT???.INF is a user-writeable file of up to 500 characters of arbitrary text, accessed via the SDOK command.   ASWXT???.DAT is the file containing the one-hour records of module data.

Description of VAISALA24 ID file

The SDHC ID file (ASWXT???.ID) contains the firmware version and PC board revision embedded in the module operating firmware. It also contains a subset of values stored in EEPROM via the UOK command. The ID file is 240 bytes long. The C data structure, with comments, is below:

/* instrument record - in ID file on SD Card - some taken from EEPROM data */
struct ID_record
	{
	char version[24];    /* version number embedded in code */
	char brdversion[16]; /* hardware board version embedded in code */
	char modmfg[16];     /* module manufacturer */
	char modmod[16];     /* module model number */
	char modser[8];      /* module serial number (used to create filenames) */
	char moddat[8];      /* module manufacture date */
	char senmfg[16];     /* sensor manufacturer */
	char senmod[16];     /* sensor model number */
	char senser[8];      /* sensor serial number */
	char sendat[8];      /* sensor manufacture date */
   	char ifbrdrev[16];   /* front-end interface PC board */
   	char ifsftrev[24];   /* front-end interface firmware & rev */
   	char ifsernum[8];    /* front-end interface serial number */
   	char ifdate[8];      /* revision date */
	char calfac[16];     /* calibration facility */
	char calper[16];     /* calibration technician */
	char caldat[8];      /* calibration date */
	char modadr[8];      /* module address */
	};

Description of VAISALA24 Data File

The SDHC data file (ASWXT???.DAT) consumes as much of the SDHC card as needed to store the one-minute data records. Each record is 272 bytes long, with parameters as described below.

The actual C language struct is reproduced here to show the format of the stored image. All float values are IEEE single-precision as described below.

 /* this is the ASIWXT24 1-minute record structure (272 bytes) */
 struct WXT_record
   {
   struct time_type time1;      /* 8 bytes of time */
   char record_size[6];         /* record size ascii */
   unsigned short rsize;        /* record size */
   float Dm_dir_avg[11];
   float Sm_spd_avg[11];
   float speed_min;
   float speed_max;
   float compass_dir[11];
   float tilt_x_avg;
   float tilt_y_avg;
   float Ta_air_temp;
   float Ua_rel_humidity;
   float Pa_air_pressure;
   float Rc_rain_accum;
   float Rd_rain_duration;
   float Ri_rain_intensity;
   float Hc_hail_accum;
   float Hd_hail_duration;
   float Hi_hail_intensity;
   float Rp_rain_peak;
   float Hp_hail_peak;
   char version[20];    /* up to 19 char of firmware version (from flash) */
   char brdversion[16];    /* up to 15 char of board version (from flash) */
   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 spare[50];
   unsigned char samp_count;
   unsigned char wndflag;	/* bad response flags */
   unsigned char rhtpflag;
   unsigned char prcflag;
   unsigned short used;     /* set to 0xA5A5 upon record write */
   };

* time structure */ 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 every 10 minutes, immediately following the acquisition of data at the end of the 9th, 19th, 29th, 39th, 49th,and 59th minute of each hour.


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

The byte order of the numeric values stored by the VAISALA24 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)