Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -raa8dbad6005f0f63b846673ac1656b003fbf85e3 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision aa8dbad6005f0f63b846673ac1656b003fbf85e3) @@ -138,6 +138,7 @@ static S32 measuredFlowReadingsSum = 0; ///< Raw flow reading sums for averaging. static U32 flowFilterCounter = 0; ///< Flow filtering counter. static DG_FLOW_SENSORS_CAL_RECORD_T flowSensorsCalRecord; ///< Flow sensors calibration record. +static OVERRIDE_F32_T measuredROFlowRateWithConcPumpsLPM = { 0.0, 0.0, 0.0, 0 }; ///< Measure RO flow rate with concentrate pumps (L/min). // ********** private function prototypes ********** @@ -331,8 +332,8 @@ *************************************************************************/ void execROPumpMonitor( void ) { - U16 roFlowReading = getFPGAROPumpFlowRate(); - U16 roFeedbackVoltage = getIntADCVoltageConverted( INT_ADC_RO_PUMP_FEEDBACK_DUTY_CYCLE ); + U32 roFlowReading = (U32)getFPGAROPumpFlowRate(); + F32 roFeedbackVoltage = getIntADCVoltageConverted( INT_ADC_RO_PUMP_FEEDBACK_DUTY_CYCLE ); // Update sum for flow average calculation measuredFlowReadingsSum += (S32)roFlowReading; @@ -355,14 +356,15 @@ { F32 flow = RO_FLOW_ADC_TO_LPM_FACTOR / ( (F32)measuredFlowReadingsSum * FLOW_AVERAGE_MULTIPLIER ); - flow = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); + flow = pow(flow, 4) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].fourthOrderCoeff + + pow(flow, 3) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].thirdOrderCoeff + + pow(flow, 2) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].secondOrderCoeff + + flow * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + + flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; - measuredROFlowRateLPM.data = pow(flow, 4) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].fourthOrderCoeff + - pow(flow, 3) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].thirdOrderCoeff + - pow(flow, 2) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].secondOrderCoeff + - flow * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + - flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; + measuredROFlowRateWithConcPumpsLPM.data = flow; + measuredROFlowRateLPM.data = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - + ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that // the flow is 0. @@ -547,6 +549,19 @@ /*********************************************************************//** * @brief + * The getMeasuredROFlowRateWithConcPumpsLPM function gets the measured RO + * pump flow rate with the concentrate pumps. + * @details Inputs: measuredROFlowRateWithConcPumpsLPM + * @details Outputs: measuredROFlowRateWithConcPumpsLPM + * @return the current RO pump flow rate with the concentrate pumps (in L/min). + *************************************************************************/ +F32 getMeasuredROFlowRateWithConcPumpsLPM( void ) +{ + return getF32OverrideValue( &measuredROFlowRateWithConcPumpsLPM ); +} + +/*********************************************************************//** + * @brief * The getTargetROPumpPressure function gets the current target RO pump * pressure. * @details Inputs: targetROPumpPressure