Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r8a0632bf9908008ee8db18474bc914d990760986 -rd64ce68a34e7a2fc8cdc67cecb7269dec440305d --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 8a0632bf9908008ee8db18474bc914d990760986) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision d64ce68a34e7a2fc8cdc67cecb7269dec440305d) @@ -38,10 +38,6 @@ #define SIZE_OF_SMALL_LOAD_CELL_AVG 8 ///< Small load cell moving average has 8 samples. #define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. -#define MAX_LOAD_CELL_CHANGE_G 1000.0 ///< Maximum delta between new load cell sample and its small moving average (in g). Can change quite a bit during tare. -#define MAX_ACTIVE_LOAD_CELL_CHANGE_G 30.0 ///< Maximum delta between new load cell sample and its small moving average (in g) when associated reservoir is active in treatment. -#define LOAD_CELL_CHANGE_PERSISTENCE 3 ///< Excessive load cell acceleration must persist for 3 samples (@ 10 Hz) to trigger alarm. - /// States of the treatment reservoir management state machine. typedef enum TreatmentReservoirMgmt_States { @@ -94,8 +90,6 @@ static F32 lgLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_LARGE_LOAD_CELL_AVG ]; static U32 lgLoadCellReadingsIdx = 0; ///< Index for next sample in large load cell rolling average sample array. static F32 lgLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc large load cell moving average. -/// Persistence counters for excessive load cell acceleration alarm. -static U32 excessiveLoadCellAccelerationCtr[ NUM_OF_DG_RESERVOIRS ] = { 0, 0 }; // DG pumps data static F32 dgROPumpFlowRateMlMin = 0.0; ///< Latest RO water flow rate reported by the DG. @@ -673,34 +667,6 @@ for ( res = DG_RESERVOIR_1; res < NUM_OF_DG_RESERVOIRS; res++ ) { F32 wt = ( res == DG_RESERVOIR_1 ? res1Primary : res2Primary ); -#ifndef DISABLE_UF_ALARMS - F32 delta = fabs( smFilteredReservoirWeightInGrams[ res ] - wt ); - BOOL deltaAlarmDetected = FALSE; - ALARM_ID_T deltaAlarm = ( res == DG_RESERVOIR_1 ? ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_1_ALARM : ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_2_ALARM ); - - // Check for excessive load cell acceleration - if ( ( TRUE == inTreatment ) && ( res == activeRes ) && ( delta > MAX_ACTIVE_LOAD_CELL_CHANGE_G ) ) - { - deltaAlarmDetected = TRUE; - } - else if ( ( delta > MAX_LOAD_CELL_CHANGE_G ) && ( TRUE == isPOSTCompleted() ) ) - { - deltaAlarmDetected = TRUE; - } - // Trigger or clear excessive load cell acceleration condition - if ( TRUE == deltaAlarmDetected ) - { - if ( ++excessiveLoadCellAccelerationCtr[ res ] > LOAD_CELL_CHANGE_PERSISTENCE ) - { - SET_ALARM_WITH_2_F32_DATA( deltaAlarm, wt, smFilteredReservoirWeightInGrams[ res ] ); - } - } - else - { - excessiveLoadCellAccelerationCtr[ res ] = 0; - clearAlarmCondition( deltaAlarm ); - } -#endif smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ]; lgLoadCellReadingsTotal[ res ] -= lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ]; smLoadCellReadings[ res ][ smLoadCellReadingsIdx ] = wt; Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rda2e3c510c11072220a77e1a30dd546ddff0e744 -rd64ce68a34e7a2fc8cdc67cecb7269dec440305d --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision da2e3c510c11072220a77e1a30dd546ddff0e744) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision d64ce68a34e7a2fc8cdc67cecb7269dec440305d) @@ -51,9 +51,9 @@ #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. -#define DOP_P_COEFFICIENT 0.0020 ///< P term for dialysate outlet pump control. -#define DOP_I_COEFFICIENT 0.0002 ///< I term for dialysate outlet pump control. +#define DOP_CONTROL_INTERVAL ( 2000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate outlet pump is controlled. +#define DOP_P_COEFFICIENT 0.0025 ///< P term for dialysate outlet pump control. +#define DOP_I_COEFFICIENT 0.0005 ///< I term for dialysate outlet pump control. #define DOP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define DOP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -raeb1dea9ea10fcc70ae66023a87b565f29924c07 -rd64ce68a34e7a2fc8cdc67cecb7269dec440305d --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision aeb1dea9ea10fcc70ae66023a87b565f29924c07) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision d64ce68a34e7a2fc8cdc67cecb7269dec440305d) @@ -53,6 +53,8 @@ #define MIN_SALINE_BOLUS_VOLUME_PCT 0.8 ///< Minimum saline bolus volume measured by independent means (as % of target). #define MAX_SALINE_BOLUS_VOLUME_PCT 1.2 ///< Maximum saline bolus volume measured by independent means (as % of target). +#define MAX_ACTIVE_LOAD_CELL_CHANGE_G 50.0 ///< Maximum delta between new and previous measured UF volume. + // ********** private data ********** static DIALYSIS_STATE_T currentDialysisState; ///< Current state of the dialysis sub-mode state machine. @@ -1127,11 +1129,23 @@ { DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); F32 latestResVolume = getReservoirWeightSmallFilter( activeRes ); +#ifndef DISABLE_UF_ALARMS + F32 deltaVolume = latestResVolume - resFinalVolume[ activeRes ]; - // calculate UF volumes and provide to dialysate outlet pump controller - measUFVolume = measUFVolumeFromPriorReservoirs + ( latestResVolume - resStartVolume[ activeRes ] ); - resFinalVolume[ activeRes ] = latestResVolume; - setDialOutUFVolumes( refUFVolume, measUFVolume ); + // ensure volume change is not too excessive - indication that load cell was impacted by some kind of shock + if ( fabs(deltaVolume) > MAX_ACTIVE_LOAD_CELL_CHANGE_G ) + { + ALARM_ID_T deltaAlarm = ( getDGActiveReservoir() == DG_RESERVOIR_1 ? ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_1_ALARM : ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_2_ALARM ); + SET_ALARM_WITH_1_F32_DATA( deltaAlarm, deltaVolume ); + } + else +#endif + { + // calculate UF volumes and provide to dialysate outlet pump controller + measUFVolume = measUFVolumeFromPriorReservoirs + ( latestResVolume - resStartVolume[ activeRes ] ); + resFinalVolume[ activeRes ] = latestResVolume; + setDialOutUFVolumes( refUFVolume, measUFVolume ); + } } /*********************************************************************//** Index: firmware/App/Services/PIControllers.c =================================================================== diff -u -r46d8eb906ba116a5e846ecb3a3a8629eae167635 -rd64ce68a34e7a2fc8cdc67cecb7269dec440305d --- firmware/App/Services/PIControllers.c (.../PIControllers.c) (revision 46d8eb906ba116a5e846ecb3a3a8629eae167635) +++ firmware/App/Services/PIControllers.c (.../PIControllers.c) (revision d64ce68a34e7a2fc8cdc67cecb7269dec440305d) @@ -64,7 +64,7 @@ /// PI Controllers -- initial configurations. static PI_CONTROLLER_T piControllers[ NUM_OF_PI_CONTROLLERS_IDS ] = { // Kp Ki uMax uMin ref meas err esw esum ctrl Ilimit controller type - { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, CONTROLLER_UNIDIRECTIONAL }, // PI_CONTROLLER_ID_ULTRAFILTRATION + { 0.0, 0.0, 0.90, 0.10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 50.0, CONTROLLER_UNIDIRECTIONAL }, // PI_CONTROLLER_ID_ULTRAFILTRATION { 0.0, 0.0, 0.90, 0.10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0, CONTROLLER_UNIDIRECTIONAL }, // PI_CONTROLLER_ID_BLOOD_FLOW { 0.0, 0.0, 0.90, 0.10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0, CONTROLLER_UNIDIRECTIONAL } // PI_CONTROLLER_ID_DIALYSATE_FLOW };