Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r081b2525e3a650671d770513eb841057d88ea505 -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 081b2525e3a650671d770513eb841057d88ea505) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -15,6 +15,8 @@ * ***************************************************************************/ +#include // For sqrtf + #include "BalancingChamber.h" #include "Conductivity.h" #include "ConcentratePumps.h" @@ -28,7 +30,6 @@ #include "MixingControl.h" #include "ModeGenDialysate.h" #include "ModeStandby.h" -#include "OperationModes.h" #include "Pressure.h" #include "TaskGeneral.h" #include "TDInterface.h" @@ -45,11 +46,7 @@ #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. #define BAL_CHAMBER_FILL_PRES_DROP_MS ( 200 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber filling started and corrosponding valves opened. -#if 1 #define BAL_CHAMBER_FILL_COMPLETE_MS ( 100 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range -#else -#define BAL_CHAMBER_FILL_COMPLETE_MS ( 300 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range -#endif #define SPENT_FILL_COMPLETE_QD_LOW_RISE_MAX_MLPM 300.0F ///< For Qd <= 300 mL/min (Diener 1000). #define SPENT_FILL_COMPLETE_DP_RISE_PSIG 0.5F ///< Minimum 100 ms spent pressure rise (current minus n-2) to count as a rise hit at low Qd. #define SPENT_FILL_COMPLETE_DP_RISE_HIGH_QD_PSIG 3.0F ///< Minimum spent pressure rise for Diener 2000 or Qd > 300 mL/min. @@ -64,6 +61,10 @@ #define BAL_CHAMBER_FILL_TIMEOUT_FACTOR 3.0F ///< Balancing Chamber fill timeout factor (300% of observed fill count) #define COMP_SLOPE -0.000376F ///< Balancing chamber temperature compensation slope factor #define COMP_INTERCEPT 1.007269F ///< Balancing chamber temperature compensation intercept factor +/// Bicarb (D10) pump speed from instantaneous mix volume: speed = 240 - sqrt(230400 - 96000*v)/2 +#define BC_BICARB_SPEED_OFFSET_MLPM 240.0F ///< Bicarb speed formula offset (mL/min). +#define BC_BICARB_SPEED_DISC_CONST 230400.0F ///< Bicarb speed formula discriminant constant. +#define BC_BICARB_SPEED_DISC_VOL_COEF 96000.0F ///< Bicarb speed formula volume coefficient. /// Payload record structure for balancing chamber switch only request typedef struct @@ -114,7 +115,7 @@ static F32 balancingError; ///< Balancing error that has been calculated during balancing chamber switching. //TODO: remove later once level sensor working -static U32 bicarbChamberPeriodicFillCounter; +static U32 bicarbChamberPeriodicFillCounter; // Balancing chamber state change tracker static BAL_CHAMBER_EXEC_STATE_T prevBalChamberState; ///< Balancing chamber Previous State tracking variable @@ -139,6 +140,8 @@ static void valveControlForBCState2FreshSideClose( void ); static void closeFreshSideValvesWhenFillComplete( void ); static void calculateBalancingChamberError( void ); +static F32 getBicarbConcentratePumpSpeedMlMin( F32 bicarbVolumeMl ); +static void startBalChamberConcPumpDosing( F32 acidVolume, F32 bicarbVolume ); /*********************************************************************//** * @brief @@ -206,6 +209,62 @@ /*********************************************************************//** * @brief + * The getBicarbConcentratePumpSpeedMlMin function computes D10 pump speed + * from the instantaneous bicarb mix volume: + * speed = 240 - sqrt(230400 - 96000*v) / 2 + * Result is clamped to [0, CONCENTRATE_PUMP_MAX_SPEED]. + * @details \b Inputs: bicarbVolumeMl + * @param bicarbVolumeMl Instantaneous bicarb mix volume (mL) + * @return Bicarb concentrate pump speed (mL/min) + *************************************************************************/ +static F32 getBicarbConcentratePumpSpeedMlMin( F32 bicarbVolumeMl ) +{ + F32 discriminant = BC_BICARB_SPEED_DISC_CONST - ( BC_BICARB_SPEED_DISC_VOL_COEF * bicarbVolumeMl ); + F32 result = 0.0F; + + if ( discriminant < 0.0F ) + { + discriminant = 0.0F; + } + + result = BC_BICARB_SPEED_OFFSET_MLPM - ( sqrtf( discriminant ) / 2.0F ); + + if ( result > CONCENTRATE_PUMP_MAX_SPEED ) + { + result = CONCENTRATE_PUMP_MAX_SPEED; + } + else if ( result < 0.0F ) + { + result = 0.0F; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The startBalChamberConcPumpDosing function starts acid and bicarb dosing. + * Acid (D11) runs at fixed 100 mL/min. Bicarb (D10) speed is computed from + * the instantaneous bicarb mix volume on every BC dose start. + * @details \b Inputs: acidVolume, bicarbVolume + * @details \b Outputs: concentrate pumps + * @param acidVolume Acid dose volume (mL) + * @param bicarbVolume Bicarb dose volume (mL) + * @return none + *************************************************************************/ +static void startBalChamberConcPumpDosing( F32 acidVolume, F32 bicarbVolume ) +{ + F32 acidSpeed = DOSING_ACID_CONCENTRATE_PUMP_SPEED; + F32 bicarbSpeed = getBicarbConcentratePumpSpeedMlMin( bicarbVolume ); + + setConcentratePumpTargetSpeed( D11_PUMP, acidSpeed, acidVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, bicarbSpeed, bicarbVolume ); + requestConcentratePumpOn( D11_PUMP ); + requestConcentratePumpOn( D10_PUMP ); +} + +/*********************************************************************//** + * @brief * The transitionToBalChamberFill function prepares for transition to * balancing chamber fill/switching operations. * @details \b Inputs: none @@ -767,11 +826,7 @@ // Deliver dosing during generate dialysate mode if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - // start acid and bicarb pump with the expected quantity - setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidVolume ); - setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbVolume ); - requestConcentratePumpOn( D11_PUMP ); - requestConcentratePumpOn( D10_PUMP ); + startBalChamberConcPumpDosing( acidVolume, bicarbVolume ); } state = BAL_CHAMBER_STATE1_BICARB_ACID_DOSING_CNTRL; @@ -1099,11 +1154,7 @@ // Deliver dosing during generate dialysate mode if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - // start acid and bicarb pump with the expected quantity - setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidVolume ); - setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbVolume ); - requestConcentratePumpOn( D11_PUMP ); - requestConcentratePumpOn( D10_PUMP ); + startBalChamberConcPumpDosing( acidVolume, bicarbVolume ); } state = BAL_CHAMBER_STATE2_BICARB_ACID_DOSING_CNTRL; Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -r4237cbced773b985ff69a8c2af8287dbd5457f24 -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 4237cbced773b985ff69a8c2af8287dbd5457f24) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -75,6 +75,8 @@ F32 getBalancingChamberError( void ); // Get balancing chamber error to adjust UF rate. F32 getBicarbDoseVol( void ); // Get liquid bicarb dose volume F32 getAcidDoseVol( void ); // Get acid dose volume +BOOL isBalChamberSwitchImminent( void ); +BOOL getBalChamberFreshSideValvesClosedStatus( void ); BOOL testDDBalChamberDataPublishIntervalOverride( MESSAGE_T *message ); // To override the balancing chamber data publish interval BOOL testBalChamberSwFreqOverride( MESSAGE_T *message ); // To override the balancing chamber switching frequency Index: firmware/App/Controllers/ConcentratePumps.h =================================================================== diff -u -rfd897db8177752330ad08d877e0a13620513dbdc -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision fd897db8177752330ad08d877e0a13620513dbdc) +++ firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -32,11 +32,12 @@ // ********** public definitions ********** // For 150 RPM, Diener pump delivers 60ml/min #define CONCENTRATE_PUMP_MAX_SPEED 200.0F ///< Maximum Diener pump speed for concentrate pump in mL/min -#define DOSING_CONCENTRATE_PUMP_SPEED 100.0F ///< Diener pump speed for acid and bicarb dosing pump speed in mL/min +#define DOSING_ACID_CONCENTRATE_PUMP_SPEED 100.0F ///< Diener pump speed for acid pump +#define DOSING_CONCENTRATE_PUMP_SPEED 100.F ///< Dosing pump speed for spent chamber fill for acid and bicarb pumps #define DRAIN_BICART_PUMP_SPEED 200.0F ///< Diener pump speed for cartridge drains at maximum speed in mL/min #define DEFAULT_ACID_VOLUME_ML 0.666666667F ///< Acid concentrate volume in ml. -#define DEFAULT_BICARB_VOLUME_ML 1.146666667F ///< Bicarb concentrate volume in ml. +#define DEFAULT_BICARB_VOLUME_ML 0.95F ///< Bicarb concentrate volume in ml. #define DOSING_CONT_VOLUME 0xFFFFFFFF ///< Volume set to 0xFFFFFFFF enables continuous delivery based on the speed set. Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r081b2525e3a650671d770513eb841057d88ea505 -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 081b2525e3a650671d770513eb841057d88ea505) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -46,7 +46,8 @@ #define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the drybicart data published. #define WCDI2_PRESSURE_OFFSET_PSI 7.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID1 #define WCID1_PRESSURE_OFFSET_PSI 1.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID2 -#define DRY_BICART_PERSISTENCE_DURATION_MS 200 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. +#define DRY_BICART_PERSISTENCE_DURATION_MS 500 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. +//#define DRY_BICART_FILL_PERSISTENCE_DURATION_MS ( 1 * MS_PER_SECOND ) ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. // Dry Bicart Fill @@ -56,7 +57,8 @@ #define GET_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) ///< Get fill complete pressure based on the WCID configuration #define DRY_BICART_FILL_INITIATE_PRESSURE_PSI 1.5F ///< Minimum pressure required to initiate the dry bicart fill process. -#define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state +//#define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state +#define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 17.0F ///< Maximum pressure allowed at bicart fill during supply process/state #define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 4.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state #define DRY_BICART_MAX_FILL_CYCLE_CNT 10 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. #define DRY_BICART_MINIMUM_FILL_CYCLE_CNT 3 ///< Minimum fill cycle count for filling dry bicart @@ -67,14 +69,15 @@ // Bicarb chamber fill/Supply #ifdef CONDUCTIVE_LEVEL_SENSOR_ENABLED -#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill using level sensor +#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 60 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill using level sensor #else #define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 3 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill time based fill #endif #define DRY_BICART_SUPPLY_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bicart gas before actuating Bicarb chamber(F) venting. #define DRY_BICART_SUPPLY_VENT_MAX_TIME_MS ( 1 * MS_PER_SECOND ) ///< Max time to vent both dry bicart and Chamber F. #define DRY_BICART_SUPPLY_COMPLETE_TIME_MS ( 2 * MS_PER_SECOND ) ///< Wait time to close the D80 valve after D65 is closed #define DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI 4.0F ///< Minimum decay pressure needed to end the supply process. +#define DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ( 15 * SEC_PER_MIN * MS_PER_SECOND ) ///< Vent cycle time to initiate D85 opening. // Dry Bicart Drain #define LARGE_DRY_BICART_MAX_DRAIN_TIME_MS ( 8 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for large dry bicart in ms. @@ -141,6 +144,8 @@ static U32 dryBiCartPersistenceStartTime; ///< Dry bicart Persistence time. static U32 drybicartPersistenceOnLowercartPressureStartTime; ///< Dry bicart Persistence on lower cart pressure start time. static BOOL dryBiCartPressureDecayStartTimeFlag; ///< Dry bicart d66 pressure decay start timer. +static BOOL dryBiCartVentCycleWaitTimeStartedFlag; ///< Flag indicating venting cycle timer started for opening D85. +static U32 dryBiCartVentCycleStartTime; ///< Dry bicart Vent cycle start time. static DRY_BICART_OPERATION_T dryBicartStartRequest; ///< Dry bicart operation, fill or supply or drain request static DRY_BICART_OPERATION_T prevDryBicartState; ///< Dry BiCart State Change Tracker @@ -239,7 +244,9 @@ dryBiCartLowerCartPressure.override = OVERRIDE_RESET; dryBiCartPressureDecayStartTimeFlag = FALSE; + dryBiCartVentCycleWaitTimeStartedFlag = FALSE; dryBiCartFillVentTimeOut = FALSE; + dryBiCartVentCycleStartTime = 0; dryBiCartFillStartTime = 0; lastFillDurationInMS = 0; currentFillDurationInMS = 0; @@ -586,6 +593,8 @@ if ( TRUE == isBalChamberSwitchImminent() ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); + // Open D80 only in supply state + setValveState( D80_VALV, VALVE_STATE_OPEN ); } } @@ -1097,7 +1106,14 @@ if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) { - state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; + //state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; + state = BICARB_CHAMBER_SUPPLY_STATE; + + if ( FALSE == dryBiCartVentCycleWaitTimeStartedFlag ) + { + dryBiCartVentCycleWaitTimeStartedFlag = TRUE; + dryBiCartVentCycleStartTime = getMSTimerCount(); + } } return state; @@ -1113,13 +1129,12 @@ { BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; -#ifdef __D65_OPENING_DISABLED__ if ( TRUE == isDryBicartBalChamberFillWindowOpen() ) -#endif { // Close vent valves and descaling valve setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D81_VALV, VALVE_STATE_CLOSED ); + //setValveState( D83_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); // open inlet water to bicart only when fresh-side BC valves are closed @@ -1147,8 +1162,8 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; + LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); -#ifdef __D65_OPENING_DISABLED__ if ( FALSE == isDryBicartBalChamberFillWindowOpen() ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); @@ -1157,7 +1172,7 @@ { setValveState( D65_VALV, VALVE_STATE_OPEN ); } -#endif + // check D66 pressure greater than or equal to 17 PSI if ( d66Pressure >= fillCompletePressure ) { @@ -1167,21 +1182,31 @@ dryBiCartPersistenceStartTime = getMSTimerCount(); } - // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + //TODO: revert after testing + // 2s persistence on D66 pressure since pressure overshoot just after D65 opening only for chamber fill if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { // Close water inlet valve as D66 pressure reaches 11 PSI after persistence setValveState( D65_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; - state = BICARB_CHAMBER_SUPPLY_STATE; + //state = BICARB_CHAMBER_SUPPLY_STATE; + state = BICARB_SUPPLY_VENT_END_STATE; + } } else { dryBiCartPersistenceStartTime = 0; } + //Additional code + if ( LVL_STATE_LOW == bicarbChamberLevel ) + { + //Force transition to end state to allow next supply + state = BICARB_SUPPLY_VENT_END_STATE; + } + return state; } @@ -1197,7 +1222,9 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_PRESSURE_CHECK_STATE; // TODO: set supply in progress to inform BC control to disable alarm - setValveState( D64_VALV, VALVE_STATE_CLOSED ); + //setValveState( D64_VALV, VALVE_STATE_CLOSED ); + setValveState( D64_VALV, VALVE_STATE_OPEN ); + // Open the Bicarb chamber inlet valve setValveState( D80_VALV, VALVE_STATE_OPEN ); @@ -1224,37 +1251,47 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_PRESSURE_CHECK_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); -#ifdef __D65_OPENING_DISABLED__ + // Close D65 irrespective of pressure for balancing chamber fresh side fill to complete. closeD65IfBalChamberSwitchImminent(); -#endif // Once upper level reached high , close the valve, timeout is for safety in case level sensor didn't work(10 sec), or else its a time based filling (3 sec) 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 ) + if ( TRUE == didTimeout( dryBiCartVentCycleStartTime, DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ) ) { - 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 <= DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI ) + // start the timer for d66 pressure decay + if ( FALSE == dryBiCartPressureDecayStartTimeFlag ) { - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_OPEN ); - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCarbSypplyVentStartTime = 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 <= DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI ) + { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D64_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_OPEN ); - state = BICARB_SUPPLY_VENT_START_STATE; + dryBiCarbSupplyStartTime = getMSTimerCount(); + dryBiCarbSypplyVentStartTime = getMSTimerCount(); + + state = BICARB_SUPPLY_VENT_START_STATE; + } } } + else + { + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + dryBiCarbSupplyStartTime = getMSTimerCount(); + + state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; + + } } else if ( d66Pressure <= getDryBicartLowerCartPressure() ) { @@ -1264,15 +1301,12 @@ drybicartPersistenceOnLowercartPressureStartTime = getMSTimerCount(); } -#ifdef __D65_OPENING_DISABLED__ // 200 ms persistence on D66 pressure if ( ( TRUE == didTimeout( drybicartPersistenceOnLowercartPressureStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) && ( TRUE == isDryBicartBalChamberFillWindowOpen() ) ) -#else - if ( TRUE == didTimeout( drybicartPersistenceOnLowercartPressureStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) -#endif { setValveState( D65_VALV, VALVE_STATE_OPEN ); + setValveState( D80_VALV, VALVE_STATE_CLOSED ); drybicartPersistenceOnLowercartPressureStartTime = 0; } } @@ -1289,6 +1323,7 @@ if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); + setValveState( D80_VALV, VALVE_STATE_OPEN ); dryBiCartPersistenceStartTime = 0; } } @@ -1332,7 +1367,7 @@ { setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; - + dryBiCartVentCycleWaitTimeStartedFlag = FALSE; state = BICARB_SUPPLY_VENT_END_STATE; } } @@ -1341,6 +1376,7 @@ setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; dryBiCartFillVentTimeOut = TRUE; + dryBiCartVentCycleWaitTimeStartedFlag = FALSE; state = BICARB_SUPPLY_VENT_END_STATE; } Index: firmware/App/Controllers/MixingControl.c =================================================================== diff -u -r43ebe58702128e865210533f9e6deaf13f99d262 -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision 43ebe58702128e865210533f9e6deaf13f99d262) +++ firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -46,8 +46,8 @@ #define MIXING_CONTROL_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the mixing control data published. // drybicarb mixing -#define BICARB_VOL_CONTROL_P_COEFFICIENT ( 0.00008484F * 2 ) ///< Bicarb proportional gain (kp) -#define BICARB_VOL_CONTROL_I_COEFFICIENT ( 0.00033936F / 4 ) ///< Bicarb integral gain. (ki) +#define BICARB_VOL_CONTROL_P_COEFFICIENT ( 0.00008484F ) ///< Bicarb proportional gain (kp) +#define BICARB_VOL_CONTROL_I_COEFFICIENT ( 0.00033936F / 8 ) ///< Bicarb integral gain. (ki) #define MIN_BICARB_VOLUME_ML 0.4F ///< Minimum bicarb volume in mL #define MAX_BICARB_VOLUME_ML 1.8F ///< Maximum bicarb volume in mL @@ -72,8 +72,8 @@ #define BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER ( 3 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bicarb mix is controlled. #define ACID_MIX_CONTROL_INTERVAL_MULTIPLIER ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate mix is controlled. -#define BICARB_DEADBAND_CONTROL 15.0F ///< Bicarb dead band control -#define ACID_DEADBAND_CONTROL 50.0F ///< Acid dead band control +#define BICARB_DEADBAND_CONTROL 30.0F ///< Bicarb dead band control +#define ACID_DEADBAND_CONTROL 70.0F ///< Acid dead band control // Proportioning Ratios: 1 Part Acid : 1.72 Parts Bicarb : 42.28 Parts Water // Total parts = 1 + 1.72 + 42.28 = 45.0 Index: firmware/App/DDCommon.h =================================================================== diff -u -r081b2525e3a650671d770513eb841057d88ea505 -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 081b2525e3a650671d770513eb841057d88ea505) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -66,10 +66,7 @@ //Uncomment below to disable the conductivity sensor alarms #define __CONDUCTIVITY_SENSOR_ALARMS_DISABLED__ 1 -//Uncommnet below to enable the D65 valves opening during balancincg chamber fill -//#define __D65_OPENING_DISABLED__ 1 - #include #include #endif Index: firmware/App/Modes/ModeGenDialysate.h =================================================================== diff -u -ra6737c3bcc8286c153b778c2c395f465e76aaafb -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 --- firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision a6737c3bcc8286c153b778c2c395f465e76aaafb) +++ firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) @@ -32,7 +32,7 @@ // ********** public definitions ********** #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. -#define FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0 1250 ///< Nominal RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. +#define FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0 1600 ///< Nominal RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. #define SPENT_DIAL_PUMP_INITIAL_RPM 2300 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. #define DIAL_PUMP_DRAIN_RPM 1000 ///< Nominal RPM target for dialysate pump to drain the dry bicart. #define SPENT_DIAL_PUMP_FILL_RPM 200 ///< Nominal RPM target for spent chamber fill operations.