Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r8471d9c87bc554586ecc1e7e12d6ee35b7876230 -r34e1ca4e998f57d2e962709cd272a296dc4d8c50 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 8471d9c87bc554586ecc1e7e12d6ee35b7876230) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 34e1ca4e998f57d2e962709cd272a296dc4d8c50) @@ -207,7 +207,7 @@ { // Increment counter indicating fill is in progress. currentBalChamberSwitchingCounter += 1; - currentBalChamberFillCounter+=1; + currentBalChamberFillCounter += 1; // execute current balancing chamber exec state switch ( balChamberExecState ) @@ -802,7 +802,7 @@ * @details \b Inputs: Pressure * @details \b Outputs: valve states * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_START_PRESSURE_OUT_OF_RANGE - * when pressure is not in range during balacing chamber fill start. + * when pressure is not in range during balancing chamber fill start. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillStart( void ) @@ -860,7 +860,7 @@ /*********************************************************************//** * @brief * The handleBalChamberConcentrateControl function handles the Acid and Bicarb - * concentrate doisng and checks the conductivity of the dialysate for the treatment. + * concentrate dosing and checks the conductivity of the dialysate for the treatment. * @details \b Inputs: balChamberSWState , Concentrate volume * @details \b Outputs: isPressureDroppedDuringFill, state * @return next balancing chamber state. @@ -951,7 +951,7 @@ // close the state 1 opened valves valveControlForBCState1FillEnd(); isBalChamberFillInProgress = FALSE; - setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeed(), TRUE ); + setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); // Transition to next state state = BAL_CHAMBER_STATE1_FILL_END; @@ -963,21 +963,21 @@ /*********************************************************************//** * @brief * The handleBalChamberState1FillEnd function check for the balancing chamber - * switching period and tranistion to next state switching. + * switching period and transition to next state switching. * @details \b Inputs: currentBalChamberSwitchingCounter, balChamberSwitchingPeriod * @details \b Outputs: balChamberFillPressureDropCounter,balChamberFillCompleteStablePressureCounter * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE - * when pressure drop is not in range during balacing chamber fill in progress. + * when pressure drop is not in range during balancing chamber fill in progress. * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE - * when pressure is not in range during balacing chamber fill complete. + * when pressure is not in range during balancing chamber fill complete. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd( void ) { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_END; // On completion of cycle time, transition to next state - if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) + //if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { balChamberFillPressureDropCounter = 0; balChamberFillCompleteStablePressureCounter = 0; @@ -1024,7 +1024,7 @@ * @details \b Inputs: fresh and spent dialysate pressure * @details \b Outputs: valve states * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_START_PRESSURE_OUT_OF_RANGE - * when pressure is not in range during balacing chamber state 2 fill start. + * when pressure is not in range during balancing chamber state 2 fill start. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillStart( void ) @@ -1120,7 +1120,7 @@ // close the valves valveControlForBCState2FillEnd(); isBalChamberFillInProgress = FALSE; - setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeed(), TRUE ); + setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); //Transition to next state state = BAL_CHAMBER_STATE2_FILL_END; @@ -1146,7 +1146,7 @@ BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_END; // On completion of cycle time, transition to next state - if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) + //if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { balChamberFillPressureDropCounter = 0; balChamberFillCompleteStablePressureCounter = 0; @@ -1209,20 +1209,20 @@ F32 diffInSpentPressure = 0.0F; U32 absDiffSpentFillCount = 0; U32 adjustedSpeed = 0; - U32 spentDialPumpSpeed = getD48PumpSpeed(); + U32 spentDialPumpSpeed = getD48PumpSpeedForBCFill(); // Collect the next sample of spent pressure lastPrevSpentDialPressure = prevSpentDialPressure; prevSpentDialPressure = spentDialPressure; // find the pressure difference for pressure spike detection diffInSpentPressure = fabs(spentDialPressure - lastPrevSpentDialPressure); - if ( diffInSpentPressure >= SPENT_FILL_COMPLETE_DIFF_PRES ) + if ( ( diffInSpentPressure >= SPENT_FILL_COMPLETE_DIFF_PRES ) && ( isSpentFillComplete != TRUE ) ) { // Check spent fill time against the balancing chamber closing period diffSpentFillCompleteCount = balChamberValveClosePeriod - currentBalChamberFillCounter; absDiffSpentFillCount = abs(diffSpentFillCompleteCount); - adjustedSpeed = ( ( absDiffSpentFillCount / balChamberValveClosePeriod ) * getD48PumpSpeed() ) * D48_SPEED_ADJUST_FACTOR; + adjustedSpeed = ( ( absDiffSpentFillCount / balChamberValveClosePeriod ) * getD48PumpSpeedForBCFill() ) * D48_SPEED_ADJUST_FACTOR; //Not adjust the D48 pump speed if the fill counter is just 50ms difference from the closing period. if ( absDiffSpentFillCount > SPENT_DIFF_COUNT_DEADBAND ) @@ -1239,7 +1239,7 @@ } // Update the D48 pump speed - setD48PumpSpeed( spentDialPumpSpeed ); + setD48PumpSpeedForBCFill( spentDialPumpSpeed ); } //Update spent fill is complete @@ -1377,7 +1377,7 @@ data.isBalChamberFillInProgress = isBalChamberFillInProgress; data.currentBalChamberSwitchingCounter = currentBalChamberSwitchingCounter; #else - data.balChamberSwPeriod = getD48PumpSpeed(); + data.balChamberSwPeriod = getD48PumpSpeedForBCFill(); data.isBalChamberFillInProgress = isSpentFillComplete; data.currentBalChamberSwitchingCounter = currentBalChamberFillCounter; #endif