Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r2468e56fbecd26da713bc78535bd727f4b105fe1 -rab7dfc361e5ee347141842b317f1fc2f16e4e3f3 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 2468e56fbecd26da713bc78535bd727f4b105fe1) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision ab7dfc361e5ee347141842b317f1fc2f16e4e3f3) @@ -316,15 +316,16 @@ DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_BICARB_PUMP_CHECK; DG_BICARB_CONCENTRATES_RECORD_T bicarb = getBicarbConcentrateCalRecord(); F32 const measuredROFlowRate_mL_min = getMeasuredROFlowRate() * ML_PER_LITER; - F32 const bicarbPumpFlowRate_mL_min = measuredROFlowRate_mL_min * bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio + + F32 bicarbPumpFlowRate_mL_min = measuredROFlowRate_mL_min * bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio + CONCENTRATE_PUMP_PRIME_EXTRA_SPEED_ML_MIN; - #ifndef DISABLE_DIALYSATE_CHECK F32 const bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); #else - F32 const bicarbConductivity = MIN_BICARB_CONCENTRATE_CONDUCTIVITY; + F32 const bicarbConductivity = MAX_BICARB_CONCENTRATE_CONDUCTIVITY; #endif + bicarbPumpFlowRate_mL_min = MIN( bicarbPumpFlowRate_mL_min, CONCENTRATE_PUMP_MAX_SPEED ); + if ( MIN_BICARB_CONCENTRATE_CONDUCTIVITY <= bicarbConductivity ) { // Reduce acid pump speed after reaching minimum conductivity @@ -377,9 +378,11 @@ #ifndef DISABLE_DIALYSATE_CHECK F32 const acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); #else - F32 const acidConductivity = MIN_ACID_CONCENTRATE_CONDUCTIVITY; + F32 const acidConductivity = MAX_ACID_CONCENTRATE_CONDUCTIVITY; #endif + acidPumpFlowRate_mL_min = MIN( acidPumpFlowRate_mL_min, CONCENTRATE_PUMP_MAX_SPEED ); + if ( MIN_ACID_CONCENTRATE_CONDUCTIVITY <= acidConductivity ) { // Reduce acid pump speed after reaching minimum conductivity @@ -429,10 +432,12 @@ { // Prime mixing before deliver result to reservoir handleDialysateMixing( measuredROFlowRate_mL_min ); +#ifndef DISABLE_MIXING requestConcentratePumpOn( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); if ( concentratePumpPrimeCount++ > CONCENTRATE_PUMP_PRIME_INTERVAL ) +#endif { setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; @@ -512,7 +517,7 @@ result = DG_FILL_MODE_STATE_PAUSED; } #endif - +#ifndef DISABLE_MIXING if ( ( ACID_CONCENTRATION_BOTTLE_VOLUME_ML - getF32OverrideValue( &usedAcidVolume_mL ) ) <= CONCENTRATION_BOTTLE_LOW_VOLUME_ML ) { activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); @@ -522,18 +527,18 @@ { activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); } - +#endif // 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 ) ) || ( ( integratedVolume_mL - reservoirBaseWeight ) >= MAX_RESERVOIR_VOLUME_ML ) ) + 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; + F32 const avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; // TODO - should we be checking this below? F32 const avgDialysateConductivity = dialysateConductivityTotal / conductivitySampleCount; if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) { -#ifndef DISABLE_MIXING +#ifndef DISABLE_FLOW_CHECK_IN_FILL SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FLOW_METER_CHECK_FAILURE, filledVolume_mL, integratedVolume_mL ); #endif }