Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -ra069eb423b26296eb95214e18383c81adae07497 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision a069eb423b26296eb95214e18383c81adae07497) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -56,6 +56,8 @@ #define CONCENTRATE_PUMP_CONTROL_INTERVAL ( 50 / 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. +#define NUMBER_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK 1 ///< Number of acid and bicarb non-volatile data to check. + /// Enumeration of concentrate pump states. typedef enum ConcentratePumpState { @@ -149,14 +151,11 @@ if ( TRUE == isNewCalibrationRecordAvailable() ) { // Get the calibration values of acid and bicarb - // NOTE: since only the first acid and bicarb are used the number of sensors to check is acid or bicarb + 1 since the for loop - // starts from 0 and goes to sizeof the array so target sensor + 1 to just check the calibration time of the calibration values - // that are calibrated getNVRecord2Driver( GET_CAL_ACID_CONCENTREATES, (U08*)&acidConcentrateCalRecord, sizeof( acidConcentrateCalRecord ), - ( CAL_DATA_ACID_CONCENTRATE_1 + 1 ), ALARM_ID_DG_ACID_CONCENTRATE_INVALID_CAL_RECORD ); + NUMBER_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_ACID_CONCENTRATE_INVALID_CAL_RECORD ); getNVRecord2Driver( GET_CAL_BICARB_CONCENTRATES, (U08*)&bicarbConcentrateCalRecord, sizeof( bicarbConcentrateCalRecord ), - ( CAL_DATA_BICARB_CONCENTRATE_1 + 1 ), ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); + NUMBER_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); } if ( ++concentratePumpMonitorTimerCounter >= getU32OverrideValue( &concentratePumpDataPublishInterval ) ) @@ -166,7 +165,7 @@ if ( 0 != fpgaConcentratePumpsFault ) { - //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_CONCENTRATE_PUMP_FAULT, fpgaConcentratePumpsFault ); // TODO why did this error occur once? + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_CONCENTRATE_PUMP_FAULT, fpgaConcentratePumpsFault ); } calcMeasuredPumpsSpeed( CONCENTRATEPUMPS_CP1_ACID, getFPGACP1HallSensePulseWidth() ); Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r70031fe2d788c19ba0ec4779f144751b2ba3d3f9 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 70031fe2d788c19ba0ec4779f144751b2ba3d3f9) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -78,7 +78,7 @@ static U32 fansPublishCounter = 0; ///< Fans data publish interval counter. static BOOL isPOSTComplete = FALSE; ///< Flag that indicates whether POST is complete or not. static BOOL hasAlarmBeenRaised = FALSE; ///< Flag that indicates whether the RPM out of range alarm been raise. -static OVERRIDE_U32_T rpmAlarmStartTimeOffset = { 0, 0, 0, 0}; ///< RPM out of range alarm start time offset. +static OVERRIDE_U32_T rpmAlarmStartTimeOffset = { 0, 0, 0, 0 }; ///< RPM out of range alarm start time offset. static U32 rpmAlarmStartTime = 0; ///< RPM alarm start time. /// Temperature to duty cycle conversion slope (duty cycle not in percent) @@ -123,7 +123,7 @@ rpmAlarmStartTimeOffset.data = 0; rpmAlarmStartTimeOffset.ovData = 0; rpmAlarmStartTimeOffset.ovInitData = 0; - rpmAlarmStartTimeOffset.override = 0; + rpmAlarmStartTimeOffset.override = OVERRIDE_RESET; // Initialize the fans for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) @@ -657,7 +657,6 @@ rpmAlarmStartTimeOffset.override = OVERRIDE_KEY; result = TRUE; - } return result; Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rf5dc98b3d5fcd39e3ab502fbe81110e188ce0ec5 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision f5dc98b3d5fcd39e3ab502fbe81110e188ce0ec5) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -330,7 +330,7 @@ heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = heaterCmdPtr->targetTemp; // TODo do we need to remove this since the trimmer heater is set in the reservoirs #ifndef DISABLE_HEATERS_AND_TEMPS - //heatersStatus[ DG_TRIMMER_HEATER ].startHeaterSignal = TRUE; // DEBUG_DENALI + heatersStatus[ DG_TRIMMER_HEATER ].startHeaterSignal = TRUE; #endif } else @@ -730,8 +730,8 @@ dutyCycle = flow * WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES * ( targetTemperature - currentTemperature ) * heaterEfficiency; // Check the boundaries of the calculated duty cycle - dutyCycle = ( dutyCycle > HEATERS_MAX_DUTY_CYCLE ? HEATERS_MAX_DUTY_CYCLE : dutyCycle ); - dutyCycle = ( dutyCycle < HEATERS_MIN_DUTY_CYCLE ? HEATERS_MIN_DUTY_CYCLE : dutyCycle ); + dutyCycle = MIN( dutyCycle, HEATERS_MAX_DUTY_CYCLE ); + dutyCycle = MIN( dutyCycle, HEATERS_MIN_DUTY_CYCLE ); return dutyCycle; } @@ -833,7 +833,6 @@ data.interimTargetTemp = heatersStatus[ DG_PRIMARY_HEATER ].temporaryInterimTemperature; data.targetHeaterFlowLPM = heatersStatus[ DG_PRIMARY_HEATER ].targetROFlow; - broadcastData( MSG_ID_DG_HEATERS_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( HEATERS_DATA_T ) ); dataPublicationTimerCounter = 0; @@ -866,8 +865,9 @@ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_PRIMARY_HEATER_CJ_TEMP_OUT_OF_RANGE, primaryHeaterInternalTemp ); } - /*/ If any of the temperatures are above the range - /if ( ( FALSE == isPrimaryHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) +#ifndef IGNORE_HEATERS_MONITOR + // If any of the temperatures are above the range + if ( ( FALSE == isPrimaryHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) { stopPrimaryHeater(); isPrimaryHeaterTempOutOfRange = TRUE; @@ -879,7 +879,8 @@ { isPrimaryHeaterTempOutOfRange = FALSE; activateSafetyShutdown(); - }*/ + } +#endif } /*********************************************************************//** @@ -908,9 +909,10 @@ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_CJ_TEMP_OUT_OF_RANGE, trimmerHeaterColdJunctionTemp ); } +#ifndef IGNORE_HEATERS_MONITOR // If it is above the range for the first time, stop the trimmer heater // and set the variables - /*if ( ( FALSE == isTrimmerHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) + if ( ( FALSE == isTrimmerHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) { stopTrimmerHeater(); isTrimmerHeaterTempOutOfRange = TRUE; @@ -921,7 +923,8 @@ ( TRUE == didTimeout( trimmerHeaterTempOutTimer, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ) ) ) { activateSafetyShutdown(); - }*/ + } +#endif } /*********************************************************************//** Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -ra069eb423b26296eb95214e18383c81adae07497 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision a069eb423b26296eb95214e18383c81adae07497) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -354,9 +354,10 @@ if ( ++flowFilterCounter >= FLOW_SAMPLES_TO_AVERAGE ) { F32 flow = RO_FLOW_ADC_TO_LPM_FACTOR / ( (F32)measuredFlowReadingsSum * FLOW_AVERAGE_MULTIPLIER ); - flow = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / 1000.0 ) - - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / 1000.0 ); + flow = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - + ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); + measuredROFlowRateLPM.data = pow(flow, 4) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].fourthOrderCoeff + pow(flow, 3) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].thirdOrderCoeff + pow(flow, 2) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].secondOrderCoeff + Index: firmware/App/DGCommon.h =================================================================== diff -u -re59287e5915e01c44af22fc54eafc29cb0f6c2c0 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision e59287e5915e01c44af22fc54eafc29cb0f6c2c0) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -44,7 +44,7 @@ // #define HEATERS_DEBUG 1 // #define PRESSURES_DEBUG 1 // #define IGNORE_DRAIN_PUMP_MONITOR 1 -// #define IGNORE_HEATERS_MONITOR 1 + #define IGNORE_HEATERS_MONITOR 1 #define IGNORE_RO_PUMP_MONITOR 1 #define DISABLE_RO_RATIO_CHECK 1 #define DISABLE_COND_SENSOR_CHECK 1 // Disabled for Tom Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r46c6c0c0967b279e4a5ad1eb501b526812704248 -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 46c6c0c0967b279e4a5ad1eb501b526812704248) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -766,11 +766,4 @@ setHeatersInfoRecord( (U08*)&record ); } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - - /**@}*/ Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r38974e7129adace42bc44cacbf384a0b1442046c -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 38974e7129adace42bc44cacbf384a0b1442046c) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -17,6 +17,7 @@ #include // for memcpy() +#include "Heaters.h" #include "LoadCell.h" #include "MessageSupport.h" #include "ModeDrain.h" @@ -527,7 +528,7 @@ * @details Outputs: none * @return target fill flow rate in L/min *************************************************************************/ -F32 getTargetFillFlowRateLPM( void ) +F32 getTargetFillFlowRateLPM( void ) { return targetFillFlowRateLPM; } @@ -614,24 +615,27 @@ if ( FALSE == isThisTheFirstFill() ) { - F32 tempReservoirUse = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; + F32 tempTargetNumerator; + F32 targetTempDenominator; + F32 tempReservoirUse; + + tempReservoirUse = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; heatersTempCalc.tempReservoirEndFill = tempReservoirUse - ( heatersTempCalc.timeReservoirFill2SwitchMS * RESERVOIR_TAU_C_PER_MS ); heatersTempCalc.tempReservoir0 = heatersTempCalc.tempReservoirEndFill - ( ( heatersTempCalc.timeReservoirFillMS * 0.5 ) * RESERVOIR_TAU_C_PER_MS ); heatersTempCalc.timeUFDecayMS = (F32)heatersTempCalc.timeReservoirCycleMS - heatersTempCalc.timeReservoirFillMS; UFTimeConstant = heatersTempCalc.timeUFDecayMS * ULTRAFILTER_TAU_C_PER_MS; heatersTempCalc.tempUFFill = tempLastFill + UFTimeConstant; - F32 tempTargetNumerator = heatersTempCalc.tempReservoir0 - ( ( ULTRAFILTER_VOLUME_ML / targetFillVolML ) * heatersTempCalc.tempUFFill ); - F32 targetTempDenominator = ( ( targetFillVolML - ULTRAFILTER_VOLUME_ML ) / targetFillVolML ); + tempTargetNumerator = heatersTempCalc.tempReservoir0 - ( ( ULTRAFILTER_VOLUME_ML / targetFillVolML ) * heatersTempCalc.tempUFFill ); + targetTempDenominator = ( ( targetFillVolML - ULTRAFILTER_VOLUME_ML ) / targetFillVolML ); tempTarget = tempTargetNumerator / targetTempDenominator; } else { tempTarget = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; } - return tempTarget; } Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -r38974e7129adace42bc44cacbf384a0b1442046c -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 38974e7129adace42bc44cacbf384a0b1442046c) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -20,7 +20,6 @@ #include "DGCommon.h" #include "DGDefs.h" -#include "Heaters.h" // TODO maybe remove this and bring TARGET_TEMPS_AND_TIME_PAYLOAD_T to reservoirs? #include "NVDataMgmt.h" /** @@ -34,60 +33,58 @@ // ********** public definitions ********** #define MAX_RESERVOIR_VOLUME_ML 2000 ///< Maximum reservoir volume in mL. -// TODO the extra temperature includes 1 degree of extra temperature to account for the concentrate pumps #define RESERVOIR_EXTRA_TEMPERATURE 2.0 ///< Reservoirs extra margin temperature. /// Fill command data structure. typedef struct { - U32 fillToVolumeMl; ///< Target volume to fill to (in mL) - U32 cmd; ///< General command (start/stop) - F32 targetFlowLPM; ///< Target flow rate L/min + U32 fillToVolumeMl; ///< Target volume to fill to (in mL) + U32 cmd; ///< General command (start/stop) + F32 targetFlowLPM; ///< Target flow rate L/min } FILL_CMD_T; /// Drain command data structure. typedef struct { - U32 targetVolume; ///< Target volume to drain to (in mL) - BOOL tareLoadCell; ///< Flag to tare load call - BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines or not - U32 cmd; ///< General command (start/stop) + U32 targetVolume; ///< Target volume to drain to (in mL) + BOOL tareLoadCell; ///< Flag to tare load call + BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines or not + U32 cmd; ///< General command (start/stop) } DRAIN_CMD_T; /// DG command response data record. typedef struct { - U32 commandID; ///< The command DG is responding to - BOOL rejected; ///< Flag indicates if the command has been rejected - U32 rejectCode; ///< Reason code for rejecting the command + U32 commandID; ///< The command DG is responding to + BOOL rejected; ///< Flag indicates if the command has been rejected + U32 rejectCode; ///< Reason code for rejecting the command } DG_CMD_RESPONSE_T; -// TODO add doxygen comments /// Dialysate heating parameters typedef struct { - F32 trimmerTargetTemperature; - U32 timeReservoirCycleMS; - F32 timeReservoirFillMS; - U32 timeReservoirWait2SwitchMS; - F32 dialysateFlowLPM; + F32 trimmerTargetTemperature; ///< Trimmer Target temperature + U32 timeReservoirCycleMS; ///< Reservoir cycle time in milliseconds + F32 timeReservoirFillMS; ///< Reservoir fill time in milliseconds + U32 timeReservoirWait2SwitchMS; ///< Wait to switch active reservoir time in milliseconds + F32 dialysateFlowLPM; ///< Dialysate flow rate in L/min } DG_CMD_DIALYSATE_HEATING_PARAMS_T; /// Reservoir data struct. typedef struct { - U32 activeReservoir; ///< Active reservoir ID - U32 fillToVolumeMl; ///< Volume target to fill to - U32 drainToVolumeMl; ///< Volume target to drain to - U32 timeReservoirCycleMS; - U32 timeReservoirFill2SwitchMS; - F32 timeUFDecayMS; - F32 tempUFFill; - F32 tempReservoirUseActual; - F32 tempReservoirEndFill; - F32 tempAvgFill; - F32 tempLastFill; - F32 timereservoirFill; + U32 activeReservoir; ///< Active reservoir ID + U32 fillToVolumeMl; ///< Volume target to fill to + U32 drainToVolumeMl; ///< Volume target to drain to + U32 timeReservoirCycleMS; ///< Reservoir cycle time in milliseconds + U32 timeReservoirFill2SwitchMS; ///< Reservoir fill to switch time in milliseconds + F32 timeUFDecayMS; ///< Ultrafilter temperature decay time in milliseconds + F32 tempUFFill; ///< Ultrafilter fill time in milliseconds + F32 tempReservoirUseActual; ///< Reservoir actual temperature + F32 tempReservoirEndFill; ///< Reservoir end fill temperature + F32 tempAvgFill; ///< Average fill temperature + F32 tempLastFill; ///< Last fill temperature + F32 timereservoirFill; ///< Reservoir fill time in milliseconds } RESERVOIR_DATA_T; // ********** public function prototypes ********** @@ -110,7 +107,6 @@ DG_RESERVOIR_ID_T getInactiveReservoir( void ); F32 getReservoirWeight( DG_RESERVOIR_ID_T reservoirId ); -// Heaters target temperature function prototype void setDialysateHeatingParameters( DG_CMD_DIALYSATE_HEATING_PARAMS_T params ); U32 getTargetFillVolumeML( void ); F32 getTargetFillFlowRateLPM( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r989cb7be41238fe88d132b532f05298d2320e94e -reeb4e9c7c8ca2bc41168353c3d30f311080972b2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 989cb7be41238fe88d132b532f05298d2320e94e) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision eeb4e9c7c8ca2bc41168353c3d30f311080972b2) @@ -1699,6 +1699,7 @@ if ( FALSE == payload.reset ) { U32 command = 1; + result = testSetSafetyShutdownOverride( command ); } else