Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -ra2bc96881a5fc3d8f779246b2abebf15a8de9384 -re23087e0c17f6ea81d60641fdb52121a8dd5a099 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision a2bc96881a5fc3d8f779246b2abebf15a8de9384) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision e23087e0c17f6ea81d60641fdb52121a8dd5a099) @@ -44,14 +44,15 @@ #define MAX_DIAL_OUT_FLOW_RATE 650 ///< Maximum dialysate outlet pump flow rate in mL/min. #define MIN_DIAL_OUT_FLOW_RATE 100 ///< Minimum dialysate outlet pump flow rate in mL/min. -#define DPO_FLOW_ADJ_DUE_TO_HIGHER_INLET_PRES 0.875 ///< Adjustment factor to account for higher pump inlet pressure (than DPi pump inlet). +#define DPO_FLOW_ADJ_DUE_TO_HIGHER_INLET_PRES 1.000 ///< Adjustment factor to account for higher pump inlet pressure (than DPi pump inlet). #define MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< Maximum duty cycle change when ramping up ~ 200 mL/min/s. #define MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< Maximum duty cycle change when ramping down ~ 300 mL/min/s. #define MAX_DIAL_OUT_PUMP_PWM_DUTY_CYCLE 0.88 ///< Controller will error if PWM duty cycle > 90%, so set max to 88%. #define MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE 0.12 ///< Controller will error if PWM duty cycle < 10%, so set min to 12%. -#define DOP_CONTROL_INTERVAL ( 1000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate outlet pump is controlled. +/// Interval (ms/task time) at which the dialysate outlet pump is controlled. +static const U32 DOP_CONTROL_INTERVAL = ( 2000 / TASK_GENERAL_INTERVAL ); #define DOP_P_COEFFICIENT 0.0050 ///< P term for dialysate outlet pump control. #define DOP_I_COEFFICIENT 0.0001 ///< I term for dialysate outlet pump control. @@ -66,11 +67,16 @@ #define DOP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. #define DOP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). #define DOP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. -#define DOP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for motor off error condition. -#define DOP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) motor speed error condition. -#define DOP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) rotor speed error condition. -#define DOP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) pump direction error condition. +/// Persist time (task intervals) for motor off error condition. +static const U32 DOP_OFF_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) motor speed error condition. +static const U32 DOP_MOTOR_SPEED_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) rotor speed error condition. +static const U32 DOP_ROTOR_SPEED_ERROR_PERSIST = ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) pump direction error condition. +static const U32 DOP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); + #define DOP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. #define DOP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< Motor controller current should always exceed this when pump should be running. #define DOP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< Motor controller current should not exceed this when pump should be running. @@ -132,7 +138,6 @@ static PUMP_CONTROL_MODE_T dialOutPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested control mode for dialysate outlet pump (open or closed loop). static PUMP_CONTROL_MODE_T dialOutPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set control mode for dialysate outlet pump. -static OVERRIDE_F32_T loadCellWeightInGrams[ NUM_OF_LOAD_CELLS ]; ///< Measured weight from load cells. static OVERRIDE_U32_T dialOutDataPublishInterval = { DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, 0 }; ///< Interval (in ms) at which to publish dialysate outlet data to CAN bus. static OVERRIDE_F32_T referenceUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Target ultrafiltration volume (in mL). static OVERRIDE_F32_T totalMeasuredUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Total measured ultrafiltration volume (in mL). @@ -203,12 +208,6 @@ dopLastMotorHallSensorCounts[ i ] = 0; } - // Initialize load cell weights - for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) - { - loadCellWeightInGrams[ i ].data = 0.0; - } - // Initialize dialysate outlet flow PI controller initializePIController( PI_CONTROLLER_ID_ULTRAFILTRATION, MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE, DOP_P_COEFFICIENT, DOP_I_COEFFICIENT, @@ -383,30 +382,6 @@ /*********************************************************************//** * @brief - * The setDialOutUFVolumes function sets the ultrafiltration reference and - * measured total volumes (in mL). - * @details Inputs: none - * @details Outputs: loadCellWeightInGrams[] - * @param res1Primary New weight from primary load cell of reservoir 1 - * @param res1Backup New weight from backup load cell of reservoir 1 - * @param res2Primary New weight from primary load cell of reservoir 2 - * @param res2Backup New weight from backup load cell of reservoir 2 - * @return TRUE if successful, FALSE if not - *************************************************************************/ -BOOL setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ) -{ - BOOL result = TRUE; - - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_PRIMARY ].data = res1Primary; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_BACKUP ].data = res1Backup; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_PRIMARY ].data = res2Primary; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_BACKUP ].data = res2Backup; - - return result; -} - -/*********************************************************************//** - * @brief * The execDialOutFlowMonitor function executes the dialysate outlet pump * and load cell sensor monitor. Checks are performed. Data is published * at appropriate interval. @@ -1010,37 +985,6 @@ /*********************************************************************//** * @brief - * The getLoadCellWeightInGrams function gets the load cell weight. - * @details Inputs: loadCellWeightInGrams - * @details Outputs: none - * @param loadCellID ID of load cell to get - * @return the current load cell weight in grams - *************************************************************************/ -F32 getLoadCellWeightInGrams( U32 loadCellID ) -{ - F32 result = 0.0; - - if ( loadCellID < NUM_OF_LOAD_CELLS ) - { - if ( OVERRIDE_KEY == loadCellWeightInGrams[ loadCellID ].override ) - { - result = loadCellWeightInGrams[ loadCellID ].ovData; - } - else - { - result = loadCellWeightInGrams[ loadCellID ].data; - } - } - else - { - activateAlarmNoData( ALARM_ID_HD_SOFTWARE_FAULT ); - } - - return result; -} - -/*********************************************************************//** - * @brief * The getTotalTargetDialOutUFVolumeInMl function gets the target UF volume. * @details Inputs: referenceUFVolumeInMl * @details Outputs: none @@ -1515,57 +1459,4 @@ return result; } -/*********************************************************************//** - * @brief - * The testSetDialOutLoadCellWeightOverride function overrides the value of the - * load cell sensor with a given weight (in grams). - * @details Inputs: loadCellWeightInGrams[] - * @details Outputs: loadCellWeightInGrams[] - * @param sensor ID of load cell sensor to override weight for - * @param value override weight (in grams) for the given sensor - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ) -{ - BOOL result = FALSE; - - if ( sensor < NUM_OF_LOAD_CELLS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - loadCellWeightInGrams[ sensor ].ovData = value; - loadCellWeightInGrams[ sensor ].override = OVERRIDE_KEY; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetDialOutLoadCellWeightOverride function resets the override of the - * load cell sensor. - * @details Inputs: loadCellWeightInGrams[] - * @details Outputs: loadCellWeightInGrams[] - * @param sensor ID of load cell sensor to override weight for - * @return TRUE if reset successful, FALSE if not - *************************************************************************/ -BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ) -{ - BOOL result = FALSE; - - if ( sensor < NUM_OF_LOAD_CELLS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - loadCellWeightInGrams[ sensor ].override = OVERRIDE_RESET; - loadCellWeightInGrams[ sensor ].ovData = loadCellWeightInGrams[ sensor ].ovInitData; - } - } - - return result; -} - /**@}*/