Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -rff0edadf0c6f161a0a092ddaf94d1940d64f7d5e -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision ff0edadf0c6f161a0a092ddaf94d1940d64f7d5e) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -22,6 +22,7 @@ #include "FpgaDD.h" #include "MessageSupport.h" #include "Messaging.h" +#include "ModeStandby.h" //#include "NVMgmt.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -1142,9 +1143,15 @@ *************************************************************************/ BOOL testDialysatePumpTargetSpeedOverride( MESSAGE_T *message ) { + +//TODO: This is a fix just for our testing to simulate going to heat mode from standby, need to revert back +#if 0 BOOL result = f32ArrayOverride( message, &pumpTargetSpeed[ 0 ], NUM_OF_DIALYSATE_PUMPS - 1 ); +#else + pendingStartDDHeatDisinfectRequest = TRUE; +#endif - return result; + return pendingStartDDHeatDisinfectRequest; } /*********************************************************************//** Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rff0edadf0c6f161a0a092ddaf94d1940d64f7d5e -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision ff0edadf0c6f161a0a092ddaf94d1940d64f7d5e) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -45,10 +45,15 @@ // ********** private definitions ********** #define AC_HEATER_TX_MAX_DUTY_CYCLE 0.50F ///< AC Heater treatment mode max duty cycle (50% of 1400W : 700W ) -#define AC_HEATER_HEAT_MAX_DUTY_CYCLE 0.70F ///< AC Heater heat disinfect mode max duty cycle (70% of 1400W : 980W ) +#define AC_HEATER_LOW_HEAT_MAX_DUTY_CYCLE 0.70F ///< AC Heater heat disinfect mode max duty cycle (70% of 1400W : 980W ) +#define AC_HEATER_UPPER_HEAT_MAX_DUTY_CYCLE 0.50F ///< AC Heater heat disinfect mode reduced duty cycle (50% of 1400W : 700W ) +#define AC_HEATER_REDUCED_DUTY_CYCLE 0.40F ///< AC Heater heat disinfect mode reduced duty cycle (40% of 1400W : 700W ) #define AC_HEATER_MAX_DUTY_CYCLE 1.0F ///< AC Heater max duty cycle (100.0%) or ON state #define DC_HEATER_MAX_DUTY_CYCLE 1.0F ///< DC Heater max duty cycle (100%) or ON state #define HEATERS_MIN_DUTY_CYCLE 0.0F ///< Heaters minimum duty cycle (0.00%) or OFF state +#define HEATERS_DISINFECT_TEMPERATURE_VERY_HIGH_DRIFT_C 10.0F ///< Heaters disinfect temperature very high drift in C. +#define HEATERS_DISINFECT_TEMPERATURE_HIGH_DRIFT_C 7.0F ///< Heaters disinfect temperature high drift in C. +#define HEATERS_DISINFECT_TEMPERATURE_MED_DRIFT_C 5.0F ///< Heaters disinfect temperature medium drift in C. #define HEATERS_DISINFECT_TEMPERATURE_DRIFT_C 3.0F ///< Heaters disinfect temperature drift in C. #define HEATERS_ZERO_DELTA_TEMP_C 0.0F ///< Heaters zero delta temperature in C. #define HEATERS_DUTY_CYCLE_CONVERSION_FACTOR 100.0F ///< Heaters duty cycle 0: OFF, 100: 100% duty cycle. @@ -68,9 +73,12 @@ #define HEATERS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters data publish interval. #define HEATER_TEMP_CONTROL_TRANSFER 2.0F ///< Primary Heater temperature difference to switch to D28 outer loop control function #define HEATER_TARGET_TEMPERATURE_MIN 10.0F ///< Minimum allowed target temperature for the heaters. +#if 1 +#define HEATER_TARGET_TEMPERATURE_MAX 45.0F ///< Maximum allowed target temperature for the heaters. +#else #define HEATER_TARGET_TEMPERATURE_MAX 90.0F ///< Maximum allowed target temperature for the heaters. +#endif #define DELTA_TEMP_ADJ_FLOW_RATE 150.0F ///< Fo Qd <= 150, the bottom range of second level temperature correction to be applied. - #define D5_HEAT_ON_NO_FLUID_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Primary heater on with no flow time out in milliseconds. #define D45_HEAT_ON_NO_FLUID_TIMEOUT_MS ( 12 * MS_PER_SECOND ) ///< Trimmer heater on with no flow time out in milliseconds. #define HEATERS_MAX_OPERATING_VOLTAGE_V 24.0F ///< Heaters max operating voltage in volts. @@ -983,6 +991,8 @@ else { // TODO : Calculate required duty cycle + // Start Open loop control with max power for heating + control[ heater ].data = AC_HEATER_LOW_HEAT_MAX_DUTY_CYCLE; state = HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET; } } @@ -1156,11 +1166,38 @@ { HEATERS_STATE_T state = HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET; - //TODO : update dutycycle for the heat disinfect state + if ( D5_HEAT == heater ) + { + F32 currentTemperature = getFilteredTemperatureValue( D78_TEMP ); + F32 heaterTemperature = getFilteredTemperatureValue( D4_TEMP ); + F32 targetTemperature = getHeaterTargetTemperature( heater ); + F32 deltaTemp = currentTemperature - targetTemperature; - setHeaterControl( D45_HEAT ); - setHeaterControl( D5_HEAT ); + if ( heaterTemperature > HEATER_TARGET_TEMPERATURE_MAX ) + { + control[ D5_HEAT ].data = HEATERS_MIN_DUTY_CYCLE; + } + else if ( deltaTemp > HEATERS_DISINFECT_TEMPERATURE_VERY_HIGH_DRIFT_C ) + { + control[ D5_HEAT ].data = HEATERS_MIN_DUTY_CYCLE; + } + else if ( currentTemperature < targetTemperature ) + { + control[ D5_HEAT ].data = AC_HEATER_LOW_HEAT_MAX_DUTY_CYCLE; + } + else if ( deltaTemp > HEATERS_DISINFECT_TEMPERATURE_HIGH_DRIFT_C ) + { + control[ D5_HEAT ].data = AC_HEATER_REDUCED_DUTY_CYCLE; + } + // TODO : if the current temp goes beyond the set limit + threshold, reduce the PWM Cycle + else if ( deltaTemp > HEATERS_DISINFECT_TEMPERATURE_DRIFT_C ) + { + control[ D5_HEAT ].data = AC_HEATER_UPPER_HEAT_MAX_DUTY_CYCLE; + } + setHeaterControl( D5_HEAT ); + } + return state; } Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r687cd19f4cd2476f648b7eb48c54c20fca0facb1 -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 687cd19f4cd2476f648b7eb48c54c20fca0facb1) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -327,6 +327,8 @@ setValveState( D40_VALV, VALVE_STATE_CLOSED ); setValveState( D100_VALV, VALVE_STATE_CLOSED ); setValveState( D47_VALV, VALVE_STATE_CLOSED ); + setValveState( D23_VALV, VALVE_STATE_OPEN ); + setValveState( D25_VALV, VALVE_STATE_OPEN ); requestConcentratePumpOff( D76_PUMP, FALSE ); switch ( state ) @@ -362,6 +364,8 @@ setValveState( D40_VALV, VALVE_STATE_OPEN ); setValveState( D91_VALV, VALVE_STATE_OPEN ); setValveState( D47_VALV, VALVE_STATE_OPEN ); + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); setConcentratePumpTargetSpeed( D76_PUMP, HEAT_DISINFECT_CONC_FLUSH_SPEED_ML_MIN, DOSING_CONT_VOLUME ); requestConcentratePumpOn( D76_PUMP ); break; @@ -750,7 +754,7 @@ switch ( depressurizeSubState ) { case HEAT_DEPRES_WAIT_D6: - if ( LEVEL_STATE_HIGH == getLevelStatus( D6_LEVL ) ) + if ( LVL_STATE_HIGH == getFloaterStatus( D6_LEVL ) ) { setValveState( D3_VALV, VALVE_STATE_CLOSED ); depressurizeSubState = HEAT_DEPRES_OPEN_D64; @@ -1069,6 +1073,15 @@ } } + if ( DD_HEAT_DISINFECT_DEPRESSURIZE_BICART == heatDisinfectState ) + { + setCurrentSubState( (U32)depressurizeSubState ); + } + else + { + setCurrentSubState( NO_SUB_STATE ); + } + publishHeatDisinfectModeData(); return heatDisinfectState; @@ -1113,6 +1126,7 @@ * The publishHeatDisinfectModeData function broadcasts heat disinfect * mode data at the configured interval. * @details \b Inputs: heatDisinfectPublishTimerCounter, heatDisinfectModePublishInterval, + * heatDisinfectState, depressurizeSubState, * ddDwellAtTarget, ddDwellAccumulatedMS, ddDwellAtTargetStartMS, * wcidDwellAtTarget, wcidDwellAccumulatedMS, wcidDwellAtTargetStartMS * @details \b Outputs: heatDisinfectPublishTimerCounter @@ -1127,8 +1141,18 @@ HEAT_DISINFECT_STATE_DATA_T data; data.heatDisinfectExecState = (U32)getCurrentHeatDisinfectState(); + if ( DD_HEAT_DISINFECT_DEPRESSURIZE_BICART == heatDisinfectState ) + { + data.heatDisinfectSubState = (U32)depressurizeSubState; + } + else + { + data.heatDisinfectSubState = NO_SUB_STATE; + } data.ddRecircDwellTimeMS = currentDwellMs( ddDwellAtTarget, ddDwellAccumulatedMS, ddDwellAtTargetStartMS ); data.wcidRecircDwellTimeMS = currentDwellMs( wcidDwellAtTarget, wcidDwellAccumulatedMS, wcidDwellAtTargetStartMS ); + data.ddDwellAtTarget = (U32)ddDwellAtTarget; + data.wcidDwellAtTarget = (U32)wcidDwellAtTarget; broadcastData( MSG_ID_DD_HEAT_DISINFECT_STATE_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( HEAT_DISINFECT_STATE_DATA_T ) ); heatDisinfectPublishTimerCounter = 0; } Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rff0edadf0c6f161a0a092ddaf94d1940d64f7d5e -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision ff0edadf0c6f161a0a092ddaf94d1940d64f7d5e) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -48,7 +48,7 @@ static BOOL pendingStartDDPreGenRequest; ///< Flag indicating TD has requested DD start the pre generation dialysate request. //static BOOL pendingStartDDFlushRequest; ///< Flag indicating TD has requested DD start flush. -//static BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. +BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. //static BOOL pendingStartDDHeatDisinfectActiveCoolRequest; ///< Flag indicating TD has requested DD start heat disinfect active cool. //static BOOL pendingStartDGROPermeateSampleRequest; ///< Flag indicating TD has requested DD to command RO to start permeate sample. @@ -185,11 +185,11 @@ // pendingStartDDFlushRequest = FALSE; // requestNewOperationMode( DD_MODE_FLUS ); // } -// else if ( TRUE == pendingStartDDHeatDisinfectRequest ) -// { -// pendingStartDDHeatDisinfectRequest = FALSE; -// requestNewOperationMode( DD_MODE_HEAT ); -// } + else if ( TRUE == pendingStartDDHeatDisinfectRequest ) + { + pendingStartDDHeatDisinfectRequest = FALSE; + requestNewOperationMode( DD_MODE_HEAT ); + } // else if ( TRUE == pendingStartDDHeatDisinfectActiveCoolRequest ) // { // pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r6d4aa77e6b85aa7621a234660f631e725fb1d441 -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 6d4aa77e6b85aa7621a234660f631e725fb1d441) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -32,6 +32,8 @@ // ********** public definitions ********** +BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. + /// Standby mode data structure typedef struct { Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -r9eae2f683887bededd2240f51ddfc667d8c1d566 -rd9839070a9c1d8dbc58cbba991b0b6845ee42d59 --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 9eae2f683887bededd2240f51ddfc667d8c1d566) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision d9839070a9c1d8dbc58cbba991b0b6845ee42d59) @@ -46,6 +46,7 @@ #define D28_D30_DATA_COLLECTION_TIME_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature sensors data collection time in milliseconds. #define D28_D30_TEMP_SENSORS_MAX_DEVIATION_C 3.0F ///< Dialysate temperature sensors maximum allowed deviation in C. #define DIALYSATE_TEMP_SNSRS_OUT_OF_RANGE_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Dialysate temperature sensors drift timeout in milliseconds. +#define TEMP_SNSRS_FILTERING_SAMPLE_TIME_SEC 5.0F ///< Dialysate temperature sensors sample interval into moving average filter. #define D28_D30_TEMP_SENSORS_MAX_DEVIATION_IN_HEAT_DIS_C 5.0F ///< Dialysate temperature sensors maximum allowed deviation in heat disinfect in C. /// Dialysate temperature sensors enums @@ -450,9 +451,18 @@ *************************************************************************/ static void getTempMovingAverageTimeInterval( void ) { + DD_OP_MODE_T opMode = getCurrentOperationMode(); + U32 sampleInterval; F32 period = (F32)SEC_PER_MIN / ( getTDDialysateFlowrate() / BAL_CHAMBER_FILL_VOLUME_ML ) ; - U32 sampleInterval = (U32)( ( period / (F32)TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); + if ( DD_MODE_HEAT == opMode ) + { + sampleInterval = (U32)( ( TEMP_SNSRS_FILTERING_SAMPLE_TIME_SEC / (F32)TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); + } + else + { + sampleInterval = (U32)( ( period / (F32)TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); + } tempDataCollectionTimeInterval = (U32) ( sampleInterval / TASK_PRIORITY_INTERVAL ); }