Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r353d01d31bc69d4d1901ff09097ee610bb1c9dbc -ra3960210792d0811093a6913e505d43eda1918ea --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 353d01d31bc69d4d1901ff09097ee610bb1c9dbc) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a3960210792d0811093a6913e505d43eda1918ea) @@ -119,15 +119,16 @@ *************************************************************************/ void initFillMode( void ) { - fillState = DG_FILL_MODE_STATE_START; - dialysateFillStartTime = 0; - reservoirBaseWeight = 0.0; - totalROFlowRate_mL_min = 0.0; - concentrateTestStartTime = 0; - acidConductivityTotal = 0.0; - dialysateConductivityTotal = 0.0; - conductivitySampleCount = 0; - concentratePumpPrimeCount = 0; + fillState = DG_FILL_MODE_STATE_START; + dialysateFillStartTime = 0; + reservoirBaseWeight = 0.0; + totalROFlowRate_mL_min = 0.0; + concentrateTestStartTime = 0; + acidConductivityTotal = 0.0; + dialysateConductivityTotal = 0.0; + conductivitySampleCount = 0; + concentratePumpPrimeCount = 0; + // Get the heaters info form the NV data management DG_HEATERS_RECORD_T heaterInfo = getHeatersInfoReocrd(); // If the data in the NV data management was not initialized properly, set it to 0 otherwise, set the average flow rate @@ -136,6 +137,9 @@ fillStatus.fillSampleCounter = 0; fillStatus.fillTemperatureRunningSum = 0.0; fillStatus.fillTemperatureAverage = 0.0; + // The last fill temperature is initialized to TPo because this value is used for heater calculations prior to filling the + // reservoirs. The first actual value will be updated at the end of the fill cycle. + fillStatus.fillLastTemperature = getTemperatureValue( (U32)TEMPSENSORS_INLET_PRIMARY_HEATER ); initPersistentAlarm( ALARM_ID_ACID_CONDUCTIVITY_OUT_OF_RANGE, 0, EMPTY_BOTTLE_DETECT_PERSISTENT_PERIOD_MS ); initPersistentAlarm( ALARM_ID_BICARB_CONDUCTIVITY_OUT_OF_RANGE, 0, EMPTY_BOTTLE_DETECT_PERSISTENT_PERIOD_MS ); @@ -545,10 +549,10 @@ // If we've reached our target fill to volume (by weight), we're done filling - go back to generation idle mode if ( TRUE == hasTargetFillVolumeBeenReached( inactiveReservoir ) ) { - F32 const filledVolume_mL = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; - F32 const integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolume_mL / integratedVolume_mL ) ); - F32 const avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; // TODO - should we be checking this below? - F32 const avgDialysateConductivity = dialysateConductivityTotal / conductivitySampleCount; + F32 filledVolume_mL = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; + F32 integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolume_mL / integratedVolume_mL ) ); + F32 avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; // TODO - should we be checking this below? + F32 avgDialysateConductivity = dialysateConductivityTotal / conductivitySampleCount; if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) {