Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -rcff72ec53660ec3ff6775c0508e3c721240ffba2 --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision cff72ec53660ec3ff6775c0508e3c721240ffba2) @@ -119,6 +119,7 @@ static F32 calculateBaroPressure( U32 adcSum ); static F32 getCalibrationAppliedPressure( U08 sensorId, F32 pressure ); static F32 getBaroPressurePSI( void ); +static void monitorPressureSensors( void ); /*********************************************************************//** * @brief @@ -306,8 +307,6 @@ U32 zeroPressureOffset = PUMP_PRESSURE_ZERO; F32 count2PressureConv = PUMP_PRESSURE_PSIA_PER_COUNT; U08 sensorId; - F32 pressureReading; - BOOL isPressureOutOfRange; #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) @@ -376,35 +375,7 @@ } } - for ( sensorId = 0; sensorId < NUM_OF_PRESSURE_SENSORS; sensorId++ ) - { - switch ( sensorId ) - { - case PRESSURE_SENSOR_RO_PUMP_INLET: - case PRESSURE_SENSOR_RO_PUMP_OUTLET: - case PRESSURE_SENSOR_DRAIN_PUMP_INLET: - case PRESSURE_SENSOR_DRAIN_PUMP_OUTLET: - pressureReading = getMeasuredDGPressure( sensorId ) + getBaroPressurePSI(); - isPressureOutOfRange = ( ( pressureReading < MIN_VALID_PRESSURE_RANGE_PSIA ) || ( pressureReading > MAX_VALID_PRESSURE_RANGE_PSIA ) ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_DG_PRESSURE_OUT_OF_RANGE, isPressureOutOfRange, (F32)sensorId, pressureReading ); - break; - - case PRESSURE_SENSOR_BAROMETRIC: - if ( baroConvConsts.pressureSensitivity != 0 ) - { - pressureReading = getBaroPressurePSI(); - isPressureOutOfRange = ( ( pressureReading < MIN_VALID_BARO_PRESSURE_PSIA ) || ( pressureReading > MAX_VALID_BARO_PRESSURE_PSIA ) ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE, isPressureOutOfRange, (F32)sensorId, pressureReading ); - } - break; - -#ifndef _VECTORCAST_ - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_PRESSURE_SENSOR_SELECTED, sensorId ); - break; -#endif - } - } + monitorPressureSensors(); return result; } @@ -533,6 +504,65 @@ return baroPressure; } + +/*********************************************************************//** + * @brief + * The monitorPressureSensors function monitors the pressure sensors to be + * in range. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +static void monitorPressureSensors( void ) +{ + U08 sensorId; + BOOL isPressureOutOfRange = FALSE; + BOOL isCurrentPressureOut = FALSE; + BOOL isBaroOutOfRange = FALSE; + F32 pressureOutID = 0.0F; + F32 pressureReading = 0.0F; + + for ( sensorId = 0; sensorId < NUM_OF_PRESSURE_SENSORS; sensorId++ ) + { + switch ( sensorId ) + { + case PRESSURE_SENSOR_RO_PUMP_INLET: + case PRESSURE_SENSOR_RO_PUMP_OUTLET: + case PRESSURE_SENSOR_DRAIN_PUMP_INLET: + case PRESSURE_SENSOR_DRAIN_PUMP_OUTLET: + // Get the pressure and convert it back to absolute by adding back the baro pressure value + // Check if the pressure is out of the upper or lower range + // Bitwise OR the current pressure sensor with the total pressure sensor to persistent alarm check + // Remember the ID of the pressure sensor that is out of range. The ID is converted to float since the check persistent alarm function + // accepts only floats. + pressureReading = getMeasuredDGPressure( sensorId ) + getBaroPressurePSI(); + isCurrentPressureOut = ( ( pressureReading < MIN_VALID_PRESSURE_RANGE_PSIA ) || ( pressureReading > MAX_VALID_PRESSURE_RANGE_PSIA ) ? TRUE : FALSE ); + isPressureOutOfRange |= isCurrentPressureOut; + pressureOutID = ( TRUE == isCurrentPressureOut ? (F32)sensorId : pressureOutID ); + break; + + case PRESSURE_SENSOR_BAROMETRIC: + if ( baroConvConsts.pressureSensitivity != 0 ) + { + // Check the baro and alarm if out of range. Make sure the conversion coefficients of the sensor has been read and received from FPGA + pressureReading = getBaroPressurePSI(); + isBaroOutOfRange = ( ( pressureReading < MIN_VALID_BARO_PRESSURE_PSIA ) || ( pressureReading > MAX_VALID_BARO_PRESSURE_PSIA ) ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE, isBaroOutOfRange, (F32)sensorId, pressureReading ); + } + break; + +#ifndef _VECTORCAST_ + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_PRESSURE_SENSOR_SELECTED, sensorId ); + break; +#endif + } + } + + // TODO remove + // Once the sensors were all checked to be out of range, check the persistent alarm + //checkPersistentAlarm( ALARM_ID_DG_PRESSURE_OUT_OF_RANGE, isPressureOutOfRange, pressureOutID, pressureReading ); +} /*************************************************************************