Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r94b2082ddcec6ccb947e67714dc85ae005a2c7b6 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 94b2082ddcec6ccb947e67714dc85ae005a2c7b6) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -256,10 +256,11 @@ * This part of code is commented out until the RPM is calculated from ADC correctly. * There will be a story to address the RPM conversion. */ +#ifndef IGNORE_DRAIN_PUMP_MONITOR // The RPM is only checked in open loop state that the pump is run at a fixed RPM. // The persistent alarm waits for a couple of seconds before raising an alarm, this is supposed to cover // when the pump is turned on and it takes a while to ramp up to target RPM. - /*if( drainPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) + if( drainPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { U32 targetRPM = getTargetDrainPumpRPM(); F32 threshold = OPEN_LOOP_RPM_OUT_OF_RANGE * targetRPM; @@ -283,7 +284,8 @@ //activateSafetyShutdown(); BOOL test = FALSE; } - }*/ + } +#endif // Publish drain pump data on interval publishDrainPumpData(); @@ -448,7 +450,7 @@ DRAIN_PUMP_STATE_T state = DRAIN_PUMP_OPEN_LOOP_STATE; // Check if the RPM is 0, and if it is turn off the pump - if ( getTargetDrainPumpRPM() == 0 ) + if ( 0 == getTargetDrainPumpRPM() ) { state = DRAIN_PUMP_OFF_STATE; signalDrainPumpHardStop(); Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r9f3943dcab5881216ef0119e7de3a36668dea3bc -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 9f3943dcab5881216ef0119e7de3a36668dea3bc) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -38,34 +38,33 @@ // ********** private definitions ********** -#define MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE 0.89 ///< Main primary heater (heater A) max duty cycle (89%). -#define SMALL_PRIMAY_HEATER_MAX_DUTY_CYCLE 0.50 ///< Small Primary heater (heater B) max duty cycle (50%). -#define TRIMMER_HEATER_MAX_DUTY_CYCLE 0.50 ///< Trimmer heater max duty cycle (50%). -#define HEATERS_MIN_DUTY_CYCLE 0.00 ///< Primary and trimmer heaters minimum duty cycle (0.00%). +#define MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE 0.89 ///< Main primary heater (heater A) max duty cycle (89%). +#define SMALL_PRIMAY_HEATER_MAX_DUTY_CYCLE 0.50 ///< Small Primary heater (heater B) max duty cycle (50%). +#define TRIMMER_HEATER_MAX_DUTY_CYCLE 0.50 ///< Trimmer heater max duty cycle (50%). +#define HEATERS_MIN_DUTY_CYCLE 0.00 ///< Primary and trimmer heaters minimum duty cycle (0.00%). -#define PRIMARY_HEATERS_P_COEFFICIENT 0.02 ///< Primary heaters proportional coefficient. -#define PRIMARY_HEATERS_I_COEFFICIENT 0.001 ///< Primary heaters integral coefficient. +#define PRIMARY_HEATERS_P_COEFFICIENT 0.02 ///< Primary heaters proportional coefficient. +#define PRIMARY_HEATERS_I_COEFFICIENT 0.001 ///< Primary heaters integral coefficient. -#define TRIMMER_HEATER_P_COEFFICIENT 0.02 ///< Trimmer heater proportional coefficient. -#define TRIMMER_HEATER_I_COEFFICIENT 0.001 ///< Trimmer heater integral coefficient. +#define TRIMMER_HEATER_P_COEFFICIENT 0.02 ///< Trimmer heater proportional coefficient. +#define TRIMMER_HEATER_I_COEFFICIENT 0.001 ///< Trimmer heater integral coefficient. -#define CONTROLLER_CHECK_INTERVAL_COUNT 10U ///< Time interval count to check the PI controller. -#define TEMP_SENSORS_INTERVAL_COUNT 10U ///< Temperature sensors interval count. +#define CONTROLLER_CHECK_INTERVAL_COUNT 10U ///< Time interval count to check the PI controller. +#define TEMP_SENSORS_INTERVAL_COUNT 10U ///< Temperature sensors interval count. -/// Heaters data publish interval. -#define HEATERS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / ( TASK_PRIORITY_INTERVAL ) ) +#define HEATERS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters data publish interval. -#define SMALL_PRIMARY_AND_TRIMMER_HEATERS_POST_TARGET_TEMPERATURE 40U ///< Small primary and trimmer heaters target temperature during POST. -#define MAIN_PRIMARY_HEATER_POST_TARGET_TEMPERATURE 35U ///< Main primary heater target temperature during POST. -#define HEATERS_POST_HEAT_UP_TIME_SECONDS 50U ///< The time that the heaters are heated up to reach to the target temperature during POST. -#define HEATERS_POST_TEMPERATURE_TOLERANCE 1U ///< Tolerance of the sensors to the target temperature during POST. +#define SMALL_PRIMARY_AND_TRIMMER_HEATERS_POST_TARGET_TEMPERATURE 40U ///< Small primary and trimmer heaters target temperature during POST. +#define MAIN_PRIMARY_HEATER_POST_TARGET_TEMPERATURE 35U ///< Main primary heater target temperature during POST. +#define HEATERS_POST_HEAT_UP_TIME_SECONDS 50U ///< The time that the heaters are heated up to reach to the target temperature during POST. +#define HEATERS_POST_TEMPERATURE_TOLERANCE 1U ///< Tolerance of the sensors to the target temperature during POST. -#define MINIMUM_TARGET_TEMPERATURE 10U ///< Minimum allowed target temperature for the heaters. -#define MAXIMUM_TARGET_TEMPERATURE 90U ///< Maximum allowed target temperature for the heaters. +#define MINIMUM_TARGET_TEMPERATURE 10U ///< Minimum allowed target temperature for the heaters. +#define MAXIMUM_TARGET_TEMPERATURE 90U ///< Maximum allowed target temperature for the heaters. -/// Heaters are on but there is no sufficient flow timeout in counts. -#define HEATERS_ON_WITH_NO_FLOW_TIMEOUT_COUNT ( ( 3 * MS_PER_SECOND ) / TASK_PRIORITY_INTERVAL ) +#define HEATERS_ON_WITH_NO_FLOW_TIMEOUT_COUNT ( ( 3 * MS_PER_SECOND ) / TASK_PRIORITY_INTERVAL ) ///< Heaters are on but there is no sufficient flow timeout in counts. + /// Heaters self-test enums typedef enum heaters_self_test_states { Index: firmware/App/Controllers/Heaters.h =================================================================== diff -u -r304797ba69ef356e1e9436f81a624c01126d6cd1 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 304797ba69ef356e1e9436f81a624c01126d6cd1) +++ firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -32,6 +32,8 @@ * @{ */ +// ********** Public definitions ********** + #pragma pack(push,1) /// Target temperature data structure. @@ -58,7 +60,7 @@ #pragma pack(pop) -// ********** public function prototypes ********** +// ********** Public function prototypes ********** void initHeaters( void ); Index: firmware/App/Controllers/LoadCell.h =================================================================== diff -u -r484b185f0cf4b2ea0ba9de331573952b1b5124b4 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 484b185f0cf4b2ea0ba9de331573952b1b5124b4) +++ firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -31,6 +31,17 @@ // ********** public definitions ********** +#pragma pack(push,1) +/// Loadcell measurements struct. +typedef struct +{ + F32 loadCellA1inGram; ///< Loadcell A1 measurement in gram + F32 loadCellA2inGram; ///< Loadcell A2 measurement in gram + F32 loadCellB1inGram; ///< Loadcell B1 measurement in gram + F32 loadCellB2inGram; ///< Loadcell B2 measurement in gram +} LOAD_CELL_DATA_T; +#pragma pack(pop) + // ********** public function prototypes ********** void initLoadCell( void ); // Initialize the LoadCell module. Index: firmware/App/Controllers/Pressures.h =================================================================== diff -u -rc1ef106ed0f97dc998230c6e154aa2362aa476d8 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/Pressures.h (.../Pressures.h) (revision c1ef106ed0f97dc998230c6e154aa2362aa476d8) +++ firmware/App/Controllers/Pressures.h (.../Pressures.h) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -29,7 +29,18 @@ * @{ */ -// ********** public definitions ********** +// ********** public definitions ********** + +#pragma pack(push,1) +/// Pressure data struct. +typedef struct +{ + F32 roPumpInletPressure; ///< RO pump inlet pressure + F32 roPumpOutletPressure; ///< RO pump outlet pressure + F32 drainPumpInletPressure; ///< Drain pump inlet pressure + F32 drainPumpOutletPressure; ///< Drain pump outlet pressure +} PRESSURES_DATA_T; +#pragma pack(pop) /// Enumeration of pressure sensors monitored by this module. typedef enum PressureSensors Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r9f3943dcab5881216ef0119e7de3a36668dea3bc -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 9f3943dcab5881216ef0119e7de3a36668dea3bc) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -474,15 +474,6 @@ F32 flowRateDeviation = fabs( targetFlowRate - actualFlowRate ) / targetFlowRate; BOOL isFlowOutOfRange = flowRateDeviation > ROP_FLOW_TARGET_TOLERANCE; - // If the ramp up persistent alarm is active, turn off the pump and go to off state - /*if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_RO_PUMP_RAMP_UP_TO_FLOW_TIMEOUT, isFlowOutOfRange ) ) - { - stopROPump(); - result = RO_PUMP_OFF_STATE; - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_RO_PUMP_RAMP_UP_TO_FLOW_TIMEOUT, actualFlowRate, MAX_ALLOWED_RAMP_UP_TIME ); - }*/ - // Control at set interval - //else if ( ++roControlTimerCounter >= ROP_RAMP_UP_CONTROL_INTERVAL ) if ( ++roControlTimerCounter >= ROP_RAMP_UP_CONTROL_INTERVAL ) { F32 targetPressure = getTargetROPumpPressure(); Index: firmware/App/DGCommon.h =================================================================== diff -u -rf68e01a2daee6cb88bb54816aee56668d662bcd4 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision f68e01a2daee6cb88bb54816aee56668d662bcd4) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -44,6 +44,7 @@ // #define HEATERS_DEBUG 1 // #define PRESSURES_DEBUG 1 #define DISABLE_DIALYSATE_CHECK 1 + #define IGNORE_DRAIN_PUMP_MONITOR 1 #include #include #endif @@ -61,6 +62,20 @@ // **** Common Definitions **** +#pragma pack(push,1) +/// DG version struct. +typedef struct +{ + U08 major; ///< DG version major revision + U08 minor; ///< DG version major revision + U08 micro; ///< DG version micro revision + U16 build; ///< DG build version + U08 fpgaId; ///< DG FPGA ID + U08 fpgaMajor; ///< DG FPGA major revision + U08 fpgaMinor; ///< DG FPGA minor revision + U08 fpgaLab; ///< DG FPGA lab revision +} DG_VERSIONS_T; +#pragma pack(pop) // **** Common Macros **** Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r304797ba69ef356e1e9436f81a624c01126d6cd1 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 304797ba69ef356e1e9436f81a624c01126d6cd1) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -39,63 +39,62 @@ // ********** private definitions ********** // General defines -#define MAX_ALLOWED_STATE_TRIALS 1 ///< Max allowed trials on a state. This is general among all the states. -#define HEAT_DISINFECT_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Mode Heat Disinfect data publish interval in counts. +#define MAX_ALLOWED_STATE_TRIALS 1 ///< Max allowed trials on a state. This is general among all the states. +#define HEAT_DISINFECT_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Mode Heat Disinfect data publish interval in counts. // Start state defines -#define MIN_INLET_PRESSURE_PSI 30.0 ///< Minimum water inlet pressure in psi. -#define MAX_START_STATE_TEMP_SENSORS_DIFF_C 1.0 ///< Max start state TDi and TRo difference tolerance in C. +#define MIN_INLET_PRESSURE_PSI 30.0 ///< Minimum water inlet pressure in psi. +#define MAX_START_STATE_TEMP_SENSORS_DIFF_C 1.0 ///< Max start state TDi and TRo difference tolerance in C. // Drain R1 & R2 states defines -#define DRAIN_PUMP_TARGET_RPM 1800 ///< Drain pump target RPM during drain. -#define RSRVRS_INITIAL_DRAIN_TIME_OUT_MS ( 2* 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 initial drain time out in milliseconds. -#define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 6 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. +#define DRAIN_PUMP_TARGET_RPM 1800 ///< Drain pump target RPM during drain. +#define RSRVRS_INITIAL_DRAIN_TIME_OUT_MS ( 2* SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 initial drain time out in milliseconds. +#define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 6 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. // Flush drain path state defines -#define FLUSH_DRAIN_WAIT_TIME_MS ( 60 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo original time was 60 seconds -#define MIN_INLET_TEMPERATURE_C 15.0 ///< Minimum water inlet temperature in C. TODO original temperature was 25 C -#define MIN_INLET_CONDUCTIVITY_US_PER_CM 0.0 ///< Minimum water inlet conductivity in uS/cm -#define MAX_INLET_CONDUCTIVITY_US_PER_CM 2000.0 ///< Maximum water inlet conductivity in us/cm +#define FLUSH_DRAIN_WAIT_TIME_MS ( SEC_PER_MIN * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo original time was 60 seconds +#define MIN_INLET_TEMPERATURE_C 15.0 ///< Minimum water inlet temperature in C. TODO original temperature was 25 C +#define MAX_INLET_CONDUCTIVITY_US_PER_CM 2000.0 ///< Maximum water inlet conductivity in us/cm // Flush circulation path state defines -#define RO_PUMP_TARGET_FLUSH_FILL_FLOW_RATE_LPM 0.8 ///< RO pump target flow rate during flush/fill in L/min. TODO original flow was 0.8 -#define MAX_RO_PUMP_FLUSH_FILL_PRESSURE_PSI 130 ///< Maximum RO pump pressure during flush/fill states in psi. -#define FLUSH_CICRCULATION_WAIT_TIME_MS ( 30 * MS_PER_SECOND ) ///< Flush/rinse circulation path wait time in milliseconds. TODO original time was 30 seconds -#define MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C 50.0 ///< Maximum flush circulation temperature difference tolerance in C. TODO original difference was 3.0 degrees -#define NUM_OF_TEMP_SENSORS_TO_AVG 4.0 ///< Number of temperature sensors to average to check the difference. +#define RO_PUMP_TARGET_FLUSH_FILL_FLOW_RATE_LPM 0.8 ///< RO pump target flow rate during flush/fill in L/min. TODO original flow was 0.8 +#define MAX_RO_PUMP_FLUSH_FILL_PRESSURE_PSI 130 ///< Maximum RO pump pressure during flush/fill states in psi. +#define FLUSH_CICRCULATION_WAIT_TIME_MS ( 30 * MS_PER_SECOND ) ///< Flush/rinse circulation path wait time in milliseconds. TODO original time was 30 seconds +#define MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C 50.0 ///< Maximum flush circulation temperature difference tolerance in C. TODO original difference was 3.0 degrees +#define NUM_OF_TEMP_SENSORS_TO_AVG 4.0 ///< Number of temperature sensors to average to check the difference. // Flush and drain R1 and R2 -#define RSRVRS_FULL_VOL_ML 1680.0 ///< Reservoirs 1 & 2 full volume in mL. TODo original value was 1900 -#define RSRVRS_PARTIAL_FILL_VOL_ML 500.0 ///< Reservoirs 1 & 2 partial volume in mL. -#define RSRVRS_FULL_STABLE_TIME_COUNT ( ( 4 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Reservoirs 1 & 2 full stable time in counts. -#define RSRVRS_FILL_UP_TIMEOUT_MS ( 5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 full fill up timeout in ms. TODO original value was 5 mins -#define RSRVRS_500ML_FILL_UP_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 partial fill up timeout in ms. -#define RSRVRS_DRAIN_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 drain timeout in ms. +#define RSRVRS_FULL_VOL_ML 1680.0 ///< Reservoirs 1 & 2 full volume in mL. TODo original value was 1900 +#define RSRVRS_PARTIAL_FILL_VOL_ML 500.0 ///< Reservoirs 1 & 2 partial volume in mL. +#define RSRVRS_FULL_STABLE_TIME_COUNT ( ( 4 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Reservoirs 1 & 2 full stable time in counts. +#define RSRVRS_FILL_UP_TIMEOUT_MS ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 full fill up timeout in ms. TODO original value was 5 mins +#define RSRVRS_500ML_FILL_UP_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 partial fill up timeout in ms. +#define RSRVRS_DRAIN_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 drain timeout in ms. // Fill and heat water -#define HEAT_DISINFECT_TARGET_TEMPERATURE_C 85.0 ///< Heat disinfect target water temperature in C. TODO original temperature was 85.0 -#define HEAT_DISINFECT_START_TEMPERATURE_C 81.0 ///< Heat disinfect minimum acceptable temperature in C. TODO original temperature was 81.0 +#define HEAT_DISINFECT_TARGET_TEMPERATURE_C 85.0 ///< Heat disinfect target water temperature in C. TODO original temperature was 85.0 +#define HEAT_DISINFECT_START_TEMPERATURE_C 81.0 ///< Heat disinfect minimum acceptable temperature in C. TODO original temperature was 81.0 // R1 to R2 & R2 to R1 heat disinfect circulation -#define HEAT_DISINFECT_TARGET_RO_FLOW_LPM 0.9 ///< Heat disinfect target RO flow rate in L/min. TODO original value was 0.8 -#define HEAT_DISINFECT_MAX_RO_PRESSURE_PSI 30 ///< Heat disinfect maximum RO pressure in psi. -#define HEAT_DISINFECT_TARGET_DRAIN_PRES_PSI 10.0 ///< Heat disinfect target drain outlet pressure in psi. -#define HEAT_DISINFECT_TIME_MS ( 5 * 60 * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes -#define HEAT_DISINFECT_START_TEMP_TIMOUT_MS ( 4 * 60 * 60 * MS_PER_SECOND ) ///< Heat disinfect reaching to minimum temperature timeout in milliseconds. TODO figure out this timeout -#define RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 maximum volume out of range timeout during heat disinfect. TODO change this to 5 seconds -#define RSRVRS_MAX_TARGET_VOL_CHANGE_ML 500.0 ///< Reservoirs 1 & 2 maximum allowed volume change when full during heat disinfect. TODO original value is 100 mL -#define POST_HEAT_DISINFECT_WAIT_TIME_MS ( 3 * 60 * MS_PER_SECOND ) ///< Heat disinfect final wait time before flushing the system in milliseconds. +#define HEAT_DISINFECT_TARGET_RO_FLOW_LPM 0.9 ///< Heat disinfect target RO flow rate in L/min. TODO original value was 0.8 +#define HEAT_DISINFECT_MAX_RO_PRESSURE_PSI 30 ///< Heat disinfect maximum RO pressure in psi. +#define HEAT_DISINFECT_TARGET_DRAIN_PRES_PSI 10.0 ///< Heat disinfect target drain outlet pressure in psi. +#define HEAT_DISINFECT_TIME_MS ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes +#define HEAT_DISINFECT_START_TEMP_TIMOUT_MS ( 4 * MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ) ///< Heat disinfect reaching to minimum temperature timeout in milliseconds. TODO figure out this timeout +#define RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ( 0.5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 maximum volume out of range timeout during heat disinfect. TODO change this to 5 seconds +#define RSRVRS_MAX_TARGET_VOL_CHANGE_ML 500.0 ///< Reservoirs 1 & 2 maximum allowed volume change when full during heat disinfect. TODO original value is 100 mL +#define POST_HEAT_DISINFECT_WAIT_TIME_MS ( 3 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heat disinfect final wait time before flushing the system in milliseconds. // Mix drain R1 and R2 -#define RSRVRS_MIX_DRAIN_TIMEOUT_MS ( 20 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 mix drain timeout in ms. -#define DRAIN_PUMP_START_TIME_IN_MIX_DRAIN_MS ( 5 * MS_PER_SECOND ) ///< Time to start the drain pump at mix drain after directing the flow to drain in ms. -#define DRAIN_PUMP_RPM_IN_MIX_DRAIN 600 ///< The RPM that the drain pump should be run during mix drain. +#define RSRVRS_MIX_DRAIN_TIMEOUT_MS ( 20 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 mix drain timeout in ms. +#define DRAIN_PUMP_START_TIME_IN_MIX_DRAIN_MS ( 5 * MS_PER_SECOND ) ///< Time to start the drain pump at mix drain after directing the flow to drain in ms. +#define DRAIN_PUMP_RPM_IN_MIX_DRAIN 600 ///< The RPM that the drain pump should be run during mix drain. // Rinse R1 to R2 -#define ROF_MIN_LOW_PRESSURE_TEMPERATURE_C 45.0 ///< RO filter minimum temperature that the pressure must be no more than 30psi in C. TODO the actual value is 45.0 +#define ROF_MIN_LOW_PRESSURE_TEMPERATURE_C 45.0 ///< RO filter minimum temperature that the pressure must be no more than 30psi in C. TODO the actual value is 45.0 // Cancellation paths -#define MIX_DRAIN_TEMPERATURE_THRESHOLD_C 60.0 ///< Temperature threshold for performing mix drain or normal drain. +#define MIX_DRAIN_TEMPERATURE_THRESHOLD_C 60.0 ///< Temperature threshold for performing mix drain or normal drain. /// Cancellation paths typedef enum Cancellation_modes @@ -406,7 +405,7 @@ F32 TDiTemp = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); //TODo change to TDi F32 TRoTemp = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); - // If the inlet pressure is less than the threshold or TDi and TRo difference is greater than 1 C, the cycle + // If the inlet pressure is less than the threshold and TDi and TRo difference is greater than 1 C, the cycle // should be canceled if ( ppiPressure < MIN_INLET_PRESSURE_PSI && fabs( TDiTemp - TRoTemp ) > MAX_START_STATE_TEMP_SENSORS_DIFF_C ) { @@ -551,12 +550,11 @@ DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_FLUSH_DRAIN; // Check if flush time has elapsed - if ( didTimeout( stateTimer, FLUSH_DRAIN_WAIT_TIME_MS ) ) + if ( TRUE == didTimeout( stateTimer, FLUSH_DRAIN_WAIT_TIME_MS ) ) { // If the inlet temperature and conductivity are in range, move onto the next state - if ( getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ) > MIN_INLET_TEMPERATURE_C && - getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ) > MIN_INLET_CONDUCTIVITY_US_PER_CM && - getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ) <= MAX_INLET_CONDUCTIVITY_US_PER_CM ) + if ( ( getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ) > MIN_INLET_TEMPERATURE_C ) && + ( getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ) <= MAX_INLET_CONDUCTIVITY_US_PER_CM ) ) { setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLUSH_FILL_FLOW_RATE_LPM, MAX_RO_PUMP_FLUSH_FILL_PRESSURE_PSI ); @@ -565,8 +563,9 @@ state = DG_HEAT_DISINFECT_STATE_FLUSH_CIRCULATION; } // If the number of failures have not exceeded the limit, try again. - else if ( ++stateTrialCounter < MAX_ALLOWED_STATE_TRIALS ) + else if ( stateTrialCounter < MAX_ALLOWED_STATE_TRIALS ) { + stateTrialCounter++; stateTimer = getMSTimerCount(); } // Couldn't get a good water sample after a couple of trials and the disinfect cycle failed @@ -599,21 +598,21 @@ DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_FLUSH_CIRCULATION; // Check if the flush circulation time has elapsed and the temperature sensors are not in range yet - if ( didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) && ( FALSE == areTempSensorsInRange ) ) + if ( TRUE == didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) && ( FALSE == areTempSensorsInRange ) ) { F32 ThdTemp = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); // TODO add THd later. This is the new temp sensor of the coldest spot. F32 TPoTemp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); F32 TD1Temp = getTemperatureValue( TEMPSENSORS_CONDUCTIVITY_SENSOR_1 ); F32 TD2Temp = getTemperatureValue( TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); F32 avgTemp = ( ThdTemp + TPoTemp + TD1Temp + TD2Temp ) / NUM_OF_TEMP_SENSORS_TO_AVG; - BOOL isThdOut = fabs( ThdTemp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C; - BOOL isTPoOut = fabs( TPoTemp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C; - BOOL isTD1Out = fabs( TD1Temp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C; - BOOL isTD2Out = fabs( TD2Temp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C; + BOOL isThdOut = ( fabs( ThdTemp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C ? TRUE : FALSE ); + BOOL isTPoOut = ( fabs( TPoTemp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C ? TRUE : FALSE ); + BOOL isTD1Out = ( fabs( TD1Temp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C ? TRUE : FALSE ); + BOOL isTD2Out = ( fabs( TD2Temp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C ? TRUE : FALSE ); // Check if any of the temperature sensors are out of tolerance - if( TRUE == isThdOut || TRUE == isTPoOut || TRUE == isTD1Out || TRUE == isTD2Out ) + if( ( TRUE == isThdOut ) || ( TRUE == isTPoOut ) || ( TRUE == isTD1Out ) || ( TRUE == isTD2Out ) ) { // Check if we have exceeded the number of trials. If not, try another time if ( ++stateTrialCounter < MAX_ALLOWED_STATE_TRIALS ) @@ -640,7 +639,7 @@ if ( TRUE == areTempSensorsInRange ) { // TODO: enable the timeout once the concentrate pumps are available. - //if ( didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) + //if ( TRUE == didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) if ( TRUE ) { rsrvr1Status = DG_RESERVOIR_BELOW_TARGET; @@ -1055,7 +1054,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_COOL_DOWN_HEATERS; - if ( didTimeout( stateTimer, POST_HEAT_DISINFECT_WAIT_TIME_MS ) ) + if ( TRUE == didTimeout( stateTimer, POST_HEAT_DISINFECT_WAIT_TIME_MS ) ) { // Stop the drain pump and the RO pump to exit the closed loop signalDrainPumpHardStop(); @@ -1127,14 +1126,14 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_MIX_DRAIN_R1; - if ( didTimeout( stateTimer, DRAIN_PUMP_START_TIME_IN_MIX_DRAIN_MS ) && isDrainPumpInMixDrainOn == FALSE ) + if ( TRUE == didTimeout( stateTimer, DRAIN_PUMP_START_TIME_IN_MIX_DRAIN_MS ) && isDrainPumpInMixDrainOn == FALSE ) { isDrainPumpInMixDrainOn = TRUE; // Turn on the drain pump to drain the reservoirs in open loop mode setDrainPumpTargetRPM( DRAIN_PUMP_RPM_IN_MIX_DRAIN ); } - else if ( isDrainPumpInMixDrainOn == TRUE ) + else if ( TRUE == isDrainPumpInMixDrainOn ) { if ( DG_RESERVOIR_ABOVE_TARGET == rsrvr1Status ) { @@ -1319,7 +1318,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_RINSE_CIRCULATION; - if ( didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) + if ( TRUE == didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) { state = DG_HEAT_DISINFECT_STATE_COMPLETE; } @@ -1366,7 +1365,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH; - if ( cancellationMode == CANCELLATION_MODE_NONE ) + if ( CANCELLATION_MODE_NONE == cancellationMode ) { U32 targetRPM = 0; @@ -1535,7 +1534,7 @@ stateTimer = getMSTimerCount(); } } - else if ( didTimeout( stateTimer, timeout ) ) + else if ( TRUE == didTimeout( stateTimer, timeout ) ) { // Failed to fill ontime. Update the previous heat disinfect state and transition to basic cancellation alarm = ALARM_ID_DG_RESERVOIR_FILL_TIMEOUT; @@ -1572,7 +1571,7 @@ stateTimer = getMSTimerCount(); status = DG_RESERVOIR_REACHED_TARGET; } - else if ( didTimeout( stateTimer, timeout ) ) + else if ( TRUE == didTimeout( stateTimer, timeout ) ) { // Failed to drain on time. Update the previous heat disinfect state and transition to basic cancellation alarm = ALARM_ID_DG_RESERVOIR_DRAIN_TIMEOUT; @@ -1615,7 +1614,7 @@ rsrvrsVolMonitorTimer = getMSTimerCount(); } // If the volume is out of range and it has timed out, exit - else if ( didTimeout( rsrvrsVolMonitorTimer, RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ) ) + else if ( TRUE == didTimeout( rsrvrsVolMonitorTimer, RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ) ) { areRsrvrsLeaking = FALSE; alarm = ALARM_ID_DG_RESERVOIR_LEAK_TIMEOUT; @@ -1636,7 +1635,7 @@ heatDisinfectTimer = getMSTimerCount(); isPartialDisinfectInProgress = FALSE; - if ( didTimeout( stateTimer, HEAT_DISINFECT_START_TEMP_TIMOUT_MS ) ) + if ( TRUE == didTimeout( stateTimer, HEAT_DISINFECT_START_TEMP_TIMOUT_MS ) ) { // Heating up to minimum temperature for heat disinfect failed alarm = ALARM_ID_DG_HEAT_DISINFECT_TARGET_TEMP_TIMEOUT; @@ -1651,7 +1650,7 @@ } // If heat disinfect temperature has been reached, check if this stage of heat disinfect is done - if ( isPartialDisinfectInProgress && didTimeout( heatDisinfectTimer, HEAT_DISINFECT_TIME_MS ) ) + if ( ( TRUE == isPartialDisinfectInProgress ) && ( TRUE == didTimeout( heatDisinfectTimer, HEAT_DISINFECT_TIME_MS ) ) ) { // Done with this stage of heat disnfect. Reset the variables status = HEAT_DISINFECT_COMPLETE; @@ -1683,7 +1682,7 @@ data.R2FillLevel = R2HeatDisinfectVol; // If the mode is in the actual heat disinfect states, publish the elapsed time, otherwise publish 0 to avoid confusion - if ( heatDisinfectState == DG_HEAT_DISINFECT_STATE_DISINFECT_R1_TO_R2 || heatDisinfectState == DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1 ) + if ( DG_HEAT_DISINFECT_STATE_DISINFECT_R1_TO_R2 == heatDisinfectState || DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1 == heatDisinfectState ) { data.heatDisinfectElapsedTime = calcTimeSince( heatDisinfectTimer ); } Fisheye: Tag 5c967dc311b485769e50e5e4f122be21079b5ae9 refers to a dead (removed) revision in file `firmware/App/Services/MessagePayloads.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -r304797ba69ef356e1e9436f81a624c01126d6cd1 -r5c967dc311b485769e50e5e4f122be21079b5ae9 --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 304797ba69ef356e1e9436f81a624c01126d6cd1) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) @@ -48,6 +48,14 @@ U32 rejectCode; ///< Reason code for rejecting the command } DG_CMD_RESPONSE_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 +} RESERVOIR_DATA_T; + #pragma pack(pop) // ********** public function prototypes **********