/***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /******* *******/ /******* D H C - 8 S e r i e s 4 0 0 *******/ /******* *******/ /******* F U E L Q U A N T I T Y G A G I N G S Y S T E M *******/ /******* *******/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /* */ /* Program Name : DHC-8 Fuel Quantity Gaging System (FQGS) */ /* Source File Name : acq.c */ /* CPC : Tank Data Acquisition */ /* Engineer : Katherine Monroe */ /* Criticality Level : Level C */ /* Contents : rt_ISR */ /* serial_ISR */ /* acq_sw_init */ /* acq_hw_init */ /* acq_setup_tu_status */ /* acq_slosh_filter */ /* acq_probe_filter */ /* acq_gaging_filter */ /* acq_analog_bit */ /* Description : This CSC performs data acquisition and slosh */ /* filtering as well as service the CPCI interrupts. */ /* */ /* */ /* Contents of this document are propriety information, property of: */ /* PARKER HANNIFIN CORPORATION */ /* GULL ELECTRONIC SYSTEMS DIVISION */ /* SMITHTOWN, NEW YORK 11787 */ /* Any attempt to copy or use the contents of this document in any manner */ /* whatsoever without express written consent of the owner is prohibited. */ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ #pragma EJECT /***************************************************************************/ /* Revision History */ /***************************************************************************/ /* */ /* Date Rev Engineer Description */ /* ------ --- -------- ------------------------------------------------ */ /* */ /***************************************************************************/ #pragma DEBUG #pragma LARGE #pragma NOAM #pragma OBJECTEXTEND #pragma SYMBOLS #define EXTRN extern /* declare all global variables external */ #define MAIN_FILE 0 /* #pragma SRC */ //#pragma LISTINCLUDE #include "c:\c51\inc\reg51.h" #include "c:\c51\inc\stdlib.h" #include "c:\c51\inc\string.h" #include "fai.h" #include "asicaddr.h" #include "typedefs.h" #include "defines.h" #include "acqswitc.h" #pragma LISTINCLUDE #include "globals.h" #include "prototyp.h" #pragma EJECT /*************************/ /* Module level literals */ /*************************/ /*************************/ /* Interrupt literals */ /*************************/ #define SAMPLE_INTERRUPT 0x08 /* IRQ 3 */ #define MJP_INTERRUPT 0x10 /* IRQ 4 */ #define UART_1_INTERRUPT 0x80 /* IRQ 7 */ #define UART_2_INTERRUPT 0x40 /* IRQ 6 */ #define NUMBER_OF_IRQ3_INTERRUPTS 8 /*************************/ /* 8251 literals */ /*************************/ #define RECEIVER_READY 0x2 /* 8251 */ #define TRANSMITTER_READY 0x1 /* 8251 */ #define UART_ERROR_MASK 0x38 /*************************/ /* Timing literals */ /*************************/ #define AUTOCAL_CYCLE_TIME 214 /* based on 16.384ms clock ==> 03.50 secs*/ #define SLOTS_PER_FRAME 0x4 /* four 16.384 msec slots = 65.536ms per frame */ #define SETTLING_TIME 31 /* based on 16.384ms clock ==> 507.9 ms */ #define SCHEDULE_TIME 38 /* based on 16.384ms clock ==> 622.59 ms */ /*************************/ /* Address literals */ /*************************/ #define EXCITATION_CONTROL 0xD004 #define FUNCTION_LATCH 0xD002 #define MUX_SELECT_ADDR 0xD003 /*************************/ /* Count literals */ /*************************/ #define NUMBER_OF_CHANNEL_1_PROBES 5 #define NUMBER_OF_CHANNEL_2_PROBES 4 #define NUMBER_OF_MUX_CODES 5 #define CYCLES_TO_MEASURE 4 #define BYTE_RESET 0x00 /********************************/ /* Measurement data literals */ /********************************/ #define NORMAL_GAGING_ENTRY 12 /*12th entry into MEASUREMENT_DATA */ #define MEASUREMENT_LIST_SIZE (NORMAL_GAGING_ENTRY+1) /************************************/ /* Order of measurement literals */ /************************************/ #define TOTAL_MEASUREMENTS 13 /* Size of buffer containing list of data */ /* to be measured. */ #define NORMAL_GAGING_MEAS TOTAL_MEASUREMENTS -1 #define AUTOCAL_END (TOTAL_MEASUREMENTS-2) /* 11th entry into order buffer */ #pragma EJECT /********************************/ /* Excitation value literals */ /********************************/ #define NORMAL_OPERATION 0x7F #define PROBE_OFFSET 0x00 #define BUCK_CAP_OFFSET 0x01 #define BUCK_CAP_OFFSET1 0xFE #define DIFF_CAP_OFFSET 0 #define PROBE_DATA_ONLY 0x7E /* This is used for recovery from REC 2 short condition */ /********************************/ /* Index entries into LIMITS */ /* defined below. */ /********************************/ #define NUMBER_OF_LIMIT_ENTRIES 10 #define VREF_GND_ENTRY 0 #define GAIN_ENTRY 1 #define SLOPE_ENTRY 2 #define VP_RANGE_ENTRY 3 #define DIFF_CAP_RANGE_ENTRY 4 #define CL_FAIL_RANGE_ENTRY 5 #define CL_PASS_RANGE_ENTRY 6 #define DC_OFFSET_RANGE_ENTRY 7 #define DIFF_OFFSET_RANGE_ENTRY 8 #define DC_CL_RANGE_ENTRY 9 #define INITIAL_MUX_SELECTED 0 typedef struct { int MIN[NUMBER_OF_RECEIVERS]; int MAX[NUMBER_OF_RECEIVERS]; } LIMITS_STRUCT_T; code uchar MUX_SELECT_CODES[NUMBER_OF_MUX_CODES] = {0x08, /* Tank receiver 1 on */ 0x09, /* Tank receiver 2 on */ 0x0A, /* Excitation current on */ 0x0B, /* Reference voltage on */ 0x0C}; /* Ground on */ code uchar DATA_ID_TABLE[NUMBER_OF_IRQ3_INTERRUPTS] = {0xA5, /* sample 2 probe 5 */ 0xE5, /* sample 6 probe 5 */ 0xA6, /* sample 2 probe 6 */ 0xE6, /* sample 6 probe 6 */ 0xA7, /* sample 2 probe 7 */ 0xE7, /* sample 6 probe 7 */ 0xA8, /* sample 2 probe 8 */ 0xE8}; /* sample 6 probe 8 */ code LIMITS_STRUCT_T LIMITS [NUMBER_OF_LIMIT_ENTRIES] = { /* min max */ /* tank 1 tank 2 tank1 tank 2 */ /* */ {{ 3686, 3686}, { 4505, 4505}}, // vref-gnd min max range {{ 2916, 2916}, { 3565, 3565}}, // gain difference min max range {{ 7518, 7518}, { 11277, 11277}}, // slope difference min max range {{ -150, -150}, { 7500, 7500}}, // dc gauging-offset difference min max range {{ 25, 25}, { 8191, 8191}}, // diff cap min max range {{ 3000, 3000}, { 8191, 8191}}, // current limit fail range {{ -500, -500}, { 7500, 7500}}, // current limit pass range {{ -1500, -1500}, { 1500, 1500}}, // DC offset range {{ -2000, -2000}, { 2000, 2000}}, // diff cap offset {{ -200, -200}, { 3000, 3000}} // dc data cl valid range, changed from 6200 according to R.Orbell calculations 9/29/97 }; code LIMITS_STRUCT_T PROBE_CURRENT_LIMITS [NUMBER_OF_PROBES] = { /* min max */ /* tank 1 tank 2 tank1 tank 2 */ /* */ {{ 750, 750}, { 8191, 8191}}, // probe 1 current limits fail range {{ 750, 750}, { 8191, 8191}}, // probe 2 current limits fail range {{ 750, 750}, { 8191, 8191}}, // probe 3 current limits fail range {{ 750, 750}, { 8191, 8191}}, // probe 4 current limits fail range {{ 750, 750}, { 8191, 8191}}, // probe 5 current limits fail range {{ 1500, 1500}, { 8191, 8191}}, // probe 6 current limits fail range {{ 1500, 1500}, { 8191, 8191}}, // probe 7 current limits fail range {{ 1500, 1500}, { 8191, 8191}}, // probe 8 current limits fail range {{ 1500, 1500}, { 8191, 8191}} // probe 9 current limits fail range }; /**************************************************************/ /* Probe Gallons Ceff Scale Cair Cb Cdry */ /* # factor */ /*------------------------------------------------------------*/ /* 1 81.21 25.61 0.315 26.61 22 4.61 */ /* 2 56.19 17.72 0.315 18.72 13 5.72 */ /* 3 122.84 38.73 0.315 39.739 33 6.73 */ /* 4 122.55 38.64 0.315 39.647 33 6.647 */ /* 5 101.38 31.97 0.315 32.97 27 5.97 */ /* 6 84.84 26.75 0.315 27.755 22 5.75 */ /* 7 140.19 44.21 0.315 45.21 39 6.21 */ /* 8 92.65 29.21 0.315 30.218 27 3.21 */ /* 9 106.82 33.68 0.315 34.687 27 7.68 */ /* */ /**************************************************************/ /**************************/ /* Probe ranges to 0.1 pf */ /**************************/ code PROBE_RANGE_STRUCT_T PROBE_RANGE [NUMBER_OF_PROBES] = { 25 /* 2.0 pf */, 700/* 590*/, // Probe 1 25 /* 2.0 pf */, 1600/* 1370*/, // Probe 2 25 /* 2.0 pf */, 1300/* 1090*/, // Probe 3 25 /* 2.0 pf */, 1100/* 910*/, // Probe 4 25 /* 2.0 pf */, 1000/* 850*/, // Probe 5 25 /* 2.0 pf */, 1000/* 850*/, // Probe 6 25 /* 2.0 pf */, 1000/* 850*/, // Probe 7 25 /* 2.0 pf */, 1000/* 850*/, // Probe 8 25 /* 2.0 pf */, 800/* 670*/ };// Probe 9 #pragma EJECT /***********************************************************/ /* This structure defines the function codes, scheduling */ /* times, settling times and an index used to determine */ /* where to save the received data. */ /***********************************************************/ code struct MEASUREMENT_TYPE_DEF { uchar funct_code[NUMBER_OF_RECEIVERS]; // Function code definition uint schedule_time; // Time to schedule a new measurement uchar settling_time; // Time for current measurement data to settle } MEASUREMENT_DATA[MEASUREMENT_LIST_SIZE] = {{{0x0,0x00}, SCHEDULE_TIME, SETTLING_TIME}, /* 0 : normal DC gaging */ {{0x8,0x80}, SCHEDULE_TIME, SETTLING_TIME}, /* 1 : receiver open */ {{0xA,0xA0}, SCHEDULE_TIME, SETTLING_TIME}, /* 2 : bucking capacitance */ {{0xE,0xE0}, SCHEDULE_TIME, SETTLING_TIME}, /* 3 : slope low */ {{0xC,0xC0}, SCHEDULE_TIME, SETTLING_TIME}, /* 4 : slope high */ {{0x6,0x60}, SCHEDULE_TIME, SETTLING_TIME}, /* 5 : receiver gain high */ {{0x9,0x90}, SCHEDULE_TIME, SETTLING_TIME}, /* 6 : probe capacitance/offset */ {{0xD,0xD0}, SCHEDULE_TIME, SETTLING_TIME}, /* 7 : health high */ {{0xF,0xF0}, SCHEDULE_TIME, SETTLING_TIME}, /* 8 : health low */ {{0xB,0xB0}, SCHEDULE_TIME, SETTLING_TIME}, /* 9 : difference capacitance */ {{0x4,0x40}, SCHEDULE_TIME, SETTLING_TIME}, /* 10: receiver gain low */ {{0xB,0xB0}, SCHEDULE_TIME, SETTLING_TIME}, /* 11: Excite probes */ {{0x0,0x00}, AUTOCAL_CYCLE_TIME, SETTLING_TIME} /* 12: normal DC gaging */ }; /***********************************************************/ /* This structure defines the order in which the data will */ /* be read. */ /* */ /* IMPORTANT NOTE: */ /* Gain high must be scheduled before gain low reading */ /* for processing purposes. */ /***********************************************************/ code struct M_ORDER { uchar next[NUMBER_OF_RECEIVERS]; uchar excitation; } order [TOTAL_MEASUREMENTS] = // Startup measurements {{{ 0, 4}, 0x00}, //0 tank DC gaug offset & slope high {{ 5, 0}, 0x08}, //1 tank rec gain high & tank 3 bit {{10, 0}, 0x20}, //2 tank rec gain low & tank 5 bit {{ 4, 0}, 0x00}, //3 tank rec slope high & dc offset {{ 3, 9}, 0x00}, //4 tank rec slope low & diff cap offset {{ 9, 3}, 0x00}, //5 tank rec diff cap off& slope low // Bit measurements {{ 0, 0}, 0x00}, //6 DC offset & DC offset {{ 0, 5}, 0x04}, //7 tank 2 bit & gain high {{ 0,10}, 0x10}, //8 tank 4 bit & gain low {{ 0, 0}, 0x40}, //9 tank 6 bit & tank 7 bit {{ 0, 0}, 0x01}, //10 tank 8 bit & tank 9 bit {{ 0, 9}, 0x02}, //11 tank 1 bit & diff cap offset // Normal gaging measurements {{NORMAL_GAGING_ENTRY,NORMAL_GAGING_ENTRY},0x7F} //12 tank rec normal DC & normal DC }; code uchar PROBE_LIST [NUMBER_OF_RECEIVERS][5] = {0,1, /* Probe 1 & 2 */ 3,5, /* Probe 4 & 6 */ 7,2, /* Probe 8 & 3 */ 4,6, /* Probe 5 & 7 */ 8,0}; /* Probe 9 & N/A */ #pragma EJECT /***********************************************************/ /* This structure identifies the current measurement type &*/ /* maintains the scheduling and settling timers for the */ /* tank and low level sensor receivers. */ /***********************************************************/ struct C_MEASUREMENT_TYPE { struct MEASUREMENT_TYPE_DEF *measurement; uchar excitation_test; // EXCITATION_CODE constant used uint scheduling_timer; uchar settling_timer; }; xdata struct C_MEASUREMENT_TYPE current[NUMBER_OF_RECEIVERS]; /***********************************************************/ /* This structure defines the basic raw data from the MUX. */ /***********************************************************/ struct BASIC_DATA_TYPE { int current_limit; int ref_voltage; int ground_data; }; xdata struct BASIC_DATA_TYPE acq_basic_raw_data[CYCLES_TO_MEASURE]; /***********************************************************/ /* This structure contains the tank receivers raw data */ /* acquired from the MUX. */ /***********************************************************/ struct RAW_DATA_TYPE { int new_data [NUMBER_OF_RECEIVERS]; /* read in value */ uchar data_valid [NUMBER_OF_RECEIVERS]; uchar function_code[NUMBER_OF_RECEIVERS]; uchar excitation; /* valur of excitation control register */ }; xdata struct RAW_DATA_TYPE acq_current_data[CYCLES_TO_MEASURE]; #pragma EJECT /*******************************************/ /* This structure contains the latest data */ /* read into the system for each receiver. */ /*******************************************/ struct INPUT_DATA_TYPE { int dc_data [NUMBER_OF_RECEIVERS]; // Function code 0 data int dc_cl_data [NUMBER_OF_RECEIVERS]; // Function code 0 data int dc_offset [NUMBER_OF_RECEIVERS]; // Function code 0 data int dc_cl_offset_data [NUMBER_OF_RECEIVERS]; // Function code 0 data int gain_low [NUMBER_OF_RECEIVERS]; // Function code 4 data int cl_gain_low [NUMBER_OF_RECEIVERS]; // Function code 4 data int gain_high [NUMBER_OF_RECEIVERS]; // Function code 6 data int cl_gain_high [NUMBER_OF_RECEIVERS]; // Function code 6 data int excitation_data [NUMBER_OF_PROBES]; // Function code 9 data int cl_excitation_data [NUMBER_OF_PROBES]; // Function code 9 data int difference_cap [NUMBER_OF_RECEIVERS]; // Function code 11 data int cl_difference_cap [NUMBER_OF_RECEIVERS]; // Function code 11 data int diff_cap_offset [NUMBER_OF_RECEIVERS]; // Function code 11 data int cl_diff_cap_offset [NUMBER_OF_RECEIVERS]; // Function code 11 data int slope_high [NUMBER_OF_RECEIVERS]; // Function code 12 data int cl_slope_high [NUMBER_OF_RECEIVERS]; // Function code 12 data int slope_low [NUMBER_OF_RECEIVERS]; // Function code 14 data int cl_slope_low [NUMBER_OF_RECEIVERS]; // Function code 14 data }; static xdata struct INPUT_DATA_TYPE acq_latest_reading; /**************************/ /* module level variables */ /**************************/ xdata uchar acq_skip_cycles_ctr; data uchar acq_frame_slot_id; xdata uchar acq_read_mask; xdata uchar acq_overrun_task; xdata uchar acq_last_bit_cycle; bit acq_sampling_error; #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : acq_sw_init */ /* Description : This unit initializes all data acquisition variables. */ /* Inputs : None */ /* */ /* Outputs : */ /* */ /* acq_frame_slot_id */ /* acq_skip_cycles_ctr */ /* */ /* Called by : main */ /* Calls : None */ /* */ /***************************************************************************/ void acq_sw_init(void) { xdata uchar index; acq_frame_slot_id = SLOTS_PER_FRAME - 1; acq_skip_cycles_ctr = 15; /* skip 1 sec after power on */ acq_last_bit_cycle = NORMAL_GAGING_MEAS - 1; /*********************************/ /* Allow only Excitation current,*/ /* reference voltage and ground */ /* data to be read immediately. */ /*********************************/ acq_read_mask = 0x1C; for (index = 0; index < NUMBER_OF_RECEIVERS; index++) { current[index].measurement = &MEASUREMENT_DATA[order[0].next[index]]; current[index].scheduling_timer = current[index].measurement->schedule_time; /******************************************/ /* Function code 0 data init to 0x8000 */ /******************************************/ acq_latest_reading.dc_data[index] = INVALID_INTEGER; acq_latest_reading.dc_cl_data[index] = INVALID_INTEGER; acq_latest_reading.dc_offset[index] = INVALID_INTEGER; acq_latest_reading.dc_cl_offset_data[index] = INVALID_INTEGER; /******************************************/ /* Function code 4 data init to 0x8000 */ /******************************************/ acq_latest_reading.gain_low[index] = INVALID_INTEGER; acq_latest_reading.cl_gain_low[index] = INVALID_INTEGER; /******************************************/ /* Function code 6 data init to 0x8000 */ /******************************************/ acq_latest_reading.gain_high[index] = INVALID_INTEGER; acq_latest_reading.cl_gain_high[index] = INVALID_INTEGER; /******************************************/ /******************************************/ /* Function code 11 data init to 0x8000 */ /******************************************/ acq_latest_reading.diff_cap_offset[index] = INVALID_INTEGER; acq_latest_reading.cl_diff_cap_offset[index] = INVALID_INTEGER; acq_latest_reading.difference_cap[index] = INVALID_INTEGER; acq_latest_reading.cl_difference_cap[index] = INVALID_INTEGER; /******************************************/ /* Function code 12 data init to 0x8000 */ /******************************************/ acq_latest_reading.slope_high[index] = INVALID_INTEGER; acq_latest_reading.cl_slope_high[index] = INVALID_INTEGER; /******************************************/ /* Function code 14 data init to 0x8000 */ /******************************************/ acq_latest_reading.slope_low[index] = INVALID_INTEGER; acq_latest_reading.cl_slope_low[index] = INVALID_INTEGER; /******************************************/ /* Initialize all fail counts to the max. */ /******************************************/ g_acq_sampling_error_cnt = G_MAX_ACQ_ERROR; g_probe_lls[index].filtered_vref_vgnd = INVALID_LONG; g_probe_lls[index].filtered_gain_offset = INVALID_LONG; g_probe_lls[index].filtered_slope_hi_low = INVALID_LONG; g_probe_lls[index].filtered_probe_offset = INVALID_LONG; g_probe_lls[index].filtered_diff_cap_offset = INVALID_LONG; g_probe_lls[index].filtered_dc_offset = INVALID_LONG; g_probe_lls[index].filtered_diff_offset = INVALID_LONG; } /******************************************/ /* PR045 2/14/97 KM */ /* These values must be initialized to 0 */ /* because the data is never read and so */ /* that a HiZ fault will not occur. */ /******************************************/ acq_latest_reading.diff_cap_offset[0] = 0; //pr 045 2/14/97 KM acq_latest_reading.cl_diff_cap_offset[0] = 0; //pr 045 2/14/97 KM g_probe_lls[0].filtered_diff_cap_offset = 0; //pr 045 2/14/97 KM for (index = 0; index < (NUMBER_OF_PROBES); index++) { /******************************************/ /* Function code 11 data init to 0x8000 */ /******************************************/ acq_latest_reading.excitation_data[index] = INVALID_INTEGER; acq_latest_reading.cl_excitation_data[index] = INVALID_INTEGER; /******************************************/ } } /* end acq_sw_init */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : acq_hw_init */ /* Description : This unit initializes the TUI control register. */ /* Inputs : None */ /* Outputs : None */ /* Called by : main */ /* Calls : None */ /* */ /***************************************************************************/ void acq_hw_init (void) { #define GAGING_COMMAND 0x50 /********************************************************************/ /* TUI Control Register (TU_CON) initialization */ /********************************************************************/ /* */ /* TU_CON bit map (D100h): */ /* */ /* 7 6 5 4 3 2 1 0 */ /* ------|------|-------|------|---------|--------|------|-------| */ /* rsvd | AD | S_INT | BIT | AUTOCAL | HEALTH | COMP | PROBE | */ /* ------|------|-------|------|---------|--------|------|-------| */ /* AD - the AD bit enables A/D sampling of selected data */ /* S_INT - the S_INT bit enables sample interrupts (IRQ3) */ /* BIT - the BIT bit enables BIT channel sampling. BIT */ /* channel are Probe ID 5-8. */ /* AUTOCAL - the AUTOCAL bit enables autocal sampling. Autocal */ /* channel is Probe ID 15. */ /* HEALTH - the HEALTH bit enables health sampling. Health samples */ /* are Sample ID 1,3,5,7; while data samples are Sample */ /* ID 2,6. */ /* COMP - the COMP bit enalges compensator sampling. Compensator */ /* channels are Probe ID 9-13. */ /* PROBE - the PROBE bit enagles tank probe sampling. Tank probes */ /* are Probe ID 0-4. */ /********************************************************************/ XBYTE [TU_CON_ADDR] = GAGING_COMMAND; XBYTE[EXCITATION_CONTROL] = 0xFF; // Turn excitation on. /***************************************************/ /* Initialize the MUX to read initial data. */ /***************************************************/ XBYTE[MUX_SELECT_ADDR] = MUX_SELECT_CODES[INITIAL_MUX_SELECTED]; } /* end acq_hw_init */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : rt_ISR */ /* Description : This unit services all real time interrupts (IRQ4). */ /* [ High priority; register bank 1 ] */ /* */ /* Inputs : */ /* g_task_flag */ /* g_overrun_ctr */ /* g_task_counter */ /* g_uart1_rx_index */ /* g_uart1_tx_buff */ /* g_uart1_tx_index */ /* */ /* acq_frame_slot_id */ /* */ /* Outputs : g_overrun_ctr */ /* g_overrun_task */ /* g_uart1_rx_buff */ /* g_uart1_rx_index */ /* g_uart1_tx_index */ /* */ /* acq_frame_slot_id */ /* */ /* Called by : real time interrupt (IRQ 4) */ /* Calls : None */ /* */ /***************************************************************************/ void rt_ISR (void) interrupt 2 using 1 { /******************/ /* Local literals */ /******************/ #define MJP_1_FRAME_SLOT 0 /* 0ms - 16.384ms frame slot */ #define MJP_2_FRAME_SLOT 1 /* 16.384ms - 32.768ms frame slot */ #define SHUTOFF_SAMPLES_FRAME_SLOT 2 /* 32.768ms - 49.152ms frame slot */ #define ENABLE_TANK_READ 0x01 #define ENABLE_LLS_READ 0x02 #define ENABLE_SAMPLE_INTERRUPT 0x20 code uchar DISABLE_READ[NUMBER_OF_RECEIVERS] = {0xFE, /* tank 1 receiver */ 0xFD}; /* tank 2 receiver */ code uchar ENABLE_READ[NUMBER_OF_RECEIVERS] = {0x01, /* tank 1 receiver */ 0x02}; /* tank 2 receiver */ code uchar CLEAR_FUNCTION_LATCH[NUMBER_OF_RECEIVERS] = {0xF0, /* tank 1 receiver */ 0x0F}; /* tank 2 receiver */ code uchar READ_MASK[5] = {0x01, /* tank 1 receiver */ 0x02, /* tank 2 receiver */ 0x04, /* Excitation current */ 0x08, /* Reference voltage */ 0x10}; /* Ground */ static xdata uchar fun_latch_image, mux_select_index, bit_index, next_cycle, tank_lls_index; uchar uart1_status; #pragma EJECT /****************/ /* Process IRQ3 */ /****************/ if (XBYTE [PIC_PEND_ADDR] & SAMPLE_INTERRUPT) { /*****************************/ /* acknowledge the interrupt */ /*****************************/ XBYTE [PIC_ACK_ADDR] = SAMPLE_INTERRUPT; if (mux_select_index < NUMBER_OF_MUX_CODES) if (XBYTE[DATA_ID_ADDR] == DATA_ID_TABLE[mux_select_index]) { /****************************************************/ /* Input data from A/D for each mux code selected. */ /****************************************************/ switch (mux_select_index) { case 0: /* MUX 0 = tank receiver 1 */ if (acq_read_mask & READ_MASK[mux_select_index]) { acq_current_data[acq_frame_slot_id].new_data[mux_select_index]= (*(int xdata *)AD_ADDR) >>2; /******************************************************************/ /* Save function code value, excitation ptr & indicate data valid */ /******************************************************************/ acq_current_data[acq_frame_slot_id].function_code[TANK_REC_CYCLE] = current[TANK_REC_CYCLE].measurement->funct_code[TANK_REC_CYCLE]; acq_current_data[acq_frame_slot_id].data_valid[TANK_REC_CYCLE] = SET; acq_current_data[acq_frame_slot_id].excitation = current[mux_select_index].excitation_test; } else { acq_current_data[acq_frame_slot_id].data_valid[TANK_REC_CYCLE] = BYTE_RESET ; acq_current_data[acq_frame_slot_id].function_code[TANK_REC_CYCLE] = 0; acq_current_data[acq_frame_slot_id].new_data[TANK_REC_CYCLE] = 0; acq_current_data[acq_frame_slot_id].excitation = 0; } break; case 1: /* MUX 1 = Tank receiver 2 */ if (acq_read_mask & READ_MASK[mux_select_index]) { acq_current_data[acq_frame_slot_id].new_data[LLS_REC_CYCLE]= (*(int xdata *)AD_ADDR) >>2; acq_current_data[acq_frame_slot_id].function_code[LLS_REC_CYCLE] = current[mux_select_index].measurement->funct_code[LLS_REC_CYCLE]; acq_current_data[acq_frame_slot_id].data_valid[LLS_REC_CYCLE] = SET; } else { acq_current_data[acq_frame_slot_id].data_valid[LLS_REC_CYCLE] = BYTE_RESET ; acq_current_data[acq_frame_slot_id].new_data[LLS_REC_CYCLE] =0; acq_current_data[acq_frame_slot_id].function_code[LLS_REC_CYCLE] = 0; acq_current_data[acq_frame_slot_id].excitation = 0; } break; case 2: /* current limit */ acq_basic_raw_data[acq_frame_slot_id].current_limit = (*(int xdata *)AD_ADDR) >>2; break; case 3: /* Reference voltage */ acq_basic_raw_data[acq_frame_slot_id].ref_voltage = (*(int xdata *)AD_ADDR) >>2; break; case 4: /* ground data */ acq_basic_raw_data[acq_frame_slot_id].ground_data = (*(int xdata *)AD_ADDR) >>2; break; default: break; } // switch } else { /* sampling error */ mux_select_index = NUMBER_OF_IRQ3_INTERRUPTS -1; // causes index to be reset acq_sampling_error = SET; // causes processing of data to be skiped over } mux_select_index++; mux_select_index %= NUMBER_OF_IRQ3_INTERRUPTS; if (mux_select_index < NUMBER_OF_MUX_CODES) /*****************************************/ /* Change MUX code until thru all codes. */ /*****************************************/ XBYTE[MUX_SELECT_ADDR] = MUX_SELECT_CODES[mux_select_index]; } /* if IRQ3 */ #pragma EJECT /*********/ /* IRQ 4 */ /*********/ if (XBYTE [PIC_PEND_ADDR] & MJP_INTERRUPT) { /*****************************/ /* acknowledge the interrupt */ /*****************************/ XBYTE [PIC_ACK_ADDR] = MJP_INTERRUPT; /******************************************/ /* Enable the sample interrupt & PIC IRQ3 */ /******************************************/ XBYTE [TU_CON_ADDR] |= ENABLE_SAMPLE_INTERRUPT; if (RESET == acq_overrun_task) { for (tank_lls_index = 0; tank_lls_index < 2; tank_lls_index++) { /**********************************************/ /* If time to schedule a new measurement then */ /* change the function code. */ /**********************************************/ if (current[tank_lls_index].scheduling_timer++ == current[tank_lls_index].measurement->schedule_time) { /**********************************************/ /* If startup sequence has been completed then*/ /* alternate between normal gaging and one */ /* startup (autocal ) cycle. */ /**********************************************/ if (g_acq_startup_complete_flag) { ACQ_STARTUP_END: /*****************************************/ /* If current cycle is normal gaging then*/ /* setup for next change to be an autocal*/ /* or BIT cycle otherwise setup for the */ /* next cycle to be normal gaging. */ /*****************************************/ if (NORMAL_GAGING_MEAS == next_cycle) { /*****************/ /* NORMAL CYCLE */ /*****************/ if (tank_lls_index == TANK_REC_CYCLE ) { // change only when tank is being processed acq_last_bit_cycle++; acq_last_bit_cycle %= (TOTAL_MEASUREMENTS - 1); } /**********************************************/ /* Set excitation control register to value */ /* from table defining register contents. */ /**********************************************/ XBYTE[EXCITATION_CONTROL] = order[acq_last_bit_cycle].excitation; current[tank_lls_index].excitation_test = order[acq_last_bit_cycle].excitation; current[tank_lls_index].measurement = &MEASUREMENT_DATA[order[acq_last_bit_cycle].next[tank_lls_index]]; if (tank_lls_index == LLS_REC_CYCLE) // change only after lls has been processed next_cycle = acq_last_bit_cycle; } else { /**************/ /* BIT CYCLE */ /**************/ /**********************************************/ /* Set excitation control register to value */ /* from table defining register contents. */ /**********************************************/ current[tank_lls_index].excitation_test = order[NORMAL_GAGING_MEAS].excitation; XBYTE[EXCITATION_CONTROL] = order[NORMAL_GAGING_MEAS].excitation; current[tank_lls_index].measurement = &MEASUREMENT_DATA[order[NORMAL_GAGING_MEAS].next[tank_lls_index]]; if (tank_lls_index == LLS_REC_CYCLE) { // change only after tank has been processed if (next_cycle == AUTOCAL_END) g_autocal_data_complete = SET; next_cycle = NORMAL_GAGING_MEAS; } } } else { /************************/ /* Startup in progress. */ /************************/ current[tank_lls_index].measurement = &MEASUREMENT_DATA[order[next_cycle].next[tank_lls_index]]; /**********************************************/ /* Set excitation control register to value */ /* from table defining register contents. */ /**********************************************/ current[tank_lls_index].excitation_test = order[next_cycle].excitation; XBYTE[EXCITATION_CONTROL] = order[next_cycle].excitation; /**************************************************/ /* Startup sequence in progress setup for next */ /* cycle in sequence after processing tank 2 data.*/ /**************************************************/ if (tank_lls_index == LLS_REC_CYCLE ) { next_cycle++; if (next_cycle > (AUTOCAL_END+1)) { // include reading of normal data next_cycle=0; g_acq_startup_complete_flag = SET; } } } fun_latch_image &= CLEAR_FUNCTION_LATCH[tank_lls_index]; fun_latch_image |= current[tank_lls_index].measurement->funct_code[tank_lls_index]; XBYTE[FUNCTION_LATCH] = fun_latch_image; /***********************************************/ /* Disable reading of tank or LLS receiver. */ /***********************************************/ acq_read_mask &= DISABLE_READ[tank_lls_index]; /*****************************/ /* Update the counter timers.*/ /*****************************/ current[tank_lls_index].scheduling_timer = RESET; current[tank_lls_index].settling_timer = RESET; } else { /**********************************************/ /* If time to wait before reading from tank */ /* receiver has been reached, enable tank */ /* receiver read. */ /**********************************************/ if (++current[tank_lls_index].settling_timer >= current[tank_lls_index].measurement->settling_time) { acq_read_mask |= ENABLE_READ[tank_lls_index]; } } } //end for loop } // do not change mux setup if task overrun has occurred. if (3 == acq_frame_slot_id) { if (g_task_flag) { /***********************************************/ /* error condition flag it to the task monitor */ /***********************************************/ g_overrun_task[g_overrun_ctr++] = g_task_counter; /* log the erring task */ acq_overrun_task = SET; /* repeat current acquisition cycle. */ if (g_overrun_ctr >= (sizeof(g_overrun_task))) g_overrun_ctr = 0; } else { g_task_flag = SET; acq_overrun_task = RESET; if (30 == ++g_task_counter) g_task_counter = 0; } } /* bookkeep slot ctr */ acq_frame_slot_id++; acq_frame_slot_id %= SLOTS_PER_FRAME; /* 60 Hz sampling rate */ } /* mjp interrupt IRQ4 */ #pragma EJECT /*********/ /* IRQ 6 */ /*********/ if (XBYTE [PIC_PEND_ADDR] & UART_2_INTERRUPT) { /*****************************/ /* acknowledge the interrupt */ /*****************************/ XBYTE [PIC_ACK_ADDR] = UART_2_INTERRUPT; } /* IRQ 7 */ /*********/ /* IRQ 7 */ /*********/ if (XBYTE [PIC_PEND_ADDR] & UART_1_INTERRUPT) { /*****************************/ /* acknowledge the interrupt */ /*****************************/ XBYTE [PIC_ACK_ADDR] = UART_1_INTERRUPT; /**************************************/ /* Determine if the receiver is ready */ /**************************************/ uart1_status = XBYTE [UART1_CONT_ADDR ]; if (uart1_status & RECEIVER_READY) { /**************************************/ /* Determine if UART1_STATUS contains */ /* parity, overrun or framing errors. */ /**************************************/ if (uart1_status & UART_ERROR_MASK) { /**************************************/ /* Error(s) have occurred so send */ /* command to reset the error(s). */ /* (bit 4) <== 1 */ /**************************************/ g_uart1_error_flag = SET; XBYTE [UART1_CONT_ADDR] = 0x14; } else { /**************************************/ /* No errors have occurred so input */ /* data from D901 into receive buffer.*/ /**************************************/ g_uart1_rx_buff [g_uart1_rx_index++] = XBYTE [UART1_DATA_ADDR]; /**************************************/ /* If data points beyond length of */ /* buffer then reset pointer and stop.*/ /**************************************/ if (g_uart1_rx_index >= sizeof(g_uart1_rx_buff)) g_uart1_rx_index = 0; } } #pragma EJECT /*****************************************/ /* Determine if the transmitter is ready */ /*****************************************/ if (uart1_status & TRANSMITTER_READY) { if (g_uart1_tx_buff [g_uart1_tx_index] != ETX) { XBYTE [UART1_DATA_ADDR] = g_uart1_tx_buff [g_uart1_tx_index++]; } else { /***********************************************/ /* Set command instruction definition */ /* D901 = 05h */ /* bit 0 = 0 transmit disable */ /* bit 1 = 0 Data terminal ready */ /* bit 2 = 1 receive enabled */ /* bit 3 = 0 send break character */ /* bit 4 = 0 error reset */ /* bit 5 = 0 request to send */ /* bit 6 = 0 internal reset */ /* bit 7 = 0 enter hunt mode */ /* */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x04; } } } /* IRQ 7 */ } /* end RT_isr */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : serial_ISR */ /* Description : This unit services internal UART (8031) interrupt. */ /* [ Low priority; register bank 2 ] */ /* */ /* Inputs : g_ipc_rx_index */ /* g_ipc_rx_buff */ /* g_ipc_tx_index */ /* gp_ipc_tx */ /* */ /* Outputs : g_ipc_rx_index */ /* g_ipc_rx_buff */ /* g_ipc_tx_index */ /* gp_ipc_tx */ /* */ /* Called by : UART (8031) interrupt */ /* Calls : None */ /* */ /***************************************************************************/ void serial_ISR (void) interrupt 4 using 2 { /*******************/ /* Local variables */ /*******************/ unsigned char small_wait; if (RI) { small_wait = SBUF; if (g_intp_rx_index < sizeof(g_intp_rx)) { g_intp_rx.bytes[g_intp_rx_index++] = small_wait; } else g_intp_rx_index = 0; RI = 0; } /* end if */ if (TI) { if (g_intp_tx_index) { g_intp_tx_index--; small_wait = 30; while(small_wait--); SBUF = *gp_intp_tx++; } TI = 0; } /* end if */ } /* end serial_ISR */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : acq_gaging_filter */ /* Description : This unit filters acquired fuel data. */ /* */ /* Inputs : */ /* acq_probe_data */ /* */ /* Outputs : acq_probe_data */ /* */ /* Called by : acq_slosh_filter */ /* Calls : None */ /* */ /* Timing : This function filters the input data using a 1/16 filter. */ /* */ /***************************************************************************/ long acq_gaging_filter(int new_data, long old_data) { xdata long result; if (old_data == INVALID_LONG) /******************************************/ /* Prime the filter if it is zero. */ /******************************************/ result = (long)new_data * 16; else /******************************************/ /* Filter input data as follows: */ /* */ /* 15/16 old + 1/16 new */ /******************************************/ result = ((old_data-((old_data+8) >> 4)) + (new_data)); return (result); } /* end acq_gaging_filter */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : acq_probe_filter */ /* Description : This unit filters acquired probe data. */ /* */ /* Inputs : */ /* */ /* Outputs : */ /* */ /* Called by : acq_slosh_filter */ /* Calls : None */ /* */ /* Timing : This function filters the input data using a 1/64 filter. */ /* */ /***************************************************************************/ long acq_probe_filter(int new_data, long old_data) { #define FILTER 64 #define ROUND 32 #define SHIFT_CNT 6 xdata long result; if (old_data == INVALID_LONG) /******************************************/ /* Prime the filter if it is zero. */ /******************************************/ result = (long)new_data * FILTER; else /******************************************/ /* Filter input data as follows: */ /* */ /* 63/64 old + 1/64 new */ /******************************************/ result = ( (old_data-((old_data+ROUND) >> SHIFT_CNT)) + (new_data)); return (result); } /* end acq_gaging_filter */ #pragma EJECT /***************************************************************************/ /* Unit Name : acq_slosh_filter */ /* Description : This unit executes the correct filtering unit when no */ /* sampling errors are present. */ /* Inputs : */ /* Outputs : */ /* Called by : main (background executive) */ /* Calls : acq_gaging_filter */ /* acq_probe_filter */ /***************************************************************************/ void acq_slosh_filter(void) { #define NUM_READINGS 8 code uchar SHIFT [NUMBER_OF_RECEIVERS] = {0, // shift 0 bits for tank 1 function code 4}; // shift 4 bits for tank 2 function code code uchar OFFSET_EXCIT_MASK [NUMBER_OF_RECEIVERS] ={0xFE, // bit 0 clear 0x01}; // bit 0 set code uchar NORMAL_EXCIT_MASK [NUMBER_OF_RECEIVERS] ={0x00, // Tank 0x01}; // LLS static xdata uchar tk_lls_index, arn_probe_index; xdata uchar slot_id, probe_index; xdata int difference; static xdata struct BASIC_DATA_TYPE l_basic[CYCLES_TO_MEASURE]; static xdata struct RAW_DATA_TYPE l_current[CYCLES_TO_MEASURE]; static xdata long int gain_high_sum [NUMBER_OF_RECEIVERS] ; static xdata int gain_high_avg [NUMBER_OF_RECEIVERS] ; static xdata uchar gain_start [NUMBER_OF_RECEIVERS] ; static xdata long int slope_high_sum [NUMBER_OF_RECEIVERS] ; static xdata int slope_high_avg [NUMBER_OF_RECEIVERS] ; static xdata uchar slope_start [NUMBER_OF_RECEIVERS] ; static xdata long int dcdata_sum [NUMBER_OF_RECEIVERS] ; static xdata long int dcdata_avg [NUMBER_OF_RECEIVERS] ; static xdata uchar dcdata_start [NUMBER_OF_RECEIVERS] ; /*************************************************************************/ /* The following variables were added in support of PR#045 by KM 1/28/97 */ /*************************************************************************/ static xdata long int excit_data_sum [NUMBER_OF_PROBES] ; static xdata long int excit_data_avg [NUMBER_OF_PROBES] ; static xdata uchar excit_data_start [NUMBER_OF_PROBES] ; static xdata long int sum_cl_dc_data [NUMBER_OF_RECEIVERS]; static xdata uchar cl_dc_data_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_excitation_data [NUMBER_OF_PROBES]; static xdata uchar excit_cl_data_cnt [NUMBER_OF_PROBES]; static xdata long int sum_cl_dc_offset [NUMBER_OF_RECEIVERS]; static xdata uchar cl_dc_offset_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_gain_low [NUMBER_OF_RECEIVERS]; static xdata uchar cl_gain_low_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_gain_high [NUMBER_OF_RECEIVERS]; static xdata uchar cl_gain_high_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_diff_cap_offset [NUMBER_OF_RECEIVERS]; static xdata uchar cl_diff_cap_offset_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_diff_cap [NUMBER_OF_RECEIVERS]; static xdata uchar cl_diff_cap_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_slope_hi [NUMBER_OF_RECEIVERS]; static xdata uchar cl_slope_hi_cnt [NUMBER_OF_RECEIVERS]; static xdata long int sum_cl_slope_low [NUMBER_OF_RECEIVERS]; static xdata uchar cl_slope_low_cnt [NUMBER_OF_RECEIVERS]; /*************************************************************************/ /*************************************************************************/ #pragma EJECT /*******************************************/ /* If a sampling error has been detected, */ /* log the error and drop out of this unit */ /*******************************************/ if (acq_sampling_error ) { /*******************************************/ /* Report a sampling failure. */ /*******************************************/ fai_pass_fail_logger(SAMPLING_TEST_ID,FAIL); acq_sampling_error = RESET; g_acq_sampling_error_cnt++; // count number of consecutive sample errors } else { g_acq_sampling_error_cnt= RESET; // number of sample errors /*******************************************/ /* Save contents of basic raw data buffer */ /* and current data buffer to prevent */ /* overwriting data. */ /*******************************************/ memcpy(&l_basic, &acq_basic_raw_data, sizeof(acq_basic_raw_data)); memcpy(&l_current, &acq_current_data, sizeof(acq_current_data)); for (slot_id = 0; slot_id < CYCLES_TO_MEASURE; slot_id++) { /**********************************************/ /* For each frame slot of data collected, use */ /* the function code of the tank and lls */ /* receiver data to determine what difference */ /* to take and what data to filter. */ /**********************************************/ for (tk_lls_index = 0; tk_lls_index < NUMBER_OF_RECEIVERS; tk_lls_index++) { /*************************************************************/ /* VREF VGND data */ /* */ /* Range test Vref-Vgnd for each slot id and each receiver. */ /* If the range test passes, filter the data. If the range */ /* test fails for three consecutive readings, indicate a */ /* failure so that the mass will go to zero. */ /*************************************************************/ difference =l_basic[slot_id].ref_voltage - l_basic[slot_id].ground_data; if BETWEEN(difference,LIMITS[VREF_GND_ENTRY].MIN[0],LIMITS[VREF_GND_ENTRY].MAX[0]) { g_probe_lls[tk_lls_index].filtered_vref_vgnd = acq_gaging_filter(difference,g_probe_lls[tk_lls_index].filtered_vref_vgnd); g_probe_lls[tk_lls_index].vref_vgnd_fail_count = 0; /*******************************************/ /* Clear vref vgnd fault pr 015 */ /*******************************************/ fai_pass_fail_logger((CHANNEL1_AD_TEST_ID+tk_lls_index),PASS); // vref gnd pass } else { if (g_probe_lls[tk_lls_index].vref_vgnd_fail_count < G_MAX_ACQ_ERROR) g_probe_lls[tk_lls_index].vref_vgnd_fail_count++; else { g_probe_lls[tk_lls_index].filtered_vref_vgnd=INVALID_LONG; /*******************************************/ /* Log vref vgnd fault as AD fault pr015*/ /*******************************************/ fai_pass_fail_logger((CHANNEL1_AD_TEST_ID+tk_lls_index),FAIL); //vref gnd fail } } #pragma EJECT /*******************************************/ /* New data acquired for tank and lls ? */ /*******************************************/ if (l_current[slot_id].data_valid[tk_lls_index]) /*******************************************/ /* Use function code to identify new data. */ /*******************************************/ switch (l_current[slot_id].function_code[tk_lls_index] >> SHIFT[tk_lls_index]) { case 0:/**********************************/ /* Function code 0 */ /* Normal DC gaging data / offset */ /**********************************/ if (l_current[slot_id].excitation == NORMAL_OPERATION) { /*****************************************************/ /* Data used for normal DC gaging mass computations. */ /* All excitation bits are set to one. */ /*****************************************************/ acq_latest_reading.dc_data[tk_lls_index]=l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Average the current limit data */ /* PR 045 1/29/97 KM */ /**********************************/ sum_cl_dc_data[tk_lls_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); cl_dc_data_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_dc_data_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.dc_cl_data[tk_lls_index] = (int) (sum_cl_dc_data[tk_lls_index] >> 3); cl_dc_data_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_dc_data[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/29/97 KM */ /**********************************/ if (g_probe_lls[tk_lls_index].filtered_dc_offset != INVALID_LONG) { /**********************/ /* Voff - Vp */ /**********************/ difference = ((g_probe_lls[tk_lls_index].filtered_dc_offset+8)/16) - l_current[slot_id].new_data[tk_lls_index] ; /***************************************************************/ /* If range test of the difference passes, filter the data and */ /* save the filtered data for mass computations. */ /***************************************************************/ if BETWEEN(difference,LIMITS[VP_RANGE_ENTRY].MIN[tk_lls_index], LIMITS[VP_RANGE_ENTRY].MAX[tk_lls_index]) { g_probe_lls[tk_lls_index].filtered_probe_offset = acq_probe_filter(difference, g_probe_lls[tk_lls_index].filtered_probe_offset); g_probe_lls[tk_lls_index].probe_offset_fail_count = 0; } else { if (g_probe_lls[tk_lls_index].probe_offset_fail_count < G_MAX_ACQ_ERROR) g_probe_lls[tk_lls_index].probe_offset_fail_count++; else g_probe_lls[tk_lls_index].filtered_probe_offset=INVALID_LONG; } } else { g_probe_lls[tk_lls_index].filtered_probe_offset = INVALID_LONG; } } else { #pragma EJECT if ((l_current[slot_id].excitation) == RESET) { /***************************************/ /* PROBE OFFSET DATA */ /* All excitation bits are set to zero */ /* for both receivers. */ /***************************************/ /*********************/ /* Save offset data */ /*********************/ acq_latest_reading.dc_offset[tk_lls_index] = l_current[slot_id].new_data[tk_lls_index] ; /**********************************/ /* Average the current limit data */ /* PR 045 1/29/97 KM */ /**********************************/ sum_cl_dc_offset[tk_lls_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); cl_dc_offset_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_dc_offset_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.dc_cl_offset_data[tk_lls_index] = (int) ((sum_cl_dc_offset[tk_lls_index]+4) >> 3); cl_dc_offset_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_dc_offset[tk_lls_index] = 0; } if BETWEEN(l_current[slot_id].new_data[tk_lls_index], LIMITS[DC_OFFSET_RANGE_ENTRY].MIN[tk_lls_index], LIMITS[DC_OFFSET_RANGE_ENTRY].MAX[tk_lls_index]) { /**********************************/ /* Setup for moving average. */ /* */ /* sum = sum-old+new after first 8*/ /* avg = sum/8 */ /**********************************/ dcdata_sum [tk_lls_index] += l_current[slot_id].new_data[tk_lls_index]; dcdata_start[tk_lls_index]++; /**********************************/ /* Average after full cycle. */ /**********************************/ if (NUM_READINGS == dcdata_start[tk_lls_index]) { /**********************************/ /* Average the data. */ /**********************************/ dcdata_avg[tk_lls_index] = dcdata_sum[tk_lls_index]<<1; /**********************************/ /* Update index. */ /**********************************/ dcdata_start[tk_lls_index] %= NUM_READINGS; dcdata_sum [tk_lls_index] = RESET; g_probe_lls[tk_lls_index].filtered_dc_offset = dcdata_avg[tk_lls_index]; } } else { if (g_probe_lls[tk_lls_index].dc_offset_fail_count < G_MAX_ACQ_ERROR) g_probe_lls[tk_lls_index].dc_offset_fail_count++; else g_probe_lls[tk_lls_index].filtered_dc_offset = INVALID_LONG; } } /**********************************/ /* DC data is now used for bit. */ /* PR 045 1/29/97 KM */ /**********************************/ else { #pragma EJECT /**********************************/ /* Data is for probe bit. */ /**********************************/ switch (l_current[slot_id].excitation) { case 1 : // bit 0 if (tk_lls_index == TANK_REC_CYCLE) probe_index = 7; // Probe 8 else probe_index = 8; // Probe 9 break; case 2 : // bit 1 probe_index = 0; // probe 1 break; case 4 : // bit 2 probe_index = 1; // probe 2 break; case 8 : // bit 3 probe_index = 2; // probe 3 break; case 16 : // bit 4 probe_index = 3; // probe 4 break; case 32 : // bit 5 probe_index = 4; // probe 5 break; case 64 : // bit 6 if (tk_lls_index == TANK_REC_CYCLE) probe_index = 5; // probe 6 else probe_index = 6; // Probe 7 break; default: break; } // 02-07-97 KM INT to LONG on following line if (INVALID_LONG == g_probe_lls[tk_lls_index].filtered_dc_offset) { acq_latest_reading.excitation_data[probe_index] = INVALID_INTEGER; g_own_test_data[probe_index] = 9999; } else { /**********************************/ /* Setup for moving average. */ /* */ /* sum = sum-old+new after first 8*/ /* avg = sum/8 */ /**********************************/ /**********************************/ /* Add newest. */ /**********************************/ excit_data_sum[probe_index] += (long int)(l_current[slot_id].new_data[tk_lls_index]); excit_data_start[probe_index]++; /**********************************/ /* Average after full cycle. */ /**********************************/ if (NUM_READINGS == excit_data_start[probe_index]) { /**********************************/ /* Average the data. */ /**********************************/ excit_data_avg[probe_index] = (excit_data_sum[probe_index])<<1; /**********************************/ /* Update index. */ /**********************************/ excit_data_start[probe_index] %= NUM_READINGS; excit_data_sum[probe_index] = RESET; acq_latest_reading.excitation_data[probe_index] = (int) (( g_probe_lls[tk_lls_index].filtered_dc_offset - excit_data_avg[probe_index]+8)>>4); /**********************************/ /* Setup for ARINC output. */ /**********************************/ g_own_test_data[probe_index] = (int)(acq_latest_reading.excitation_data[probe_index] * 0.45); /***********************************/ /* LOZ Current limit data on ARINC */ /***********************************/ g_own_test_data[9] = acq_latest_reading.dc_cl_data[tk_lls_index]; } /**********************************/ /* Average the current limit data */ /**********************************/ sum_cl_excitation_data[probe_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); excit_cl_data_cnt[probe_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (excit_cl_data_cnt[probe_index] == NUM_READINGS) { acq_latest_reading.cl_excitation_data[probe_index] = (int) ((sum_cl_excitation_data[probe_index]+4) >> 3); /************************************/ /* Clear out buffers and counters. */ /************************************/ sum_cl_excitation_data[probe_index] = 0; excit_cl_data_cnt[probe_index] %= NUM_READINGS; } } } } break; #pragma EJECT case 4:/*************************************************************/ /* Function code 4 */ /* Receiver gain low data */ /* Data used to get gain offset for use in mass computations */ /*************************************************************/ acq_latest_reading.gain_low[tk_lls_index] = l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Average the current limit data */ /* PR 045 1/29/97 KM */ /**********************************/ sum_cl_gain_low[tk_lls_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); cl_gain_low_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_gain_low_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.cl_gain_low[tk_lls_index] = (int) (sum_cl_gain_low[tk_lls_index] >> 3); cl_gain_low_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_gain_low[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/29/97 KM */ /**********************************/ /****************************************************************/ /* If gain low is valid reading, subtract from gain high to get */ /* gain difference. Range test the difference and filter only */ /* range test passes. If test fails, after three failures, mass*/ /* should go to zero. Recover after one pass. */ /****************************************************************/ if (acq_latest_reading.gain_high[tk_lls_index] != INVALID_INTEGER) { difference = (gain_high_avg[tk_lls_index] - l_current[slot_id].new_data[tk_lls_index]); if (BETWEEN(difference, LIMITS[GAIN_ENTRY].MIN[tk_lls_index], LIMITS[GAIN_ENTRY].MAX[tk_lls_index])) { g_probe_lls[tk_lls_index].filtered_gain_offset = acq_gaging_filter(difference, g_probe_lls[tk_lls_index].filtered_gain_offset); g_probe_lls[tk_lls_index].gain_offset_fail_count = 0; /**********************************/ /* Log gain test pass via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_GAIN_TEST_ID+tk_lls_index),PASS); } else { if (G_MAX_ACQ_ERROR == g_probe_lls[tk_lls_index].gain_offset_fail_count++) { /**********************************/ /* Log gain test fail via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_GAIN_TEST_ID+tk_lls_index),FAIL); g_probe_lls[tk_lls_index].gain_offset_fail_count = G_MAX_ACQ_ERROR; } } } else { /**********************************/ /* Log gain test fail via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_GAIN_TEST_ID+tk_lls_index),FAIL); g_probe_lls[tk_lls_index].filtered_gain_offset = INVALID_LONG; } break; #pragma EJECT case 6:/**********************************/ /* Function code 6 */ /* receiver gain high */ /**********************************/ acq_latest_reading.gain_high[tk_lls_index]=l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Add current reading to the sum */ /**********************************/ gain_high_sum[tk_lls_index] += l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Update index count */ /**********************************/ gain_start[tk_lls_index]++; /**********************************/ /* Average after full cycle. i.e. */ /* after 8 readings */ /**********************************/ if (gain_start[tk_lls_index] == NUM_READINGS) { /**********************************/ /* Average the data. */ /**********************************/ gain_high_avg[tk_lls_index] = (int) ((gain_high_sum[tk_lls_index]+4) >> 3) ; gain_high_sum[tk_lls_index] = RESET; } gain_start[tk_lls_index] %= NUM_READINGS; acq_latest_reading.cl_gain_high[tk_lls_index]= l_basic[slot_id].current_limit - l_basic[slot_id].ground_data; break; #pragma EJECT case 11:/**********************************/ /* Function code 11 */ /* difference capacitance */ /**********************************/ if ((l_current[slot_id].excitation == RESET) || (l_current[slot_id].excitation == 2)) { /***********************************/ /* DIFF CAP OFFSET DATA */ /* excitation bit(s) set to zero */ /***********************************/ /***************************/ /* Save offset data */ /***************************/ acq_latest_reading.diff_cap_offset[tk_lls_index] = l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Average the current limit data */ /* PR 045 1/29/97 KM */ /**********************************/ sum_cl_diff_cap_offset[tk_lls_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); cl_diff_cap_offset_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_diff_cap_offset_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.cl_diff_cap_offset[tk_lls_index] = (int) ((sum_cl_diff_cap_offset[tk_lls_index]+4) >> 3); cl_diff_cap_offset_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_diff_cap_offset[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/29/97 KM */ /**********************************/ /**********************************/ /* Perform range test and filter. */ /**********************************/ if BETWEEN(l_current[slot_id].new_data[tk_lls_index], LIMITS[DIFF_OFFSET_RANGE_ENTRY].MIN[tk_lls_index], LIMITS[DIFF_OFFSET_RANGE_ENTRY].MAX[tk_lls_index]) { g_probe_lls[tk_lls_index].filtered_diff_offset = acq_probe_filter(l_current[slot_id].new_data[tk_lls_index], g_probe_lls[tk_lls_index].filtered_diff_offset); g_probe_lls[tk_lls_index].diff_offset_fail_count= RESET; } else { if (g_probe_lls[tk_lls_index].diff_offset_fail_count < G_MAX_ACQ_ERROR) g_probe_lls[tk_lls_index].diff_offset_fail_count++; // indicates HIz short else g_probe_lls[tk_lls_index].filtered_diff_offset = INVALID_LONG; } } else { #pragma EJECT if ((l_current[slot_id].excitation == 0x7f) || (l_current[slot_id].excitation == 0x01)) { // PR 045 2/97 KM /***************************************/ /* DIFF CAP NORMAL DATA */ /***************************************/ if (INVALID_INTEGER == acq_latest_reading.diff_cap_offset[tk_lls_index]) { acq_latest_reading.difference_cap[tk_lls_index] = INVALID_INTEGER; } else { acq_latest_reading.difference_cap[tk_lls_index] = acq_latest_reading.diff_cap_offset[tk_lls_index] - l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Average the current limit data */ /* PR 045 1/28/97 KM */ /**********************************/ sum_cl_diff_cap[tk_lls_index] += (long int) (l_basic[slot_id].current_limit - l_basic[slot_id].ground_data); cl_diff_cap_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_diff_cap_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.cl_difference_cap[tk_lls_index] = (int) ((sum_cl_diff_cap[tk_lls_index]+4) >> 3); cl_diff_cap_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_diff_cap[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/28/97 KM */ /**********************************/ } if (g_probe_lls[tk_lls_index].filtered_diff_offset != INVALID_LONG) { /**********************/ /* Voff - Vp */ /**********************/ difference = ((g_probe_lls[tk_lls_index].filtered_diff_offset+32)/64) - l_current[slot_id].new_data[tk_lls_index] ; DIFF_CAP: /**********************************************/ /* Filter the data and save the filtered data.*/ /**********************************************/ g_probe_lls[tk_lls_index].filtered_diff_cap_offset = acq_probe_filter(difference, g_probe_lls[tk_lls_index].filtered_diff_cap_offset); } else g_probe_lls[tk_lls_index].filtered_diff_cap_offset=INVALID_LONG; } } break; #pragma EJECT case 12: /******************************************************/ /* Function code 12 */ /* Slope high data. */ /* Data used in mass computation for gauging fuel. */ /******************************************************/ acq_latest_reading.slope_high[tk_lls_index]=l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Add new reading to the sum. */ /**********************************/ slope_high_sum[tk_lls_index] += l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Update index. */ /**********************************/ slope_start[tk_lls_index]++; /**********************************/ /* Average after full cycle. */ /* i.e. after 8 readings */ /**********************************/ if (slope_start[tk_lls_index] == NUM_READINGS) { /**********************************/ /* Average the data. */ /**********************************/ slope_high_avg[tk_lls_index] =(int) ((slope_high_sum[tk_lls_index]+4) >> 3) ; slope_high_sum[tk_lls_index] = RESET; } slope_start[tk_lls_index] %= NUM_READINGS; /**********************************/ /* Average the current limit data */ /* PR 045 1/28/97 KM */ /**********************************/ sum_cl_slope_hi[tk_lls_index] += (long int) (l_basic[slot_id].current_limit); cl_slope_hi_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_slope_hi_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.cl_slope_high[tk_lls_index] = (int) ((sum_cl_slope_hi[tk_lls_index]+4) >> 3); cl_slope_hi_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_slope_hi[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/28/97 KM */ /**********************************/ break; #pragma EJECT case 14: /**********************************/ /* Function code 14 */ /* slope low */ /**********************************/ acq_latest_reading.slope_low[tk_lls_index]=l_current[slot_id].new_data[tk_lls_index]; /**********************************/ /* Average the current limit data */ /* PR 045 1/28/97 KM */ /**********************************/ sum_cl_slope_low[tk_lls_index] += (long int)(l_basic[slot_id].current_limit); cl_slope_low_cnt[tk_lls_index]++; /******************************************/ /* Save averaged current limit data value */ /******************************************/ if (cl_slope_low_cnt[tk_lls_index] == NUM_READINGS) { acq_latest_reading.cl_slope_low[tk_lls_index] = (int) ((sum_cl_slope_low[tk_lls_index]+4) >> 3); cl_slope_low_cnt[tk_lls_index] %= NUM_READINGS; sum_cl_slope_low[tk_lls_index] = 0; } /**********************************/ /* End PR 045 1/28/97 KM */ /**********************************/ if (acq_latest_reading.slope_high[tk_lls_index] != INVALID_INTEGER) { difference =slope_high_avg[tk_lls_index] - l_current[slot_id].new_data[tk_lls_index]; /************************************************************/ /* Filter slope high low difference if the range test passes*/ /************************************************************/ if (BETWEEN(difference, LIMITS[SLOPE_ENTRY].MIN[tk_lls_index], LIMITS[SLOPE_ENTRY].MAX[tk_lls_index])) { g_probe_lls[tk_lls_index].filtered_slope_hi_low = acq_gaging_filter(difference, g_probe_lls[tk_lls_index].filtered_slope_hi_low); g_probe_lls[tk_lls_index].slope_hi_low_fail_count = 0; /**********************************/ /* Log slope test pass via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_SLOPE_HI_TEST_ID+tk_lls_index),PASS); } else { if (g_probe_lls[tk_lls_index].slope_hi_low_fail_count < G_MAX_ACQ_ERROR) g_probe_lls[tk_lls_index].slope_hi_low_fail_count++; else g_probe_lls[tk_lls_index].filtered_slope_hi_low=INVALID_LONG; /**********************************/ /* Log slope test fail via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_SLOPE_HI_TEST_ID+tk_lls_index),FAIL); } } else { g_probe_lls[tk_lls_index].filtered_slope_hi_low = INVALID_LONG; /**********************************/ /* Log slope test fail via fai. */ /* PR 015 */ /**********************************/ fai_pass_fail_logger((CHANNEL1_SLOPE_HI_TEST_ID+tk_lls_index),FAIL); } break; default: break; } // switch } // for loop number of receivers loop } // for cycles to measure loop /*******************************************/ /* Report a sampling pass. */ /*******************************************/ fai_pass_fail_logger(SAMPLING_TEST_ID,PASS); } // no acquisition error } /* end acq_slosh_filter */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : acq_analog_bit */ /* Description : This unit performs bit on acquired data. */ /* */ /* Inputs : acq_latest_reading */ /* */ /* Outputs : N/A */ /* */ /* Called by : main (background executive) */ /* Calls : None */ /* */ /***************************************************************************/ void acq_analog_bit (void) { #define OPEN_LIMIT 10 // 1 pf PR 045 changed this to 10 from 20 #define NORMAL_CONDITION 0 #define OPEN_CONDITION 1 #define SHORTED_CONDITION 5 #define HI_Z_SHORTED_CONDITION 6 #define HI_Z_OPEN_CONDITION 7 #define LO_Z_SHORTED_CONDITION 8 #define LO_Z_OPEN_CONDITION 9 xdata uchar probe_fault_status [NUMBER_OF_PROBES]; xdata uchar receiver_fault_status [NUMBER_OF_RECEIVERS]; xdata uchar log_individual_fault [NUMBER_OF_RECEIVERS]; xdata uchar i; xdata uchar tk_lls; xdata uchar probe_id; xdata uchar probe_entry; xdata uchar list_entry; xdata uchar start_loop; xdata uchar end_loop; xdata uchar last_tu_status; xdata uint probe_group_statuses; xdata int normal_data; xdata int cl_data; xdata int normal_range_limits; #pragma EJECT /********************************************/ /* Perform fault isolation only when a full */ /* cycle of autocal data has been received. */ /********************************************/ if (SET == g_autocal_data_complete) { memset(&probe_fault_status, NORMAL_CONDITION, sizeof(probe_fault_status)); memset(&receiver_fault_status, NORMAL_CONDITION, sizeof(receiver_fault_status)); log_individual_fault[0] = log_individual_fault[1] = RESET; for (tk_lls = 0; tk_lls < NUMBER_OF_RECEIVERS; tk_lls++) { /**************************************************/ /* If vref, vgnd, gain or slope range errors have */ /* occurred, do not process lower level tests */ /**************************************************/ probe_group_statuses = fai_status_reporter (CHANNEL1_AD_TEST_ID+tk_lls); probe_group_statuses |= fai_status_reporter (CHANNEL1_GAIN_TEST_ID+tk_lls); probe_group_statuses |= fai_status_reporter (CHANNEL1_SLOPE_HI_TEST_ID+tk_lls); if (!(probe_group_statuses & HARD_FAILURE)) { /* check for failures */ /*****************************************************/ /* No vref, vgnd, gain or slope range errors have */ /* occurred so determine if lower level faults exist */ /*****************************************************/ if (TANK_REC_CYCLE == tk_lls) { start_loop = RESET; end_loop = NUMBER_OF_CHANNEL_1_PROBES; } else { start_loop = RESET; end_loop = NUMBER_OF_CHANNEL_2_PROBES; } /**************************************************/ /* If DC data current limit reading is not within */ /* the valid range then declare an FCU failure */ /**************************************************/ if (BETWEEN(acq_latest_reading.dc_cl_data[tk_lls], LIMITS[DC_CL_RANGE_ENTRY].MIN[tk_lls], LIMITS[DC_CL_RANGE_ENTRY].MAX[tk_lls])) fai_pass_fail_logger(CURRENT_LIMIT_TEST_OFFSET,PASS); else fai_pass_fail_logger(CURRENT_LIMIT_TEST_OFFSET,FAIL); /***********************************************/ /* Diff cap offset or dc offset data reading */ /* out of range ? */ /***********************************************/ if (/*(!(BETWEEN(acq_latest_reading.diff_cap_offset[tk_lls], LIMITS[DIFF_OFFSET_RANGE_ENTRY].MIN[tk_lls], LIMITS[DIFF_OFFSET_RANGE_ENTRY].MAX[tk_lls]))) ||*/ (!(BETWEEN(acq_latest_reading.dc_offset[tk_lls], LIMITS[DC_OFFSET_RANGE_ENTRY].MIN[tk_lls], LIMITS[DC_OFFSET_RANGE_ENTRY].MAX[tk_lls])))) { /***************************************************/ /* Current limit range error for each probe / lls? */ /***************************************************/ for (probe_id = start_loop; probe_id < end_loop; probe_id++) { /*****************************************************/ /* Setup for excitation . */ /*****************************************************/ list_entry = PROBE_LIST[tk_lls][probe_id]; cl_data = acq_latest_reading.cl_excitation_data[list_entry]; if BETWEEN(cl_data,PROBE_CURRENT_LIMITS[list_entry].MIN[tk_lls], PROBE_CURRENT_LIMITS[list_entry].MAX[tk_lls]) /*************************************************/ /* Setup to log shorted failure for failed probe.*/ /*************************************************/ probe_fault_status[list_entry] = SHORTED_CONDITION; else /************************************************/ /* Log HiZ to GND short test failure via fai. */ /************************************************/ receiver_fault_status[tk_lls] = HI_Z_SHORTED_CONDITION; } /* for loop */ } else { /***********************************************/ /* Diff cap offset and dc offset data readings */ /* are within range. */ /***********************************************/ for (probe_id = start_loop; probe_id < end_loop; probe_id++) { list_entry = PROBE_LIST[tk_lls][probe_id]; /*******************************/ /* Setup for data being tested */ /*******************************/ normal_data = acq_latest_reading.excitation_data[list_entry]; cl_data = acq_latest_reading.cl_excitation_data[list_entry]; normal_range_limits = PROBE_RANGE[list_entry].MAX; /***********************************************/ /* Diff cap less than 1 pf? OPEN Test. */ /***********************************************/ if (OPEN_LIMIT > normal_data) { /*********************************************/ /* Current limit range error for each probe. */ /*********************************************/ if BETWEEN(cl_data,PROBE_CURRENT_LIMITS[list_entry].MIN[tk_lls], PROBE_CURRENT_LIMITS[list_entry].MAX[tk_lls]) /************************************************/ /* Setup to log LoZ to GND short test failure. */ /************************************************/ probe_fault_status[list_entry] = LO_Z_SHORTED_CONDITION; else { /**************************************/ /* Setup to log open test failure. */ /**************************************/ probe_fault_status[list_entry] = OPEN_CONDITION; } } else { /***********************************************/ /* Diff cap greater than 1 pf. */ /***********************************************/ if (normal_range_limits < normal_data) { /*******************************/ /* Current limit range error ? */ /*******************************/ if BETWEEN(cl_data,PROBE_CURRENT_LIMITS[list_entry].MIN[tk_lls], PROBE_CURRENT_LIMITS[list_entry].MAX[tk_lls]) /************************************************/ /* Setup to log tank unit short test failure. */ /************************************************/ probe_fault_status[list_entry] = SHORTED_CONDITION; else /************************************************/ /* Setup to log HiZ to GND short test failure. */ /************************************************/ receiver_fault_status[tk_lls] = HI_Z_SHORTED_CONDITION; } else { /*******************************/ /* Current limit range error ? */ /*******************************/ if BETWEEN(cl_data,PROBE_CURRENT_LIMITS[list_entry].MIN[tk_lls], PROBE_CURRENT_LIMITS[list_entry].MAX[tk_lls]) /************************************/ /* Setup to log short test failure. */ /************************************/ probe_fault_status[list_entry] = SHORTED_CONDITION; } } }/* for loop */ } /* end diff offset range test */ } /* end if no failures found */ } /* end tk_lls loop */ #pragma EJECT for (tk_lls = 0; tk_lls < NUMBER_OF_RECEIVERS; tk_lls++) { /************************************************/ /* If all tank probes have failed the open test */ /* then setup to log a HiZ open failure. */ /************************************************/ for (probe_id = 0; (probe_id < (NUMBER_OF_CHANNEL_1_PROBES - tk_lls)) && (RESET == log_individual_fault [tk_lls]); probe_id++) { list_entry = PROBE_LIST[tk_lls][probe_id]; /************************************************/ /* And probe not open on this receiver? */ /************************************************/ if (OPEN_CONDITION != probe_fault_status[list_entry]) log_individual_fault [tk_lls] = SET; } } for (tk_lls = 0; tk_lls < NUMBER_OF_RECEIVERS; tk_lls++) { if (TANK_REC_CYCLE == tk_lls) { start_loop = RESET; end_loop = NUMBER_OF_CHANNEL_1_PROBES; } else { start_loop = RESET; end_loop = NUMBER_OF_CHANNEL_2_PROBES; } for (probe_id = start_loop; probe_id < end_loop; probe_id++) { list_entry = PROBE_LIST[tk_lls][probe_id]; switch (probe_fault_status[list_entry]) { case NORMAL_CONDITION : fai_pass_fail_logger((CHANNEL1_HI_Z_OPEN_TEST_ID+tk_lls),PASS); if (list_entry < 7) fai_pass_fail_logger((OPEN_TEST_OFFSET + list_entry), PASS); else fai_pass_fail_logger((PROBE_8_OPEN_TEST_ID + tk_lls), PASS); if (list_entry == 6 || list_entry == 7) list_entry--; if (list_entry == 8) list_entry = list_entry - 2; fai_pass_fail_logger((SHORTED_TEST_OFFSET+list_entry), PASS); fai_pass_fail_logger((LO_Z_SHORTED_TEST_OFFSET+list_entry),PASS); break; case OPEN_CONDITION : if (SET == log_individual_fault[tk_lls]) { if (list_entry < 7) fai_pass_fail_logger((OPEN_TEST_OFFSET + list_entry), FAIL); else fai_pass_fail_logger((PROBE_8_OPEN_TEST_ID + tk_lls), FAIL); if (list_entry == 6 || list_entry == 7) list_entry--; if (list_entry == 8) list_entry = list_entry - 2; fai_pass_fail_logger((SHORTED_TEST_OFFSET+list_entry), PASS); fai_pass_fail_logger((LO_Z_SHORTED_TEST_OFFSET+list_entry),PASS); } else { fai_pass_fail_logger((CHANNEL1_HI_Z_OPEN_TEST_ID+tk_lls), FAIL); if (list_entry < 7) fai_pass_fail_logger((OPEN_TEST_OFFSET + list_entry), PASS); else fai_pass_fail_logger((PROBE_8_OPEN_TEST_ID + tk_lls), PASS); if (list_entry == 6 || list_entry == 7) list_entry--; if (list_entry == 8) list_entry = list_entry - 2; fai_pass_fail_logger((LO_Z_SHORTED_TEST_OFFSET+list_entry),PASS); } break; case SHORTED_CONDITION : if (list_entry < 7) fai_pass_fail_logger((OPEN_TEST_OFFSET + list_entry), PASS); else fai_pass_fail_logger((PROBE_8_OPEN_TEST_ID + tk_lls), PASS); if (list_entry == 6 || list_entry == 7) list_entry--; if (list_entry == 8) list_entry = list_entry - 2; fai_pass_fail_logger((SHORTED_TEST_OFFSET+list_entry), FAIL); fai_pass_fail_logger((LO_Z_SHORTED_TEST_OFFSET+list_entry),PASS); break; case LO_Z_SHORTED_CONDITION: if (list_entry < 7) fai_pass_fail_logger((OPEN_TEST_OFFSET + list_entry), PASS); else fai_pass_fail_logger((PROBE_8_OPEN_TEST_ID + tk_lls), PASS); if (list_entry == 6 || list_entry == 7) list_entry--; if (list_entry == 8) list_entry = list_entry - 2; fai_pass_fail_logger((LO_Z_SHORTED_TEST_OFFSET+list_entry),FAIL); fai_pass_fail_logger((SHORTED_TEST_OFFSET+list_entry), PASS); break; default: break; } /* end switch */ } switch (receiver_fault_status[tk_lls]) { case NORMAL_CONDITION : /*if (TANK_REC_CYCLE == tk_lls) */ fai_pass_fail_logger((CHANNEL1_HI_Z_SHORT_TEST_ID+tk_lls),PASS); /*else */ // use range test id to log HIz short for lls /*fai_pass_fail_logger(LO_LEVEL_HIZ_SHORT_TEST_ID,PASS);*/ break; case HI_Z_SHORTED_CONDITION: /*if (TANK_REC_CYCLE == tk_lls) */ fai_pass_fail_logger((CHANNEL1_HI_Z_SHORT_TEST_ID+tk_lls),FAIL); /*else */ // use range test id to log HIz short for lls /*fai_pass_fail_logger(LO_LEVEL_HIZ_SHORT_TEST_ID,FAIL);*/ break; default: break; } } g_autocal_data_complete = RESET; } /* end g_autocal_data_complete = SET */ } /***************************************************************************/ /* */ /* Unit Name : acq_setup_tu_status */ /* Description : This unit sets up the tank unit status word */ /* */ /* Inputs : g_own_fault_status */ /* */ /* Outputs : g_own_tu_status, g_own_tu_status1 */ /* */ /* Called by : main (background executive) */ /* Calls : None */ /* */ /***************************************************************************/ void acq_setup_tu_status (void) { #define LIST_SIZE 41 code struct LIST { uchar fault_num; uchar code_index; } fault [LIST_SIZE] = {{CHANNEL1_AD_TEST_ID, 12}, {CHANNEL2_AD_TEST_ID, 12}, {CHANNEL1_GAIN_TEST_ID, 12}, {CHANNEL2_GAIN_TEST_ID, 12}, {CHANNEL1_OFFSET_TEST_ID, 12}, {CHANNEL2_OFFSET_TEST_ID, 12}, {CHANNEL1_SLOPE_HI_TEST_ID, 12}, {CHANNEL2_SLOPE_HI_TEST_ID, 12}, {CHANNEL1_SLOPE_LOW_TEST_ID, 12}, {CHANNEL2_SLOPE_LOW_TEST_ID, 12}, {CHANNEL1_HI_Z_SHORT_TEST_ID, 11}, {CHANNEL2_HI_Z_SHORT_TEST_ID, 11}, {CHANNEL1_HI_Z_OPEN_TEST_ID, 11}, {CHANNEL2_HI_Z_OPEN_TEST_ID, 11}, {CHANNEL1_CL_TEST_ID, 12}, {CHANNEL2_CL_TEST_ID, 12}, {PROBE_8_OPEN_TEST_ID, 7}, {PROBE_9_OPEN_TEST_ID, 8}, {PROBE_5_RANGE_TEST_ID, 12}, {PROBE_6_RANGE_TEST_ID, 12}, {PROBE_1_SHORTED_TEST_ID, 0}, {PROBE_2_SHORTED_TEST_ID, 1}, {PROBE_3_SHORTED_TEST_ID, 2}, {PROBE_4_SHORTED_TEST_ID, 3}, {PROBE_5_SHORTED_TEST_ID, 4}, {PROBE_6_7_SHORTED_TEST_ID, 9}, {PROBE_8_9_SHORTED_TEST_ID, 10}, {PROBE_1_OPEN_TEST_ID, 0}, {PROBE_2_OPEN_TEST_ID, 1}, {PROBE_3_OPEN_TEST_ID, 2}, {PROBE_4_OPEN_TEST_ID, 3}, {PROBE_5_OPEN_TEST_ID, 4}, {PROBE_6_OPEN_TEST_ID, 5}, {PROBE_7_OPEN_TEST_ID, 6}, {PROBE_1_LOZ_SHORTED_TEST_ID, 0}, {PROBE_2_LOZ_SHORTED_TEST_ID, 1}, {PROBE_3_LOZ_SHORTED_TEST_ID, 2}, {PROBE_4_LOZ_SHORTED_TEST_ID, 3}, {PROBE_5_LOZ_SHORTED_TEST_ID, 4}, {PROBE_6_7_LOZ_SHORTED_TEST_ID,9}, {PROBE_8_9_LOZ_SHORTED_TEST_ID,10} }; xdata uchar fault_count; xdata uchar fault_index; xdata uchar found; /*******************************************************/ /* If probe failure is detected, set the corresponding */ /* bit in the Tank Unit Status word to indicate a */ /* current or stored fault. */ /*******************************************************/ for (fault_count=0; fault_count < 2 /*(NUMBER_OF_FAULTS)*/; fault_count++) { if (g_own_fault_status[fault_count].fault_id == NO_FAULT_DATA) { ; } else { found = FALSE; fault_index = 0; while ((found == FALSE) && (fault_index < LIST_SIZE)) { if (g_own_fault_status[fault_count].fault_id == fault [fault_index].fault_num) { found=TRUE; /*******************************************************/ /* If any HiZ open or */ /* short or tank unit failure has occurred, set the */ /* Tank Unit Fault bit in the system status word. */ /*******************************************************/ if (g_own_fault_status[fault_count].pass_fail_status == FAIL) { /*****************************************/ /* Determine which probe has failed and */ /* set that bit in the Tank Unit Status */ /* word. */ /*****************************************/ switch (fault [fault_index].code_index) { case 0: g_own_tu1_chan = SET; g_own_stored_tu1_chan = SET; break; case 1: g_own_tu2_chan = SET; g_own_stored_tu2_chan = SET; break; case 2: g_own_tu3_chan = SET; g_own_stored_tu3_chan = SET; break; case 3: g_own_tu4_chan = SET; g_own_stored_tu4_chan = SET; break; case 4: g_own_tu5_chan = SET; g_own_stored_tu5_chan = SET; break; case 5: g_own_tu6_chan = SET; g_own_stored_tu6_chan = SET; break; case 6: g_own_tu7_chan = SET; g_own_stored_tu7_chan = SET; break; case 7: g_own_tu8_chan = SET; g_own_stored_tu8_chan = SET; break; case 8: g_own_tu9_chan = SET; g_own_stored_tu9_chan = SET; break; case 9: g_own_tu6_chan = SET; g_own_tu7_chan = SET; g_own_stored_tu6_chan = SET; g_own_stored_tu7_chan = SET; break; case 10: g_own_tu8_chan = SET; g_own_tu9_chan = SET; g_own_stored_tu8_chan = SET; g_own_stored_tu9_chan = SET; break; case 11: g_set_tu_bit = SET; break; case 12: break; default: break; } // end switch } else { /*****************************************/ /* Determine which probe has passed and */ /* clear that bit in the Tank Unit Status*/ /* word. */ /*****************************************/ switch (fault [fault_index].code_index) { case 0: g_own_tu1_chan = RESET; break; case 1: g_own_tu2_chan = RESET; break; case 2: g_own_tu3_chan = RESET; break; case 3: g_own_tu4_chan = RESET; break; case 4: g_own_tu5_chan = RESET; break; case 5: g_own_tu6_chan = RESET; break; case 6: g_own_tu7_chan = RESET; break; case 7: g_own_tu8_chan = RESET; break; case 8: g_own_tu9_chan = RESET; break; case 9: g_own_tu6_chan = RESET; g_own_tu7_chan = RESET; break; case 10: g_own_tu8_chan = RESET; g_own_tu9_chan = RESET; break; case 11: g_set_tu_bit = RESET; break; case 12: break; default: break; } // end switch } } // fault not in list fault_index++; } // end while loop } }// end for loop /*****************************************/ /* Determine whether to set TU bit in */ /* the system status word or not. */ /*****************************************/ if ((g_own_tu_status & 0x01ff) || (g_set_tu_bit == SET)) { if (g_own_proc_id == RIGHT_PROCESSOR) g_own_tu = SET; else g_others_tu = SET; /* if (g_own_tu_status & 0x01ff) g_own_tu_status_ssm = SSM_NORMAL_OPERATION;*/ /* 11 - which is defined as failure warning for tu status*/ /* else */ g_own_tu_status_ssm = SSM_FAILURE_WARNING; /* 00 - which is defined as normal operation for tu status */ } else { if (g_own_proc_id == RIGHT_PROCESSOR) g_own_tu = RESET; else g_others_tu = RESET; g_own_tu_status_ssm = SSM_FAILURE_WARNING; /* 00 - which is defined as normal operation for tu status */ } /*****************************************/ /* Determine TU bit and FQC bit for the */ /* other side from system status word */ /* received via interprocessor. */ /*****************************************/ if (g_own_proc_id == RIGHT_PROCESSOR) { if (g_system_status & 0x08) /* left TU */ g_others_tu = SET; else g_others_tu = RESET; if (g_system_status & 0x10) /* left FQC */ g_others_fqc = SET; else g_others_fqc = RESET; } else { if (g_system_status & 0x40) /* right TU */ g_own_tu = SET; else g_own_tu = RESET; if (g_system_status & 0x80) /* right FQC */ g_own_fqc = SET; else g_own_fqc = RESET; if (g_system_status & 0x0100) /* RDP fault */ g_own_sys_ref_panel = SET; else g_own_sys_ref_panel = RESET; } /*****************************************/ /* Set the RDI Enable bit on ARINC */ /* according to the refuel door status */ /*****************************************/ g_own_RDI_enable = ~g_own_refuel_door; /*****************************************/ /* Determine ssm failure warning for the */ /* system status word. */ /*****************************************/ /*if (g_own_system_status & 0x05d8) g_own_system_status_ssm = SSM_NORMAL_OPERATION;*/ /* 11 - which is defined as failure warning for system status*/ /*else*/ g_own_system_status_ssm = SSM_FAILURE_WARNING; /* 00 - which is defined as normal operation for system status */ }