file: sm24_rec.html
6 Feb 2004

SAMPLER24 CPU FLASH Record Format - Firmware Version 1.20

FLASH records are written once per logging interval (once per minute typically). The FR command reads records one at a time, beginning at record 1 unless a different record number is entered at the prompt. The final line STAT: follows the format of the last 4 values of the D command, with an indicator of 1 if the system is currently sampling, 0 if it's not, then three HEX values of system status, maincpu status, and sample handler status. See the C structure below for the bit breakdown of the 3 HEX status values.

The FB command can be used to look at the raw HEX values in the FLASH card in 512 byte blocks, in 16 lines of 32 bytes each. The first 256 blocks of the FLASH card are reserved and currently UNUSED on the SAMPLER24 CPU. The raw block location that corresponds to the first data record is Block 257. If you enter 257 at the FB command prompt, you will actually see the raw values of the first 16 records shown by the FR command, since the record size conveniently is 32 bytes. The record format follows the C structure below.


Note the following:
All integers are 2 bytes, stored MS byte first
All floats are IEEE-754 Single-Precision float standard, stored mantissa first:

i.e. memory address 0,1,2,3 => MMMMMMMM MMMMMMMM EMMMMMMM SEEEEEEE
where:


/* SAMPLER24 data record structure for storage in FLASH */
struct SAMP24_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 short record;   /* sequential record number from startup */

   float wsavg;                    /* wind speed m/s */
   unsigned char rain_detect;      /* rain detector 1 = RAIN */
   float flow_meter[2];            /* flow meter values */

   unsigned char fm_status;        /* flow meter status flag, meter 0 or 1 in use */
   unsigned char curr_sample_num;  /* number 0-23 of sample position currently in use */
   unsigned short curr_elapsed;    /* elapsed minutes on the current sample */
   unsigned char last_position;      /* from sample handler status message (GOCW value) */
   unsigned char last_sample_num;    /* from sample handler status message (GOCW value) */
   unsigned char system_status;  /* status byte:
                                bit 0 - sample_OK 
                                bit 1 - WIND speed OK
                                bit 2 - NOT raining - RAIN OK
                                bit 3 - XMET OK
                                bit 4 - PUMPS on
                                bit 5 - INTAKE open
                                bit 6 - INLET valve open
                                bit 7 - PLATTER position_sample successful (i.e. platter is where it belongs for this sample)
                                */

   unsigned char maincpu_status;  /* status byte (1 = ON or TRUE):

                                bit 0 - samphndl power - always ON 
                                bit 1 - wndrain power - always ON
                                bit 2 - inlet power
                                bit 3 - unused
                                bit 4 - samphndl OK (comms OK)
                                bit 5 - wndrain OK (comms OK)
                                bit 6 - inlet OK (comms OK)
                                bit 7 - unused
                                */

   unsigned short sh_status;    /* sample handler status "word":
                                - power control: LOW = ON
				- limit switches: HI at limit
				- dir control: LOW = CW

				bit 0 - purge valve power 
				bit 1 - analog 0 power
				bit 2 - analog 1 power
				bit 3 - encoder power - always ON
				bit 4 - motor 2 CW limit (intake) - closed
				bit 5 - motor 2 CCW limit - open
				bit 6 - NOT USED - motor 3 CW limit (xrf/analyze)
				bit 7 - NOT USED - motor 3 CCW limit

				bit 8 - motor 1 direction (platter)
				bit 9 - motor 1 enable
				bit 10 - motor 2 direction (intake)
				bit 11 - motor 2 enable
				bit 12 - NOT USED - motor 3 direction (xrf/analyze)
				bit 13 - NOT USED - motor 3 enable
				bit 14 - air pump power
				bit 15 - main motor power
				*/

   unsigned short used;   /* set to 0xA5A5 upon record write */
   };