/*--------------------------------------------------------------------------------------------------- * USS message structure. Information sent by ISC control computer 8 times per second. * Ultrasonic sensor minimum period is 46+ milliseconds. Therefore, the ISC period is * scheduled by the tasker at 1/16 seconds (62.5 msec periods). The time margin (62 msec - 46 msec) * gives time for echos to die down. Reporting to the navigation computer is on 1/8th second * intervals (125 msec period), hence two sensors are reported on each 1/8th second reporting interval. * ROM is compiled for 2 ultrasonic sensors, then each sensor has new data every reporting interval. * ROM is compiled for 4 ultrasonic sensors, then each sensor has new data every other reporting interval. * * Only one Ultrasonic sensor can be active at a time inorder to avoid interference. Hence sensors are * activated in sequential order on 62.5 msec periods. Individual time tags are captured when the * sensor is triggered active to begin ranging. Each count in the time tag is .9765625 milliseconds. * Each count in the range measurement is .953687 micro-seconds (16,777,000/16 = 1,048,562 Hz.) * The SRF04 Ultrasonic sensor provides an echo pulse proportional to distance. Multiply the reported * range count * 0.953687 to compute the range in micro-seconds (usec). For example, * usec/58 is the distance in inches. * usec/148 is the distance in centimeters. * * If nothing is detected then the SRF04 will report a range anyway of about 36,000 usec. * If the sensor was not triggered or is absent, the "rangex_count" field will report = 0; *---------------------------------------------------------------------------------------------------*/ /* ISC to NAV 8 times per second UltraSonic Sensor */ struct USSMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short us_sensor1_id; /* Word 4, 1,2,3,4. (0 is no sensor) */ unsigned short range1_count; /* Word 5, 0.953687 microseconds per count. */ ULONG time1_tag; /* Word 6, 0.9765625 milliseconds per count */ short us_sensor2_id; /* Word 8, 1,2,3,4. (0 is no sensor) */ unsigned short range2_count; /* Word 9, 0.953687 microseconds per count. */ ULONG time2_tag; /* Word 10, 0.9765625 milliseconds per count */ USHORT checksum; // Word 12. The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct USSMSG USSMSGst;