Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rf38051e1882be3e774f10ba924343a6ce1334890 -r2468e56fbecd26da713bc78535bd727f4b105fe1 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision f38051e1882be3e774f10ba924343a6ce1334890) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 2468e56fbecd26da713bc78535bd727f4b105fe1) @@ -71,6 +71,8 @@ #define RO_FLOW_ADC_TO_LPM_FACTOR 5555 ///< Conversion factor from ADC counts to LPM (liters/min) for RO flow rate (multiply this by inverse of FPGA reading). #endif +#define RO_FLOW_ADC_TO_LPM_FACTOR_TEMP_REMOVE 5555 + #define ROP_FLOW_TO_PWM_SLOPE 0.1 ///< Slope of flow to PWM line equation. #define ROP_FLOW_TO_PWM_INTERCEPT 0.0 ///< Intercept of flow to PWM line equation. @@ -139,6 +141,12 @@ static U32 flowFilterCounter = 0; ///< Flow filtering counter. static DG_FLOW_SENSORS_CAL_RECORD_T flowSensorsCalRecord; ///< Flow sensors calibration record. +// TODO remove +static S32 temporaryFlowVariableRemove; +static F32 temporaryFlowValueRemove; + +// TODO remove + // ********** private function prototypes ********** static RO_PUMP_STATE_T handleROPumpOffState( void ); @@ -195,6 +203,10 @@ roPumpState = RO_PUMP_OFF_STATE; roPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; isROPumpOn = FALSE; + + + temporaryFlowVariableRemove = 0; + temporaryFlowValueRemove = 0.0; } /*********************************************************************//** @@ -332,6 +344,11 @@ // Update sum for flow average calculation measuredFlowReadingsSum += (S32)roFlowReading; + // TODO remove this code + U16 tempROFlowRemove = getFPGAFMPTemporaryFlow(); + temporaryFlowVariableRemove += (S32)tempROFlowRemove; + // TODO remove this code + // Read the pressure at the sensor. The pump cannot be more that the maximum allowed pressure // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); @@ -365,6 +382,25 @@ measuredFlowReadingsSum = 0; flowFilterCounter = 0; + + // TODO remove this code after testing + F32 flowTemp = RO_FLOW_ADC_TO_LPM_FACTOR_TEMP_REMOVE / ( (F32)temporaryFlowVariableRemove * FLOW_AVERAGE_MULTIPLIER ); + + temporaryFlowValueRemove = pow(flowTemp, 4) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].fourthOrderCoeff + + pow(flowTemp, 3) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].thirdOrderCoeff + + pow(flowTemp, 2) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].secondOrderCoeff + + flowTemp * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + + flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; + + // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that + // the flow is 0. + if ( FLOW_SENSOR_ZERO_READING == tempROFlowRemove ) + { + temporaryFlowValueRemove = 0.0; + } + + temporaryFlowVariableRemove = 0; + // TODO remove this code after testing } #ifndef IGNORE_RO_PUMP_MONITOR @@ -839,6 +875,8 @@ pumpData.roPumpDutyCycle = roPumpDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; pumpData.roPumpState = (U32)roPumpState; + pumpData.roPumpTemporaryFlowRateRemove = temporaryFlowValueRemove; + broadcastROPumpData( &pumpData ); roPumpDataPublicationTimerCounter = 0; }