Index: firmware/App/Modes/BalancingChamber.c =================================================================== diff -u -r742dfbbe3f91706a00b37c04ca97a5015e09bae3 -rba5c71eab6b1930bfb044a165d803f5c16c3379a --- firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision 742dfbbe3f91706a00b37c04ca97a5015e09bae3) +++ firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision ba5c71eab6b1930bfb044a165d803f5c16c3379a) @@ -39,6 +39,8 @@ #define SPENT_DIAL_PRESSURE_MIN_PSIG 29.0F ///< Minimum spent dialysate pressure (PDs) limit for balancing chamber fill operations. #define SPENT_DIAL_PRESSURE_MAX_PSIG 30.0F ///< Maximum spent dialysate pressure (PDs) limit for balancing chamber fill operations. #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. +#define TEST_ACID_VOLUME_ML 0.63F ///< Acid concentrate volume in ml. +#define TEST_BICARB_VOLUME_ML 1.07F ///< Bicarb concentrate volume in ml. // ********** private data ********** @@ -132,11 +134,8 @@ *************************************************************************/ U32 execBalancingChamberControl( void ) { - // Increment counter during fill time only, Also check dialysate needs to be bypassed. - if ( TRUE == isBalChamberFillInProgress ) - { - currentBalChamberSwitchingCounter += 1; - } + // Increment counter indicating fill is in progress. + currentBalChamberSwitchingCounter += 1; // execute current balancing chamber exec state switch ( balChamberExecState ) @@ -333,9 +332,6 @@ //Valve control for state 1 fill valveControlForBCState1FillStart(); - //Increment counter - currentBalChamberSwitchingCounter++; - // Update fill status flag to true isBalChamberFillInProgress = TRUE; @@ -361,9 +357,14 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) { BAL_CHAMBER_EXEC_STATE_T state; - // TODO : start acid and bicarb pump with the expected quantity - // On completion of dosing, transition to next state based on the current switching state + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP1_ACID, CONCENTRATE_PUMP_MAX_SPEED, TEST_ACID_VOLUME_ML ); + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, CONCENTRATE_PUMP_MAX_SPEED, TEST_BICARB_VOLUME_ML ); + requestConcentratePumpOn( CONCENTRATEPUMPS_CP1_ACID ); + requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); + + // On triggering of dosing, transition to next state based on the current switching state if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { state = BAL_CHAMBER_STATE1_FILL_END; @@ -405,6 +406,10 @@ { // close the state 1 opened valves valveControlForBCState1FillEnd(); + + //Stop the concentrate pumps + requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID, NO_PARK_CONC_PUMPS ); + requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB, NO_PARK_CONC_PUMPS ); } // On completion of cycle time, transition to next state @@ -451,9 +456,6 @@ // Valve control for state 2 fill valveControlForBCState2FillStart(); - //Increment counter - currentBalChamberSwitchingCounter++; - // Update fill status flag to true isBalChamberFillInProgress = TRUE; @@ -496,6 +498,10 @@ { // close the valves valveControlForBCState2FillEnd(); + + //Stop the concentrate pumps + requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID, NO_PARK_CONC_PUMPS ); + requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB, NO_PARK_CONC_PUMPS ); } // On completion of cycle time, transition to next state Index: firmware/App/Monitors/Level.c =================================================================== diff -u -r3ea4def3a3a69a00fb96b6089dbd097fa80041de -rba5c71eab6b1930bfb044a165d803f5c16c3379a --- firmware/App/Monitors/Level.c (.../Level.c) (revision 3ea4def3a3a69a00fb96b6089dbd097fa80041de) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision ba5c71eab6b1930bfb044a165d803f5c16c3379a) @@ -31,6 +31,10 @@ #define FPGA_LEVEL_LOW 2 ///< Floater low level status #define FPGA_LEVEL_MEDIUM 3 ///< Floater medium level status #define FPGA_LEVEL_HIGH 1 ///< Floater high level status +#define LEVEL_COUNT_LOW 0x637F ///< Level sensor count when fluid level is low or non submerged +#define LEVEL_COUNT_HIGH ( LEVEL_COUNT_LOW / 2 ) ///< Level sensor count when fluid level is high or submerged +#define LOW_LEVEL_COUNT_TOLERANCE ( ( LEVEL_COUNT_LOW / 100 ) * 1 ) ///< Level sensor count 1% tolerance for low level +#define HIGH_LEVEL_COUNT_TOLERANCE ( ( LEVEL_COUNT_HIGH / 100 ) * 1 ) ///< Level sensor count 1% tolerance for high level #define LEVEL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the level data is published on the CAN bus. #define LEVEL_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 10 ) ///< Level debounce time in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 7 ///< Data publish counter start count. @@ -54,6 +58,7 @@ // ********** private function prototypes ********** static void publishLevelsData( void ); +static BOOL processLevelCount( U16 count ); /*********************************************************************//** * @brief @@ -122,11 +127,11 @@ break; case BICARB_LEVEL: - currentLevelStatus = ( getFPGALevelSensor1() != 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); + currentLevelStatus = ( processLevelCount( getFPGALevelSensor1() ) == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); break; case SPENT_DIALYSATE_LEVEL: - currentLevelStatus = ( getFPGALevelSensor2() != 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); + currentLevelStatus = ( processLevelCount( getFPGALevelSensor2() ) == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); break; #ifndef _VECTORCAST_ @@ -217,6 +222,38 @@ /*********************************************************************//** * @brief + * The processLevelCount function checks the range of count reported by FPGA + * and determine level based on the count. + * @details \b Inputs: none + * @details \b Outputs: level + * @param count The level count reported by FPGA + * @return level status + *************************************************************************/ +static BOOL processLevelCount( U16 count ) +{ + BOOL level = FALSE; + + // Check the level count with in the low/high level range + if ( ( count < LEVEL_COUNT_LOW + LOW_LEVEL_COUNT_TOLERANCE ) && + ( count > LEVEL_COUNT_LOW - LOW_LEVEL_COUNT_TOLERANCE ) ) + { + level = FALSE; + } + else if ( ( count < LEVEL_COUNT_HIGH + HIGH_LEVEL_COUNT_TOLERANCE ) && + ( count > LEVEL_COUNT_HIGH - HIGH_LEVEL_COUNT_TOLERANCE ) ) + { + level = TRUE; + } + else + { + level = FALSE; + } + + return level; +} + +/*********************************************************************//** + * @brief * The publishLevelsData function broadcasts the level data at the * publication interval. * @details \b Inputs: levelsDataPublicationCounter