Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r3b5080777e3dac1b5802ee18227f66a0b49deefa -r7d293e18ea5ac0fce443c68525100e44df80b4fd --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 3b5080777e3dac1b5802ee18227f66a0b49deefa) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 7d293e18ea5ac0fce443c68525100e44df80b4fd) @@ -43,7 +43,7 @@ // ********** private definitions ********** #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. -#define TARGET_RO_FLOW_RATE_L 0.8 ///< Target flow rate for RO pump. +#define TARGET_RO_FLOW_RATE_L 0.8 //TODO do we need to use this as default? ///< Target flow rate for RO pump. #define DIALYSATE_FILL_TIME_OUT ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time out period when reservoir is not filled with correct dialysate. #define EMPTY_BOTTLE_DETECT_PERSISTENT_PERIOD_MS ( 5 * MS_PER_SECOND ) ///< Persistent period for empty bottle detect. @@ -153,7 +153,7 @@ DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); initFillMode(); - reservoirBaseWeight = getReservoirWeight( inactiveReservoir ); + reservoirBaseWeight = getReservoirWeight( inactiveReservoir ); dialysateFillStartTime = getMSTimerCount(); // Set initial actuator states @@ -167,7 +167,7 @@ // because the initial guess in the heaters driver needs the target flow to calculate // the new PWMs for the main and small primary heaters #ifndef DISABLE_FLOW_CONTROL_TREATMENT - setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); + setROPumpTargetFlowRate( getTargetFillFlowRateLPM(), TARGET_RO_PRESSURE_PSI ); #endif startHeater( DG_PRIMARY_HEATER ); @@ -471,15 +471,18 @@ *************************************************************************/ static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ) { - F32 measuredROFlowRate_mL_min = getMeasuredROFlowRate() * ML_PER_LITER; - F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); - F32 dialysateConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); - BOOL isAcidConductivityOutOfRange = ( acidConductivity <= MIN_ACID_CONCENTRATE_CONDUCTIVITY ) || ( acidConductivity >= MAX_ACID_CONCENTRATE_CONDUCTIVITY ); - BOOL isDialysateConductivityOutOfRange = ( dialysateConductivity <= MIN_DIALYSATE_CONDUCTIVITY ) || ( dialysateConductivity >= MAX_DIALYSATE_CONDUCTIVITY ); + F32 integratedVolume_mL; - DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; + F32 measuredROFlowRate_mL_min = getMeasuredROFlowRate() * ML_PER_LITER; + F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); + F32 dialysateConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + BOOL isAcidConductivityOutOfRange = ( acidConductivity <= MIN_ACID_CONCENTRATE_CONDUCTIVITY ) || + ( acidConductivity >= MAX_ACID_CONCENTRATE_CONDUCTIVITY ) ? TRUE : FALSE; + BOOL isDialysateConductivityOutOfRange = ( dialysateConductivity <= MIN_DIALYSATE_CONDUCTIVITY ) || + ( dialysateConductivity >= MAX_DIALYSATE_CONDUCTIVITY ) ? TRUE : FALSE; + + DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); - F32 integratedVolume_mL; // Set concentrate pumps speed based off RO pump flow rate handleDialysateMixing( measuredROFlowRate_mL_min );