Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r7a4c91c04471aee469d1b4de128bfdf64e3dea1d -r158684426a4bd277a7b21626393eb6f41e705165 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 7a4c91c04471aee469d1b4de128bfdf64e3dea1d) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 158684426a4bd277a7b21626393eb6f41e705165) @@ -193,6 +193,7 @@ static U32 dryBiCartDrainTimePeriod; ///< Dry bicart drain time period static U32 dryBiCartPersistanceStartTime; ///< Dry bicart fill start time. +static BOOL dryBiCartPressureDecayStartTimeFlag; ///< Dry bicart d66 pressure decay start timer. static DRY_BICART_OPERATION_T dryBicartStartRequest; ///< Dry bicart operation, fill or supply or drain request // drybicart mixing @@ -385,6 +386,7 @@ dryBiCartMixControlInterval.ovInitData = 0; dryBiCartMixControlInterval.override = OVERRIDE_RESET; + dryBiCartPressureDecayStartTimeFlag = FALSE; dryBiCartFillStartTime = 0; lastFillDurationInMS = 0; currentFillDurationInMS = 0; @@ -1473,6 +1475,8 @@ { BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_START_STATE; + dryBiCartPressureDecayStartTimeFlag = FALSE; + if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) { state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; @@ -1620,16 +1624,23 @@ F32 d66Pressure = getFilteredPressure( D66_PRES ); LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); - // Once level reached, close the valve + // Once level reached, close the valve, timeout is for safety in case level sensor didn't work, or else its a time based filling if ( ( LVL_STATE_HIGH == bicarbChamberLevel ) || ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ) ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); + // start the timer for d66 pressure decay + if( FALSE == dryBiCartPressureDecayStartTimeFlag ) + { + dryBiCarbSupplyStartTime = getMSTimerCount(); + dryBiCartPressureDecayStartTimeFlag = TRUE; + } + // do not close the D80 valve, wait till d66 decays to 3 PSI if ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) { - if ( d66Pressure <= getDryBicartLowerCartPressure()) + if ( d66Pressure <= getDryBicartLowerCartPressure() ) { setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_OPEN ); @@ -1716,6 +1727,8 @@ // for this request override also cleared bicarbChamberFillRequested.ovData = FALSE; + dryBiCartPressureDecayStartTimeFlag = FALSE; + state = BICARB_CHAMBER_START_STATE; return state;