Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -red39129abdca4ec343369d83494530b23621e052 -r322747d530c1b8205be257557e53dcfe9caad50a --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision ed39129abdca4ec343369d83494530b23621e052) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) @@ -43,11 +43,10 @@ #define DATA_PUBLISH_COUNTER_START_COUNT 60 ///< Data publish counter start count. #define DP_CONTROL_INTERVAL ( 1000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate pump is controlled. -//#define DP_CONTROL_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate pump is controlled. #define DIALYSATE_PUMP_CONTROL_RUN 0x01 ///< Dialysate pump control run pump. #define DIALYSATE_PUMP_CONTROL_STOP 0x00 ///< Dialysate pump control stop pump. #define DIALYSATE_PUMP_FORWARD_DIR 1 ///< Dialysate pump forward direction. reverse direction is not allowed. -#define DIALYSATE_PUMP_SPEED_INCREMENT 10.0F ///< Speed increase when controlling dialysate pump to target step speed. +#define DIALYSATE_PUMP_RAMP_SPEED_INCREMENT 10.0F ///< Speed increase when controlling dialysate pump ramp to target step speed. #define ZERO_SPEED 0.0F ///< Zero speed/RPM value. #define DIALYSATE_PUMP_MAX_CURRENT_WHEN_OFF_A 0.1F ///< Dialysate pump maximum current when the pump is off in amps. @@ -151,7 +150,7 @@ * @brief * The initDialysatePump function initializes the DialysatePumps unit. * @details \b Inputs: none - * @details \b Outputs: Dialysate unit variables initialized. + * @details \b Outputs: Dialysate pump unit variables initialized. * @return none *************************************************************************/ void initDialysatePump( void ) @@ -252,7 +251,8 @@ } else if ( rpm < MIN_DIALYSATE_PUMP_RPM ) { - pumpTargetSpeed[ pumpId ].data = 0.0; + // Lets assign minimum speed to make sure, driver is not getting into fault mode + pumpTargetSpeed[ pumpId ].data = MIN_DIALYSATE_PUMP_RPM; } else { @@ -393,7 +393,6 @@ BOOL isCurrentOutOfRange = FALSE; DIALYSATE_PUMPS_T pumpId; - // Update the paramerters dialysatePumpMeasuredCurrentA[ D12_PUMP ].data = (F32)d12Current * CURRENT_CONVERSION_COEFF; dialysatePumpMeasuredCurrentA[ D48_PUMP ].data = (F32)d48Current * CURRENT_CONVERSION_COEFF; @@ -422,7 +421,7 @@ isOffCurrentOut = ( getDialysatePumpMeasuredCurrentA( pumpId ) > DIALYSATE_PUMP_MAX_CURRENT_WHEN_OFF_A ? TRUE : FALSE ); isRPMTooHigh = ( getDialysatePumpMeasuredSpeed( pumpId ) > MIN_DIALYSATE_PUMP_RPM ? TRUE : FALSE ); - + //TODO : Enable the code later for alarm testing #if 0 if ( D12_PUMP == pumpId ) { @@ -457,6 +456,7 @@ BOOL isDirInvalid = ( ( direction != DIALYSATE_PUMP_FORWARD_DIR ) && ( rpm > DIALYSATE_PUMP_MIN_RPM_FOR_DIR_CHECK ) ? TRUE : FALSE ); isRPMOutOfRange = ( rpmDiff > MAX_ALLOWED_RPM_OUT_OF_RANGE ? TRUE : FALSE ); + //TODO : Enable the code later for alarm testing #if 0 if ( D12_PUMP == pumpId ) { @@ -485,6 +485,7 @@ // Check the persistent alarm for the maximum dialysate pump current F32 currentA = getDialysatePumpMeasuredCurrentA( pumpId ); isCurrentOutOfRange = ( currentA > DIALYSATE_PUMP_MAX_CURRENT_A ? TRUE : FALSE ) | isOffCurrentOut; + //TODO : Enable the code later for alarm testing #if 0 if ( D12_PUMP == pumpId ) { @@ -539,7 +540,6 @@ break; #ifndef _VECTORCAST_ - // The switch case is in a for loop so the default case cannot be covered in VectorCAST default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_DIALYSATE_PUMP_EXEC_INVALID_STATE, pumpId ) dialysatePumps[ pumpId ].dialysatePumpState = DIALYSATE_PUMP_OFF_STATE; @@ -681,9 +681,9 @@ if ( currentToTargetDiff > ZERO_SPEED ) { - if ( currentToTargetDiff > DIALYSATE_PUMP_SPEED_INCREMENT ) + if ( currentToTargetDiff > DIALYSATE_PUMP_RAMP_SPEED_INCREMENT ) { - speedIncrease = DIALYSATE_PUMP_SPEED_INCREMENT; + speedIncrease = DIALYSATE_PUMP_RAMP_SPEED_INCREMENT; } else { @@ -743,19 +743,20 @@ { F32 measuredPressure = getFilteredPressure( D18_PRES ); F32 targetPressure = getDialysatePumpTargetPressure( pumpId ); - F32 newSpeed = 0; + F32 newSpeed = 0.0F; //F32 control = runPIController( PI_CONTROLLER_ID_D12_PUMP, targetPressure, measuredPressure ); // TODO : get the equivalent speed for the given control // newSpeed = control * ( MAX_DIALYSATE_PUMP_RPM / DIALYSATE_PUMP_MAX_PRESSURE_PSI ); + //TODO: Below code is placeholder to have minimal close loop control, to be reevaluated. #if 0 if ( measuredPressure < targetPressure ) { - newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed + DIALYSATE_PUMP_SPEED_INCREMENT; + newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed + DIALYSATE_PUMP_RAMP_SPEED_INCREMENT; } else { - newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed - DIALYSATE_PUMP_SPEED_INCREMENT; + newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed - DIALYSATE_PUMP_RAMP_SPEED_INCREMENT; } //Apply speed limit @@ -771,19 +772,20 @@ { F32 measuredPressure = getFilteredPressure( D51_PRES ); F32 targetPressure = getDialysatePumpTargetPressure( pumpId ); - F32 newSpeed = 0; + F32 newSpeed = 0.0F; //F32 control = runPIController( PI_CONTROLLER_ID_D48_PUMP, targetPressure, measuredPressure ); // TODO : get the equivalent speed for the given control // newSpeed = control * ( MAX_DIALYSATE_PUMP_RPM / DIALYSATE_PUMP_MAX_PRESSURE_PSI ); + //TODO: Below code is placeholder to have minimal close loop control, to be reevaluated. #if 0 if ( measuredPressure < targetPressure ) { - newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed + DIALYSATE_PUMP_SPEED_INCREMENT; + newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed + DIALYSATE_PUMP_RAMP_SPEED_INCREMENT; } else { - newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed - DIALYSATE_PUMP_SPEED_INCREMENT; + newSpeed = dialysatePumps[ pumpId ].currentPumpSpeed - DIALYSATE_PUMP_RAMP_SPEED_INCREMENT; } //Apply speed limit