Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r092b20aaea3defad5e1dbacf5a3f87e67256bd45 -r1a5efe97f5f39594b45797fded52cafce92afe80 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 092b20aaea3defad5e1dbacf5a3f87e67256bd45) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 1a5efe97f5f39594b45797fded52cafce92afe80) @@ -33,7 +33,7 @@ // ********** private definitions ********** -#define TARGET_DRAIN_PUMP_RPM 1800 ///< Target drain pump speed (in RPM). +#define TARGET_DRAIN_PUMP_RPM 2100 ///< Target drain pump speed (in RPM). #define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 2 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. /// Time period to wait after drain complete and before taring load cells. #define DRAIN_EMPTY_TARE_WAIT ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) @@ -49,6 +49,8 @@ static DG_DRAIN_STATE_T drainState; ///< Currently active drain state. static U32 drainEmptyTareTimerCtr; ///< Timer counter for delay between drain complete and load cell tare. +static U32 tempTrans = 0; + // ********** private function prototypes ********** static DG_DRAIN_STATE_T handleDrainState( void ); @@ -94,7 +96,12 @@ // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setDrainPumpTargetRPMDelayed( TARGET_DRAIN_PUMP_RPM, DELAY_DRAIN_PUMP_MS ); + + // NOTE: The target flow rate should be set prior to setting the start primary heater + // because the initial guess in the heaters driver needs the target flow to calculate + // the new PWMs for the main and small primary heaters setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); + startPrimaryHeater(); } /*********************************************************************//** @@ -150,10 +157,29 @@ static DG_DRAIN_STATE_T handleDrainState( void ) { DG_DRAIN_STATE_T result = DG_DRAIN_STATE_DRAIN; + + // TODO test code remove DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); + if ( ++tempTrans == 20 ) + { + if ( DG_RESERVOIR_2 == inactiveReservoir ) + { + setValveState( VRD2, VALVE_STATE_OPEN ); + } + else if ( DG_RESERVOIR_1 == inactiveReservoir ) + { + setValveState( VRD1, VALVE_STATE_OPEN ); + } + } + else if ( tempTrans == 40 ) + { + setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); + } + // TODO test code remove + // if we have reached our target drain to volume (by weight) or cannot drain anymore, we are done draining - go back to re-circ mode - if ( hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT ) ) + if ( TRUE == hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT ) ) { setDrainPumpTargetRPM( 0 ); @@ -199,6 +225,11 @@ drainEmptyTareTimerCtr = 0; tareLoadCellsAtEmpty( inactiveReservoir ); requestNewOperationMode( DG_MODE_CIRC ); + +#ifndef V_2_SYSTEM + setValveState( VRD1, VALVE_STATE_CLOSED ); + setValveState( VRD2, VALVE_STATE_CLOSED ); +#endif } return result;