Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 -rfbdff223ca110491c6f7776669fa46ac5fc56da4 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision fbdff223ca110491c6f7776669fa46ac5fc56da4) @@ -35,7 +35,10 @@ #define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). #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 SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. + +#define MAX_LOAD_CELL_CHANGE_G 70.0 ///< Maximum delta between new load cell sample and its small moving average (in g). +#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. /// States of the treatment reservoir management state machine. typedef enum TreatmentReservoirMgmt_States @@ -654,6 +657,8 @@ void setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ) { DG_RESERVOIR_ID_T res; + DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); + BOOL inTreatment = ( MODE_TREA == getCurrentOperationMode() ? TRUE : FALSE ); loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_PRIMARY ].data = res1Primary; loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_BACKUP ].data = res1Backup; @@ -663,8 +668,31 @@ // feed new weight samples into filters and update moving averages for ( res = DG_RESERVOIR_1; res < NUM_OF_DG_RESERVOIRS; res++ ) { - F32 wt = ( res == DG_RESERVOIR_1 ? res1Primary : res2Primary ); + 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 ) + { + deltaAlarmDetected = TRUE; + } + // Trigger or clear excessive load cell acceleration condition + if ( TRUE == deltaAlarmDetected ) + { + SET_ALARM_WITH_2_F32_DATA( deltaAlarm, wt, smFilteredReservoirWeightInGrams[ res ] ); + } + else + { + // clearAlarmCondition( deltaAlarm ); TODO - un-comment when merged with branch that has this function implemented. + } +#endif smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ]; lgLoadCellReadingsTotal[ res ] -= lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ]; smLoadCellReadings[ res ][ smLoadCellReadingsIdx ] = wt; Index: firmware/App/HDCommon.h =================================================================== diff -u -ref95a6c8bdfb5ada99e6cffb9627155b6d3cd8c6 -rfbdff223ca110491c6f7776669fa46ac5fc56da4 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision ef95a6c8bdfb5ada99e6cffb9627155b6d3cd8c6) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision fbdff223ca110491c6f7776669fa46ac5fc56da4) @@ -42,17 +42,17 @@ #define DISABLE_AIR_TRAP_LEVELING 1 // disable air trap level control // #define DISABLE_3WAY_VALVES 1 // disable 3-way valves // #define TST_3WAY_VALVES_ALWAYS_OPEN 1 // after POST and homing, open all 4 valves - #define DISABLE_ACCELS 1 // disable accelerometer POST and monitoring - #define DISABLE_CRC_ERROR 1 // do not error on bad CRC for CAN messages - #define DISABLE_ACK_ERRORS 1 // do not error on failure of other node(s) to ACK a message - #define DISABLE_MOTOR_CURRENT_CHECKS 1 // do not error on HD pump current checks - #define DISABLE_PUMP_FLOW_CHECKS 1 // do not error on HD pump flow checks - #define DISABLE_PUMP_SPEED_CHECKS 1 // do not error on HD pump speed checks - #define DISABLE_PUMP_DIRECTION_CHECKS 1 // do not error on HD pump direction checks - #define DISABLE_SALINE_BOLUS_CHECKS 1 // do not error on HD saline bolus checks - #define DISABLE_PRESSURE_CHECKS 1 // do not error on HD pressure checks - #define DISABLE_UF_ALARMS 1 // do not error on HD ultrafiltration checks - #define DISABLE_VALVE_ALARMS 1 // do not error on HD valve position +// #define DISABLE_ACCELS 1 // disable accelerometer POST and monitoring +// #define DISABLE_CRC_ERROR 1 // do not error on bad CRC for CAN messages +// #define DISABLE_ACK_ERRORS 1 // do not error on failure of other node(s) to ACK a message +// #define DISABLE_MOTOR_CURRENT_CHECKS 1 // do not error on HD pump current checks +// #define DISABLE_PUMP_FLOW_CHECKS 1 // do not error on HD pump flow checks +// #define DISABLE_PUMP_SPEED_CHECKS 1 // do not error on HD pump speed checks +// #define DISABLE_PUMP_DIRECTION_CHECKS 1 // do not error on HD pump direction checks +// #define DISABLE_SALINE_BOLUS_CHECKS 1 // do not error on HD saline bolus checks +// #define DISABLE_PRESSURE_CHECKS 1 // do not error on HD pressure checks +// #define DISABLE_UF_ALARMS 1 // do not error on HD ultrafiltration checks +// #define DISABLE_VALVE_ALARMS 1 // do not error on HD valve position // #define RUN_PUMPS_OPEN_LOOP 1 // BP and DPi pumps will be run open loop (no flow sensor feedback) // #define RAW_FLOW_SENSOR_DATA 1 // test build will not filter flow sensor data // #define READ_FPGA_ASYNC_DATA 1 // test build reads non-priority register page every other time