file: swndcflash.html
18 Dec 2009

CompactFLASH CARD STORAGE FORMAT - SONICWND53

The following describes the data storage and record format of CompactFLASH memory cards used in ASIMET instrumentation with Ver4.xx and later firmware.

CompactFLASH card sectors of interest:


Description of WND data file beginning at Sector 322

The CFLASH data file (yourname.DAT) consumes most of the CompactFLASH card. Each record is 1212 bytes long, containing the date and time written, 60 minutes of Wind Velocity East data, 60 minutes of Wind Velocity North data, 60 minutes of Wind Speed data, 60 minutes of Wind Speed Max data, 60 minutes of Last XY direction data, 60 minutes of Last Compass direction data, 60 minutes of Tilt X data, 60 minutes of Tilt Y data, 60 minutes of Gill Speed of Sound, 60 minutes of Gill Temperature, a flag which is set to 0xA5A5 when the record is written, and a 2 byte CRC of the previous 1210 bytes (currently not used, set to 0 always). The actual C language struct is reproduced here to show the format of the stored image. Most values are packed.

   
   /* this is the WND data record structure, 1212 bytes */
   struct WND_record
     {
     struct time_type time1;         /* 8 bytes of time */
     short Ve[60];                   /* 60 minutes of Vel East data */
     short Vn[60];                   /* 60 minutes of Vel North data */
     unsigned char WSpeed[60];       /* 60 minutes of WS data */
     unsigned char WSMax[60];        /* 60 minutes of Max WS data */
     unsigned short LastXYDir[60];   /* 60 minutes of Last XY Dir data */
     unsigned short LastCompass[60]; /* 60 minutes of Last Compass data */
     char TiltX[60];                 /* 60 minutes of Tilt X data */
     char TiltY[60];                 /* 60 minutes of Tilt Y data */
     float GillSOS[60];              /* 60 minutes of Speed of Sound */
     float GillTemp[60];             /* 60 minutes of Gill Temperature */
     unsigned short used;            /* set to 0xA5A5 upon record write */
     unsigned short wnd_CRC;         /* CRC of previous 738 bytes */
     };


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


Note that time structure is NOT ANSI-compatible.


Data packing - this is the packing code from the WND instrument

     /* every minute, from 0 to 59, pack and store the record */
     
     /* Vel data 0 to +/- 49.99 m/s packs to 0 to +/- 4999 */ 
     WND_data.Ve[t_time.min] = (short)(vel_east * 100);
     WND_data.Vn[t_time.min] = (short)(vel_north * 100);
     
     /* speed data from 0 to 50.0 m/s packs to 0 to 250 (.2 resolution ) */
     WND_data.WSpeed[t_time.min] = (unsigned char)(speed_avg * 5);
     WND_data.WSMax[t_time.min] = (unsigned char)(speed_max * 5);
     
     /* XY Dir (like vane) data from 0 to 359.9 packs to 0 to 3599 */
     WND_data.LastXYDir[t_time.min] = (unsigned short)(sonic_deg * 10);
     
     /* compass data from 0 to 359.9 packs to 0 to 3599 */
     WND_data.LastCompass[t_time.min] = (unsigned short)(comp_deg * 10);
     
     /* tilt data from 0 to 25.0 packs to +127/-128 (.2 resolution) */
     WND_data.TiltX[t_time.min] = (char)(tilt_x_avg * 5);
     WND_data.TiltY[t_time.min] = (char)(tilt_y_avg * 5);

     /* Gill Speed of Sound and Temperature (not packed) */
     WND_data.GillSOS[t_time.min] = gill_SOS;
     WND_data.GillTemp[t_time.min] = gill_Temp;

Data is written to the FLASH card immediately following the acquisition of all 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. The "Last" values of compass and vane are taken from the last 5 second vector averaging period of the minute, just prior to writing the record.


*** IMPORTANT NOTE ***

The byte order of the all numeric values stored by the SONICWND53 firmware is reversed relative to Intel-based PC's. That is, a long integer (4 bytes) or short integer (2 bytes) stored by a PC will be LS byte first in memory, and floats with mantissa first. The SONICWND53 firmware stores shorts and longs with MS byte first in memory. Also, single precision IEEE float values are big-endian. This must be accounted for when processing the data. 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     SEEEEEEE   EMMMMMMM    MMMMMMMM   MMMMMMMM

            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)