Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r97e0100921ccad633b39b509a93a7237e4d80446 -re6f3a632890f96a5aa282922d11df148bdd06587 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 97e0100921ccad633b39b509a93a7237e4d80446) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision e6f3a632890f96a5aa282922d11df148bdd06587) @@ -37,12 +37,11 @@ #define CONCENTRATE_PUMP_SPEED_INCREMENT 8.0 ///< Speed increase (mL/min) when controlling concentrate pump to target step speed. #define CONCENTRATE_PUMP_MIN_SPEED 3.0 ///< Minimum speed for concentrate pump in mL per min. -#define CONCENTRATE_PUMP_MAX_SPEED 49.0 ///< Maximum speed for concentrate pump in mL per min. #define CONCENTRATE_PUMP_ERROR_TOLERANCE 0.02 ///< Measured speed needs to be within 2% of commanded speed. #define CONCENTRATE_PUMP_ZERO_FLOW_RATE 0xFFFF ///< Pulse width value when zero flow rate or pump is off. -#define CONCENTRATE_PUMP_VOLUME_PER_REV 0.15 ///< Volume output every revolution (mL). -#define CONCENTRATE_PUMP_PULSE_PER_REV 4.0 ///< Number of pulses generate for every revolution. +#define CONCENTRATE_PUMP_VOLUME_PER_REV 0.1 ///< Volume output every revolution (mL). +#define CONCENTRATE_PUMP_PULSE_PER_REV 2.0 ///< Number of pulses generate for every revolution. #define CONCENTRATE_PUMP_STEP_PER_REV 200.0 ///< Number of steps for every revolution. #define CONCENTRATE_PUMP_HALL_SENSE_PERIOD_RESOLUTION 100.0 ///< Hall sense period resolution in microseconds. @@ -53,7 +52,7 @@ #define CONCENTRATE_PUMP_VOLUME_PER_PULSE ( CONCENTRATE_PUMP_VOLUME_PER_REV / CONCENTRATE_PUMP_PULSE_PER_REV ) #define CONCENTRATE_PUMP_DATA_PUBLISH_INTERVAL ( 500 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the concentrate pump is monitored. -#define CONCENTRATE_PUMP_CONTROL_INTERVAL ( 500 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the concentrate pump is controlled. +#define CONCENTRATE_PUMP_CONTROL_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the concentrate pump is controlled. #define CONCENTRATE_PUMP_SPEED_CONTROL_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for concentrate pump speed control error. /// Enumeration of concentrate pump states. @@ -102,7 +101,6 @@ static U32 getPublishConcentratePumpDataInterval( void ); static void calcMeasuredPumpsSpeed( CONCENTRATE_PUMPS_T pumpId, U16 pulseWidthCount ); -static F32 getMeasuredPumpSpeed( CONCENTRATE_PUMPS_T pumpId ); static BOOL processCalibrationData( void ); /*********************************************************************//** @@ -158,7 +156,13 @@ if ( ++concentratePumpMonitorTimerCounter >= getPublishConcentratePumpDataInterval() ) { CONCENTRATE_PUMP_DATA_T data; + U08 const fpgaConcentratePumpsFault = getFPGAConcentratePumpsFault(); + if ( 0 != fpgaConcentratePumpsFault ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_CONCENTRATE_PUMP_FAULT, fpgaConcentratePumpsFault ); + } + calcMeasuredPumpsSpeed( CONCENTRATEPUMPS_CP1_ACID, getFPGACP1HallSensePulseWidth() ); calcMeasuredPumpsSpeed( CONCENTRATEPUMPS_CP2_BICARB, getFPGACP2HallSensePulseWidth() ); @@ -167,10 +171,10 @@ data.cp2CurrentSetSpeed = concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed; data.cp2MeasuredSpeed = getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ); +#ifndef DISABLE_DIALYSATE_CHECK F32 const cp1Error = fabs( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) - concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed ) / concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed; F32 const cp2Error = fabs( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) - concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed ) / concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed; -#ifndef DISABLE_DIALYSATE_CHECK checkPersistentAlarm( ALARM_ID_CP1_SPEED_CONTROL_ERROR, cp1Error > CONCENTRATE_PUMP_ERROR_TOLERANCE, cp1Error, CONCENTRATE_PUMP_ERROR_TOLERANCE ); checkPersistentAlarm( ALARM_ID_CP2_SPEED_CONTROL_ERROR, cp2Error > CONCENTRATE_PUMP_ERROR_TOLERANCE, cp2Error, CONCENTRATE_PUMP_ERROR_TOLERANCE ); #endif @@ -308,6 +312,10 @@ { concentratePumps[ pumpId ].pumpTargetSpeed = targetSpeed_ml_min; } + else if ( targetSpeed_ml_min < CONCENTRATE_PUMP_MIN_SPEED ) + { + concentratePumps[ pumpId ].pumpTargetSpeed = 0.0; + } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_CONCENTRATE_PUMP_SPEED_OUT_OF_RANGE, targetSpeed_ml_min ) @@ -321,6 +329,35 @@ /*********************************************************************//** * @brief + * The getMeasuredPumpSpeed function gets the measured concentrate pump flow rate. + * @details Inputs: measuredPumpSpeed + * @details Outputs: none + * @param pumpId concentrate pump id to increase current step speed + * @return the current concentrate pump flow rate (in mL/min). + *************************************************************************/ +F32 getMeasuredPumpSpeed( CONCENTRATE_PUMPS_T pumpId ) +{ + F32 result = 0.0; + + if ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) + { + result = concentratePumps[ pumpId ].measuredPumpSpeed.data; + + if ( OVERRIDE_KEY == concentratePumps[ pumpId ].measuredPumpSpeed.override ) + { + result = concentratePumps[ pumpId ].measuredPumpSpeed.ovData; + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID, pumpId ); + } + + return result; +} + +/*********************************************************************//** + * @brief * The getAcidConcentrateCalRecord function returns the acid concentrate * calibration record. * @details Inputs: none @@ -508,35 +545,6 @@ /*********************************************************************//** * @brief - * The getMeasuredPumpSpeed function gets the measured concentrate pump flow rate. - * @details Inputs: measuredPumpSpeed - * @details Outputs: none - * @param pumpId concentrate pump id to increase current step speed - * @return the current concentrate pump flow rate (in mL/min). - *************************************************************************/ -static F32 getMeasuredPumpSpeed( CONCENTRATE_PUMPS_T pumpId ) -{ - F32 result = 0.0; - - if ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) - { - result = concentratePumps[ pumpId ].measuredPumpSpeed.data; - - if ( OVERRIDE_KEY == concentratePumps[ pumpId ].measuredPumpSpeed.override ) - { - result = concentratePumps[ pumpId ].measuredPumpSpeed.ovData; - } - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID, pumpId ); - } - - return result; -} - -/*********************************************************************//** - * @brief * The processCalibrationData function gets the calibration data and makes * sure it is valid by checking the calibration date. The calibration date * should not be 0. @@ -666,7 +674,7 @@ { F32 const absSpeed = fabs( value ); - if ( ( CONCENTRATE_PUMP_MIN_SPEED <= absSpeed ) && ( absSpeed <= CONCENTRATE_PUMP_MAX_SPEED ) ) + if ( absSpeed <= CONCENTRATE_PUMP_MAX_SPEED ) { result = TRUE; setConcentratePumpTargetSpeed( (CONCENTRATE_PUMPS_T)pumpId, value );