Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r26371f0d57553f6786ad6f47ac5587b43e805180 -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 26371f0d57553f6786ad6f47ac5587b43e805180) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -21,8 +21,8 @@ #include "DialysatePumps.h" #include "FpgaDD.h" #include "Heaters.h" -#include "ModeStandby.h" #include "ModeGenDialysate.h" +#include "ModeStandby.h" #include "Messaging.h" #include "OperationModes.h" #include "Pressure.h" @@ -68,7 +68,7 @@ static U32 balChamberValveClosePeriod; ///< Close balancing chamber valves with the defined time prior switching state. static U32 currentBalChamberSwitchingCounter; ///< Counter (in task interval) to monitor the timing spent during balancing chamber fill/drain operation. static BOOL isBalChamberFillInProgress; ///< Flag indicating balancing chamber fill/drain is in progress. -static BOOL isPressureStalbilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. +static BOOL isPressureStabilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. static BAL_CHAMBER_SW_STATE_T balChamberSWState; ///< Current balancing chamber switching state ( state 1 or state 2). static U32 balChamberDataPublicationTimerCounter; ///< Used to schedule balancing chamber data publication to CAN bus. static U32 balChamberFillPressureDropCounter; ///< Counter to check balancing chamber valves opened and there by pressure drop is seen. @@ -133,7 +133,7 @@ balChamberValveClosePeriod = 0; isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; lastTdDialysateFlowrate = 0.0F; balChamberDataPublicationTimerCounter = 0; balChamberFillPressureDropCounter = 0; @@ -432,7 +432,7 @@ balChamberSWState = BAL_CHAMBER_SW_STATE1; currentBalChamberFillCounter = 0; isBalChamberFillInProgress = FALSE; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; isSpentFillComplete = FALSE; lastPrevSpentDialPressure = 0.0F; @@ -443,7 +443,7 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - // Check fresh and spent dialysate pressure in range or BC switch only flag set + // Check fresh dialysate pressure in range or BC switch only flag set or BC pressure alarms are disabled if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) || ( TRUE == getBalChamberSwitchingOnlyStatus() ) || ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) { @@ -551,15 +551,15 @@ if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) { // stabilized pressure indicating fresh side fill is complete - isPressureStalbilizedDuringFill = TRUE; + isPressureStabilizedDuringFill = TRUE; } } // Spent side of balancing chamber fill is complete or not checkSpentFillComplete( spentDialPressure ); // Check both spent and fresh side fill is complete - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStalbilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { // close the state 1 opened valves valveControlForBCState1FillEnd(); @@ -605,7 +605,7 @@ // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); } - else if ( TRUE != isPressureStalbilizedDuringFill ) + else if ( TRUE != isPressureStabilizedDuringFill ) { // Alarm when switching time expired, but still pressure not in range which indicates fill is not yet completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); @@ -645,7 +645,7 @@ BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_START; currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; currentBalChamberFillCounter = 0; @@ -660,7 +660,6 @@ // Check fresh dialysate pressure in range if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) || - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || ( TRUE == getBalChamberSwitchingOnlyStatus() ) || ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) { // Valve control for state 2 fill @@ -708,24 +707,21 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - BOOL isFreshDialysatePressureInRange = ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ); - BOOL isSpentDialysatePressureInRange = ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ); - - // Check fresh and spent dialysate pressure back in range to indicate fill complete. + // Check fresh dialysate pressure back in range to indicate fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) { // stabilized pressure indicating fresh side fill is complete - isPressureStalbilizedDuringFill = TRUE; + isPressureStabilizedDuringFill = TRUE; } } // Spent side of balancing chamber fill is complete or not checkSpentFillComplete( spentDialPressure ); // Check switching cycle time or pressure check for valve closure - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStalbilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { // close the valves valveControlForBCState2FillEnd(); @@ -772,7 +768,7 @@ // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); } - else if ( TRUE != isPressureStalbilizedDuringFill ) + else if ( TRUE != isPressureStabilizedDuringFill ) { // Alarm when switching time expired, but still pressure not in range which indicates fill is not completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); @@ -810,6 +806,7 @@ * fill timing close to the switching period time. * @details \b Inputs: balChamberExecState * @details \b Outputs: none + * @param spentDialPressure to check the switching time for BC and set D48 speed based on it. * @return the current state of balancing chamber states. *************************************************************************/ static void checkSpentFillComplete( F32 spentDialPressure ) @@ -823,11 +820,16 @@ U32 maxD48Speed = initialD48PumpSpeed + ( initialD48PumpSpeed * D48_SPEED_RANGE_LIMIT ); U32 d48SpeedPostRangeCheck = 0; F32 qdMlpm = getTDDialysateFlowrate(); + BOOL result = FALSE; F32 spentFillCompletePresPsig; - // Diener 1000 pump: spent fill complete pressure depends on Qd (7/15/20 PSI). Other pump: use legacy 25 PSI. - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP ) ) + // Diener 2000 pump: spent fill complete pressure use legacy 25 PSI. Other pump: depends on Qd. + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) { + spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES; + } + else + { if ( qdMlpm <= QD_THRESHOLD_LOW_MLPM ) { spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_LOW_PSIG; @@ -841,10 +843,6 @@ spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_HIGH_PSIG; } } - else - { - spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES; - } // Collect the next sample of spent pressure lastPrevSpentDialPressure = prevSpentDialPressure; @@ -859,9 +857,9 @@ absDiffSpentFillCount = abs(diffSpentFillCompleteCount); adjustedSpeed = ( ( (F32)absDiffSpentFillCount / (F32)balChamberValveClosePeriod ) * spentDialPumpSpeed ) * D48_SPEED_ADJUST_FACTOR; - //Not adjust the D48 pump speed if the fill counter is just 50ms difference from the closing period. - if ( 0 == ( ( diffSpentFillCompleteCount <= 0 ) && ( diffSpentFillCompleteCount >= -2 ) ) ) - //if ( absDiffSpentFillCount > SPENT_DIFF_COUNT_DEADBAND ) + result = ( ( diffSpentFillCompleteCount <= 0 ) && ( diffSpentFillCompleteCount >= -2 ) ) ? TRUE : FALSE; + //Not adjust the D48 pump speed if the fill counter is just 50ms difference from the closing period(considering only positive DEADBAND as negative deadband might indicate under fill of BC). + if ( 0 == result ) { if ( diffSpentFillCompleteCount < SPENT_DIFF_COUNT_ZERO ) { @@ -937,6 +935,7 @@ * switching only On/Off status. * @details \b Inputs: balanceChamberSwitchingOnly * @details \b Outputs: none + * @param OnOff to set the BC switch status * @return none *************************************************************************/ void setBalChamberSwitchingOnlyStatus( BOOL OnOff ) @@ -1013,7 +1012,7 @@ data.balChamberSwPeriod = getD48PumpSpeedForBCFill(); data.isBalChamberFillInProgress = isSpentFillComplete; data.currentBalChamberSwitchingCounter = currentBalChamberFillCounter; - data.isPressureStabilizedDuringFill = isPressureStalbilizedDuringFill; + data.isPressureStabilizedDuringFill = isPressureStabilizedDuringFill; data.balChamberSWOnlyState = balanceChamberSwitchingOnly; broadcastData( MSG_ID_DD_BAL_CHAMBER_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( BAL_CHAMBER_DATA_T ) ); Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -rac5e52d907ff6adad795d8f81ca8206c5cd33c77 -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision ac5e52d907ff6adad795d8f81ca8206c5cd33c77) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -74,7 +74,6 @@ #define D12_PUMP_I_COEFFICIENT 60.0F ///< I term for fresh dialysate pump delta pressure control. #define D48_PUMP_P_COEFFICIENT 20.0F ///< P term for spent dialysate pump delta pressure control. #define D48_PUMP_I_COEFFICIENT 60.0F ///< I term for spent dialysate pump delta pressure control. -#define D48_PUMP_CLOSED_LOOP_DEADBAND_RPM 50.0F ///< Deadband on PI output so pump speed does not fluctuate frequently. #define DIAL_PUMP_NO_FEED_FORWARD 0.0F ///< Feedforward term for dialysate pump control #define DEGAS_PUMP_SLOPE_FACTOR -0.0156F ///< Dialysate pump target pressure multiply factor ( m factor in 'y = mx + b' equation) #define DEGAS_PUMP_INTERCEPT_FACTOR 0.1153F ///< Dialysate pump target pressure addition factor ( b factor in 'y = mx + b' equation) @@ -160,37 +159,53 @@ * @brief * The getD48MinPumpRPM function returns the minimum RPM limit for the D48 pump * based on test configuration (Diener 1000 vs Diener 2000). - * @details \b Inputs: Test configuration TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP. + * @details \b Inputs: Test configuration TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP. * @details \b Outputs: none - * @return Minimum RPM for D48 pump (134 when Diener 1000 enabled, 200 otherwise). + * @param pumpId to set the pump speed accordingly + * @return Minimum RPM for D48 pump (200 when Diener 2000 enabled, 134 otherwise). *************************************************************************/ -U32 getD48MinPumpRPM( void ) +U32 getDialysatePumpMinRPM( DIALYSATE_PUMPS_T pumpId ) { U32 minRpm = MIN_DIALYSATE_PUMP_RPM; - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP ) ) + if ( D48_PUMP == pumpId ) { + // Default to Diener 1000 min when that test config is active; + // otherwise use the common MIN_DIALYSATE_PUMP_RPM (Diener 2000 / beta systems). minRpm = D48_DIENER_1000_MIN_RPM; + + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) + { + minRpm = MIN_DIALYSATE_PUMP_RPM; + } } return minRpm; } /*********************************************************************//** * @brief - * The getD48MaxPumpRPM function returns the maximum RPM limit for the D48 pump - * based on test configuration (Diener 1000 vs Diener 2000). - * @details \b Inputs: Test configuration TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP. + * The getDialysatePumpMaxRPM function returns the maximum RPM limit for a + * given dialysate pump. + * @details \b Inputs: pumpId * @details \b Outputs: none - * @return Maximum RPM for D48 pump (2770 when Diener 1000 enabled, 2650 otherwise). +* @param pumpId to set the pump speed accordingly + * @return Maximum RPM for the specified pump *************************************************************************/ -U32 getD48MaxPumpRPM( void ) +U32 getDialysatePumpMaxRPM( DIALYSATE_PUMPS_T pumpId ) { U32 maxRpm = MAX_DIALYSATE_PUMP_RPM; - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP ) ) + if ( D48_PUMP == pumpId ) { + // Default to Diener 1000 max when that test config is active; + // otherwise use the common MAX_DIALYSATE_PUMP_RPM (Diener 2000 / beta systems). maxRpm = D48_DIENER_1000_MAX_RPM; + + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) + { + maxRpm = MAX_DIALYSATE_PUMP_RPM; + } } return maxRpm; @@ -234,14 +249,7 @@ dialysatePumpMeasuredCurrentA[ pumpId ].ovInitData = 0.0F; dialysatePumpMeasuredCurrentA[ pumpId ].ovData = 0.0F; dialysatePumpMeasuredCurrentA[ pumpId ].override = OVERRIDE_RESET; - if ( D48_PUMP == pumpId ) - { - dialysatePumps[ pumpId ].currentPumpSpeed = getD48MinPumpRPM(); - } - else - { - dialysatePumps[ pumpId ].currentPumpSpeed = MIN_DIALYSATE_PUMP_RPM; - } + dialysatePumps[ pumpId ].currentPumpSpeed = getDialysatePumpMinRPM( pumpId ); dialysatePumps[ pumpId ].prevPumpTargetSpeed = 0.0F; dialysatePumps[ pumpId ].control = DIALYSATE_PUMP_CONTROL_STOP; dialysatePumps[ pumpId ].directionErrorCount = 0; @@ -276,8 +284,8 @@ // Init the dialysate pump with valid PWM while motor is disabled. // when enable triggers, we dont want invlid RPM set that triggers alarm in motor controller. - setFPGAD12PumpSpeed( MIN_DIALYSATE_PUMP_RPM ); - setFPGAD48PumpSpeed( getD48MinPumpRPM() ); + setFPGAD12PumpSpeed( getDialysatePumpMinRPM( D12_PUMP ) ); + setFPGAD48PumpSpeed( getDialysatePumpMinRPM( D48_PUMP ) ); #ifdef __PITEST__ for ( i = 0; i < NUM_OF_CONTROLLER_SIGNAL; i++ ) @@ -339,16 +347,8 @@ U32 minRPM; U32 maxRPM; - if ( D48_PUMP == pumpId ) - { - minRPM = getD48MinPumpRPM(); - maxRPM = getD48MaxPumpRPM(); - } - else - { - minRPM = MIN_DIALYSATE_PUMP_RPM; - maxRPM = MAX_DIALYSATE_PUMP_RPM; - } + minRPM = getDialysatePumpMinRPM( pumpId ); + maxRPM = getDialysatePumpMaxRPM( pumpId ); if ( pumpId < NUM_OF_DIALYSATE_PUMPS ) { @@ -411,24 +411,17 @@ { dialysatePumps[ pumpId ].control = DIALYSATE_PUMP_CONTROL_STOP; setFPGAD12PumpControl( dialysatePumps[ pumpId ].control ); - setFPGAD12PumpSpeed( MIN_DIALYSATE_PUMP_RPM ); + setFPGAD12PumpSpeed( getDialysatePumpMinRPM( D12_PUMP ) ); } else { dialysatePumps[ pumpId ].control = DIALYSATE_PUMP_CONTROL_STOP; setFPGAD48PumpControl( dialysatePumps[ pumpId ].control ); - setFPGAD48PumpSpeed( getD48MinPumpRPM() ); + setFPGAD48PumpSpeed( getDialysatePumpMinRPM( D48_PUMP ) ); } // Reset all the variables to stop mode. - if ( D48_PUMP == pumpId ) - { - dialysatePumps[ pumpId ].currentPumpSpeed = getD48MinPumpRPM(); - } - else - { - dialysatePumps[ pumpId ].currentPumpSpeed = MIN_DIALYSATE_PUMP_RPM; - } + dialysatePumps[ pumpId ].currentPumpSpeed = getDialysatePumpMinRPM( pumpId ); pumpTargetSpeed[ pumpId ].data = 0.0F; dialysatePumps[ pumpId ].dialysatePumpState = DIALYSATE_PUMP_OFF_STATE; dialysatePumps[ pumpId ].controlTimerCounter = 0; @@ -728,17 +721,8 @@ { DIALYSATE_PUMP_STATE_T result = DIALYSATE_PUMP_OFF_STATE; F32 targetSpeed = getDialysatePumpTargetSpeed( pumpId ); - U32 minRPM; + U32 minRPM = getDialysatePumpMinRPM( pumpId ); - if ( D48_PUMP == pumpId ) - { - minRPM = getD48MinPumpRPM(); - } - else - { - minRPM = MIN_DIALYSATE_PUMP_RPM; - } - if ( targetSpeed >= minRPM ) { if ( D12_PUMP == pumpId ) @@ -807,7 +791,7 @@ F32 speedIncrease = 0.0F; BOOL hasTgtBeenReached = FALSE; F32 currentToTargetDiff = fabs( getDialysatePumpTargetSpeed( pumpId ) - dialysatePumps[ pumpId ].currentPumpSpeed ); - U32 minRPM; + U32 minRPM = getDialysatePumpMinRPM( pumpId ); if ( currentToTargetDiff > ZERO_SPEED ) { @@ -836,15 +820,6 @@ // } } - if ( D48_PUMP == pumpId ) - { - minRPM = getD48MinPumpRPM(); - } - else - { - minRPM = MIN_DIALYSATE_PUMP_RPM; - } - if ( dialysatePumps[ pumpId ].currentPumpSpeed >= minRPM ) { if ( D12_PUMP == pumpId ) @@ -1266,20 +1241,9 @@ if ( (DIALYSATE_PUMPS_T)payload.pumpID < NUM_OF_DIALYSATE_PUMPS ) { - U32 minRPM; - U32 maxRPM; + U32 minRPM = getDialysatePumpMinRPM( (DIALYSATE_PUMPS_T)payload.pumpID ); + U32 maxRPM = getDialysatePumpMaxRPM( (DIALYSATE_PUMPS_T)payload.pumpID ); - if ( D48_PUMP == (DIALYSATE_PUMPS_T)payload.pumpID ) - { - minRPM = getD48MinPumpRPM(); - maxRPM = getD48MaxPumpRPM(); - } - else - { - minRPM = MIN_DIALYSATE_PUMP_RPM; - maxRPM = MAX_DIALYSATE_PUMP_RPM; - } - // Handle start command. if ( ( TRUE == payload.startStop ) && ( ( payload.rpm >= minRPM ) && ( payload.rpm <= maxRPM ) ) ) Index: firmware/App/Controllers/DialysatePumps.h =================================================================== diff -u -r97eba3d39e6ddf44276b77b1aea1171805ca142d -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Controllers/DialysatePumps.h (.../DialysatePumps.h) (revision 97eba3d39e6ddf44276b77b1aea1171805ca142d) +++ firmware/App/Controllers/DialysatePumps.h (.../DialysatePumps.h) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -84,8 +84,8 @@ void execDialysatePumpController( void ); SELF_TEST_STATUS_T execDialysatePumpSelfTest( void ); -U32 getD48MinPumpRPM( void ); -U32 getD48MaxPumpRPM( void ); +U32 getDialysatePumpMinRPM( DIALYSATE_PUMPS_T pumpId ); +U32 getDialysatePumpMaxRPM( DIALYSATE_PUMPS_T pumpId ); F32 getDialysatePumpTargetSpeed( DIALYSATE_PUMPS_T pumpId ); F32 getDialysatePumpMeasuredSpeed( DIALYSATE_PUMPS_T pumpId ); F32 getDialysatePumpTargetPressure( DIALYSATE_PUMPS_T pumpId ); Index: firmware/App/DDCommon.h =================================================================== diff -u -r3f13f08370505c15ae818c90822d18410bf6747c -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 3f13f08370505c15ae818c90822d18410bf6747c) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -54,7 +54,6 @@ //Uncomment below to disable Teensy conductivity driver #define __TEENSY_CONDUCTIVITY_DRIVER__ 1 - #include #include #endif Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r97eba3d39e6ddf44276b77b1aea1171805ca142d -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 97eba3d39e6ddf44276b77b1aea1171805ca142d) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -145,7 +145,7 @@ bicarbFillStartTimeMS = 0; pendingSpentChamberFill = FALSE; pendingBicarbChamberFill = FALSE; - d48PumpSpeed = getD48MinPumpRPM(); + d48PumpSpeed = getDialysatePumpMinRPM( D48_PUMP ); //Testing bypassStateDelayStartTimeMS = 0; delayBypassStateFlag = TRUE; @@ -649,8 +649,10 @@ F32 dialFlowrate = getTDDialysateFlowrate(); F32 slope; F32 intercept; + F32 calculatedSpeed; + U32 rpm; - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP ) ) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) { slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_1000; intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000; @@ -661,7 +663,18 @@ intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000; } - return (U32)( ( slope * dialFlowrate ) + intercept ); + // Calculate nominal speed from Qd. + calculatedSpeed = ( slope * dialFlowrate ) + intercept; + + // Prevent negative before converting to unsigned and round up using ceilf. + if ( calculatedSpeed < 0.0F ) + { + calculatedSpeed = 0.0F; + } + + rpm = (U32)ceilf( calculatedSpeed ); + + return rpm; } /*********************************************************************//** Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -rd5f400afa9c81bf42d813af25961d63132ad297a -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision d5f400afa9c81bf42d813af25961d63132ad297a) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -1091,14 +1091,14 @@ *************************************************************************/ void setFPGAD48PumpSpeed( U16 speed ) { - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP )) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP )) { - U16 currentSpeed = (U16)( ( ( DIENER_1000_PUMP_SLOPE * speed ) + DIENER_1000_PUMP_INTERCEPT) * DIENER_1000_PUMP_SPEED_FULL_SCALE ); + U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); SET_FPGA_ACTUATOR_FIELD( fpgaD48PumpSpeed, currentSpeed ); } else { - U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); + U16 currentSpeed = (U16)( ( ( DIENER_1000_PUMP_SLOPE * speed ) + DIENER_1000_PUMP_INTERCEPT) * DIENER_1000_PUMP_SPEED_FULL_SCALE ); SET_FPGA_ACTUATOR_FIELD( fpgaD48PumpSpeed, currentSpeed ); } } @@ -1114,10 +1114,8 @@ *************************************************************************/ void setFPGAD12PumpSpeed( U16 speed ) { - U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); SET_FPGA_ACTUATOR_FIELD( fpgaD12PumpSpeed, currentSpeed ); - } /*********************************************************************//**