Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r2fb473f4574f9c150849bb39991a31bcadaae693 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 2fb473f4574f9c150849bb39991a31bcadaae693) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -8,10 +8,10 @@ * @file DryBiCart.c * * @author (original) Sameer poyil -* @date (original) 23-Oct-2025 +* @date (original) 10-Nov-2025 * * @author (original) Sameer poyil -* @date (original) 23-Oct-2025 +* @date (original) 10-Nov-2025 * ***************************************************************************/ @@ -41,24 +41,31 @@ // ********** private definitions ********** #define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. + +// Bicart Fill +#define DRY_BICART_FILL_DURATION_MIN_MS (2 * MS_PER_SECOND) ///< Minimum fill duration to be met to end the fill cycle. +#define DRY_BICART_FILL_DURATION_DIFF_MS 750 ///< Fill duration difference between last and current fill cycle. #define DRY_BICART_FILL_MAX_PRESSURE 12.0F ///< Maximum pressure that drybicart can withstand. #define DRY_BICART_FILL_COMPLETE_PRESSURE 15.0F ///< Maximum pressure reached to inidcate the drybicart fill being completed. #define DRY_BICART_FILL_INITIATE_PRESSURE 5.0F ///< Minimum pressure required to initiate the drybicart fill process. -#define DRY_BICART_VENT_COMPLETE_PRESSURE 1.5F ///< Pressure reached to inidcate the drybicart venting being completed. -#define DRY_BICART_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bibag gas before actuating Bicarb chamber(F) venting. -#define DRY_BICART_VENT_MAX_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. -#define DRY_BICART_FILL_DURATION_DIFF_MS 500 ///< Fill duration difference between last and current fill cycle. -#define DRY_BICART_FILL_DURATION_MIN_MS 1500 ///< Minimum fill duration to be met to end the fill cycle. #define DRY_BICART_DEFAULT_MAX_FILL_CYCLE_CNT 10 ///< Default max fill cycle allowed for dry bicart fill/mix with water. #define DRY_BICART_MAX_FILL_CYCLE_CNT 30 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. -//TODO: uncomment later based on the testing results -//#define VALV_D80_MAX_OPEN_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. -#define VALV_D80_MAX_OPEN_TIME_MS ( 500 ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. -#define DRY_BICART_MAX_DRAIN_TIME_MS ( 240 * MS_PER_SECOND ) ///< Max drain time for bicart chamber in ms. + +// Bicart Vent +#define DRY_BICART_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bibag gas before actuating Bicarb chamber(F) venting. +#define DRY_BICART_VENT_MAX_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. +#define DRY_BICART_VENT_TIME_MS ( 5 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. +#define DRY_BICART_VENT_COMPLETE_PRESSURE 1.5F ///< Pressure reached to inidcate the drybicart venting being completed. + +// Bicarb chamber fill/Supply +#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 3 * MS_PER_SECOND ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. + +// Bicart Drain +#define DRY_BICART_MAX_DRAIN_TIME_MS ( 4 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for bicart chamber in ms. +#define DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ( 3 * MS_PER_SECOND ) ///< Time to stay in fluid drain per cycle #define DRY_BICART_DRAIN_COND_SAMPLE_PERIOD_MS 50 ///< Conductivity sample period #define DRY_BICART_DRAIN_COND_ZERO_THRESH 0.05F ///< "Zero" conductivity threshold #define DRY_BICART_DRAIN_COND_STABLE_SAMPLES 10U ///< Debounce samples (10*50ms=500ms) -#define DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ( 3 * MS_PER_SECOND ) ///< Time to stay in fluid drain per cycle #define DRY_BICART_DRAIN_VENT_PHASE_TIME_MS 1500 ///< Time to keep D64 open per vent cycle #define DRY_BICART_DRAIN_COND_STABLE_COUNT_MAX 0xFFFFU @@ -80,6 +87,7 @@ static U32 currentFillDurationInMS; ///< Current time duartion to fill the bicart fill. static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop Dry bicart fill. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop Dry bicart drain. +static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop Dry bicart fill. static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. static U32 dryBiCarbSupplyStartTime; ///< Bicarb supply start time from bicart to Chamber F. @@ -132,6 +140,10 @@ dryBiCartFillRequested.ovData = FALSE; dryBiCartFillRequested.ovInitData = FALSE; dryBiCartFillRequested.override = 0; + dryBiCartDrainRequested.data = FALSE; + dryBiCartDrainRequested.ovData = FALSE; + dryBiCartDrainRequested.ovInitData = FALSE; + dryBiCartDrainRequested.override = 0; bicarbChamberFillRequested.data = FALSE; bicarbChamberFillRequested.ovData = FALSE; bicarbChamberFillRequested.ovInitData = FALSE; @@ -252,7 +264,7 @@ { DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_WATER_START_STATE; - // Close vent valves and descaling valve + // Close vent valves and de-scaling valve setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D81_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); @@ -455,8 +467,10 @@ switch ( bicarbChamberFillExecState ) { case BICARB_CHAMBER_START_STATE: + if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) { + bicarbChamberFillExecState = BICARB_CHAMBER_CHECK_LEVEL_STATE; bicarbChamberFillRequested.data = FALSE; } @@ -560,10 +574,11 @@ // Once level reached, close the valve if ( ( LEVEL_STATE_HIGH == bicarbChamberLevel ) || - ( TRUE == didTimeout( dryBiCarbSupplyStartTime, VALV_D80_MAX_OPEN_TIME_MS ) ) ) + ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ) ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); setValveState( D80_VALV, VALVE_STATE_CLOSED ); + state = BICARB_CHAMBER_START_STATE; } @@ -598,6 +613,13 @@ dryBiCartDrainLastCondSampleTime = dryBiCartDrainStartTime; dryBiCartDrainCondStableCount = 0; dryBiCartDrainExecState = DRY_BICART_FLUID_DRAIN_STATE; + + // open bypass valve + setValveState( D34_VALV, VALVE_STATE_OPEN ); + // open DD drain + setValveState( D53_VALV, VALVE_STATE_OPEN ); + // open iofp drain valve + setValveState( M12_VALV, VALVE_STATE_OPEN ); } break; @@ -649,7 +671,7 @@ setValveState( D14_VALV, VALVE_STATE_CLOSED ); // RUn D10 IN OPpen loop mode(max speed) - setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, 0xFFFF ); + setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, DOSING_CONT_VOLUME ); requestConcentratePumpOn( D10_PUMP ); // Run D48 @@ -768,6 +790,13 @@ setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); + // close bypass valve + setValveState( D34_VALV, VALVE_STATE_CLOSED ); + // close DD drain + setValveState( D53_VALV, VALVE_STATE_CLOSED ); + // close iofp drain valve + setValveState( M12_VALV, VALVE_STATE_CLOSED ); + // Go idle when request cleared if ( FALSE == getU32OverrideValue( &dryBiCartDrainRequested ) ) { @@ -790,8 +819,35 @@ bicarbChamberFillRequested.data = TRUE; } + /*********************************************************************//** * @brief + * The setBicartFillRequested function sets the bicart fill request + * flag value to be True. + * @details \b Inputs: none + * @details \b Outputs: dryBiCartFillRequested + * @return none. + *************************************************************************/ +void setBicartFillRequested( void ) +{ + dryBiCartFillRequested.data = TRUE; +} + +/*********************************************************************//** + * @brief + * The setBicartDrainRequested function sets the bicart drain request + * flag value to be True. + * @details \b Inputs: none + * @details \b Outputs: dryBiCartDrainRequested + * @return none. + *************************************************************************/ +void setBicartDrainRequested( void ) +{ + dryBiCartDrainRequested.data = TRUE; +} + +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter @@ -808,10 +864,12 @@ data.dryBiCartFillExecState = (U32)dryBiCartFillExecState; data.bicarbChamberFillExecState = (U32)bicarbChamberFillExecState; + data.dryBiCartDrainExecState = (U32)dryBiCartDrainExecState; data.dryBiCartFillCycleCounter = biCartFillCycleCounter; data.dryBiCartMaxFillCycleCount = getU32OverrideValue( &biCartMaxFillCycleCount ); data.dryBiCartFillRequest = getU32OverrideValue( &dryBiCartFillRequested ); data.bicarbChamberFillRequest = getU32OverrideValue( &bicarbChamberFillRequested ); + data.dryBiCartDrainRequested = getU32OverrideValue( &dryBiCartDrainRequested ); data.dryBiCartLastFillTime = lastFillDurationInMS; data.dryBiCartCurrentFillTime = currentFillDurationInMS; @@ -895,4 +953,20 @@ return result; } +/*********************************************************************//** + * @brief + * The testDryBiCartDrainRequestOverride function starts/stops the bicart + * drain request + * @details \b Inputs: tester logged in + * @details \b Outputs: bicarbChamberFillRequested + * @param message set message from Dialin which includes the bicart + * drain request start/stop. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testDryBiCartDrainRequestOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &dryBiCartDrainRequested, FALSE, TRUE ); + + return result; +} /**@}*/