Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -rbe4507c7fef6c9d987eba9e34369402e989e962e -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision be4507c7fef6c9d987eba9e34369402e989e962e) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -53,7 +53,9 @@ #define CONCENTRATE_PUMP_VOLUME_PER_PULSE ( CONCENTRATE_PUMP_VOLUME_PER_REV / CONCENTRATE_PUMP_PULSE_PER_REV ) #define CONCENTRATE_PUMP_DATA_PUBLISH_INTERVAL ( 500 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the concentrate pump is monitored. + #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. Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -176,6 +176,7 @@ { if( heater < NUM_OF_DG_HEATERS ) { +#ifndef DISABLE_HEATERS_AND_TEMPS // Assume the target temperature has not changed heatersStatus[ heater ].hasTargetTempChanged = FALSE; @@ -186,6 +187,7 @@ heatersStatus[ heater ].hasTargetTempChanged = TRUE; // TODO alarm if temperature if out of range or just reject? } +#endif } else { @@ -217,13 +219,16 @@ { BOOL status = FALSE; + if( heater < NUM_OF_DG_HEATERS ) { +#ifndef DISABLE_HEATERS_AND_TEMPS if ( TRUE == heatersStatus[ heater ].hasTargetTempChanged ) { status = TRUE; heatersStatus[ heater ].startHeaterSignal = TRUE; } +#endif } else { @@ -901,12 +906,12 @@ if ( trimmerHeaterInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) { isTempOut = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, trimmerHeaterInternalTemp ); + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, trimmerHeaterInternalTemp ); } else if ( trimmerHeaterColdJunctionTemp > HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C ) { isTempOut = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_CJ_TEMP_OUT_OF_RANGE, trimmerHeaterColdJunctionTemp ); + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_CJ_TEMP_OUT_OF_RANGE, trimmerHeaterColdJunctionTemp ); } #ifndef IGNORE_HEATERS_MONITOR Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -94,7 +94,7 @@ * @details Outputs: LoadCell module initialized. * @return none *************************************************************************/ - void initLoadCell( void ) +void initLoadCell( void ) { U32 i; U32 j; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -358,18 +358,18 @@ flow = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); + // Apply calibration to flow sensor reading 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 + - flow * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + + flow * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; - // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that - // the flow is 0. - if ( FLOW_SENSOR_ZERO_READING == roFlowReading ) - { - measuredROFlowRateLPM.data = 0.0; - } + // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that the flow is 0. + if ( FLOW_SENSOR_ZERO_READING == roFlowReading ) + { + measuredROFlowRateLPM.data = 0.0; + } measuredFlowReadingsSum = 0; flowFilterCounter = 0; Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -94,15 +94,15 @@ switch ( i ) { case CONCENTRATE_CAP: - currentSwitchStatus = ( getFPGAConcentrateCapStatus() != 0 ? STATE_OPEN : STATE_CLOSED ); + currentSwitchStatus = getFPGAConcentrateCapStatus(); break; case DIALYSATE_CAP: - currentSwitchStatus = ( getFPGADialysateCapStatus() != 0 ? STATE_OPEN : STATE_CLOSED ); + currentSwitchStatus = getFPGADialysateCapStatus(); break; case FLUID_DOOR: - currentSwitchStatus = ( getFPGAGFluidDoorStatus() != 0 ? STATE_OPEN : STATE_CLOSED ); + currentSwitchStatus = getFPGAGFluidDoorStatus(); break; default: Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -165,7 +165,7 @@ static BOOL isADCReadValid( U32 sensorIndex, U32 fpgaError, U32 fpgaCount ); static void processADCRead( U32 sensorIndex, S32 adc ); static void publishTemperatureSensorsData( void ); -static void monitorTemperatureSnsrs( U32 sensorIndex ); +static void monitorTemperatureSnsrs( U32 sensorIndex, F32 temperature ); /*********************************************************************//** * @brief @@ -381,7 +381,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( OVERRIDE_KEY == tempSensors[ sensorIndex ].temperatureValues.override ) + if ( tempSensors[ sensorIndex ].temperatureValues.override == OVERRIDE_KEY ) { temperature = tempSensors[ sensorIndex ].temperatureValues.ovData; } @@ -721,7 +721,7 @@ tempSensors[ sensorIndex ].temperatureValues.data = temperature; // Monitor the temperature value - monitorTemperatureSnsrs( sensorIndex ); + monitorTemperatureSnsrs( sensorIndex, temperature ); } /*********************************************************************//** @@ -888,14 +888,17 @@ * @details Inputs: tempSensors * @details Outputs: tempSensors * @param sensorIndex the index of the temperature sensor + * @param temperature the temperature value to be checked * @return none *************************************************************************/ -static void monitorTemperatureSnsrs( U32 sensorIndex ) +static void monitorTemperatureSnsrs( U32 sensorIndex, F32 temperature ) { - F32 temperature = getTemperatureValue( sensorIndex ); + // The maximum allowed temperature is different for the sensors that are in the fluid path + // with the ones that are not in the fluid path + F32 maxLimit = tempSensors[ sensorIndex ].maxAllowedTemperature; // Check both temperature and to be in range - if ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorIndex ].maxAllowedTemperature ) ) + if ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > maxLimit ) ) { // TODO investigate //checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_OUT_OF_RANGE, TRUE, sensorIndex, temperature ); @@ -924,7 +927,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensors[ sensorIndex ].temperatureValues.ovData = temperature; @@ -950,7 +953,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensors[ sensorIndex ].temperatureValues.override = OVERRIDE_RESET; @@ -974,7 +977,7 @@ { BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { U32 interval = value / TASK_PRIORITY_INTERVAL; @@ -998,7 +1001,7 @@ { BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensorsPublishInterval.override = OVERRIDE_RESET; Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -39,7 +39,8 @@ #define THERMISTOR_REFERENCE_VOLTAGE 3.0 ///< Thermistors source voltage. #define THERMISTOR_REFERENCE_RESISTOR_AT_25 10000.0 ///< Thermistors reference resistor in ohms. #define THERMISTOR_REFERENCE_TEMPERATURE 298.0 ///< Thermistors reference temperature in kelvin. -#define THERMISTOR_BETA_VALUE 3380.0 ///< Thermistors beta value. +#define ONBOARD_THERMISTOR_BETA_VALUE 3380.0 ///< Onboard thermistor beta value. +#define POWER_SUPPLY_THERMISTOR_BETA_VALUE 3345.0 ///< Power supply beta value. #define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. #define MIN_ALLOWED_TEMPERATURE 0.0 ///< Thermistors/sensors minimum allowed temperature reading. #define MAX_ALLOWED_TEMPERATURE 80.0 ///< Thermistors/sensors maximum allowed temperature reading. @@ -48,16 +49,17 @@ /// Thermistors exec states typedef enum thermistors_Exec_States { - THERMISTORS_EXEC_STATE_START_STATE = 0, ///< Thermistors exec state start state. - THERMISTORS_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Thermistors exec state get ADC values state. - NUM_OF_THERMISTORS_EXEC_STATES, ///< Number of thermistors exec state. + THERMISTORS_EXEC_STATE_START_STATE = 0, ///< Thermistors exec state start state + THERMISTORS_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Thermistors exec state get ADC values state + NUM_OF_THERMISTORS_EXEC_STATES, ///< Number of thermistors exec state } THERMISTORS_EXEC_STATES_T; /// Thermistor struct typedef struct { - S32 rawADCRead; ///< Thermistor raw ADC read. - OVERRIDE_F32_T temperatureValue; ///< Thermistor temperature value. + S32 rawADCRead; ///< Thermistor raw ADC read + OVERRIDE_F32_T temperatureValue; ///< Thermistor temperature value + F32 betaValue; ///< Thermistor beta value used to calculate temperature } THERMISTOR_T; static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; ///< Thermistors exec state. @@ -68,8 +70,8 @@ static U32 adcReadCounter; ///< Thermistors ADC read counter. static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / - (F32)TWELVE_BIT_RESOLUTION; ///< Thermistors ADC to voltage conversion coefficient. -static const F32 THERMISTOR_REF_TEMP_INV = 1 / THERMISTOR_REFERENCE_TEMPERATURE; ///< Thermistors reference inverse. + (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. +static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. // ********** private function prototypes ********** @@ -78,7 +80,7 @@ static void monitorThermistors( void ); static void convertADC2Temperature( void ); -static F32 calculateThemristorTemperature( U32 adcValue ); +static F32 calculateOnBoardThemristorTemperature( U32 adcValue, F32 betaValue ); static void publishThermistorsData( void ); /*********************************************************************//** @@ -94,6 +96,11 @@ thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; dataPublishCounter = 0; + // Initialize the beta values of each thermistor + thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].betaValue = ONBOARD_THERMISTOR_BETA_VALUE; + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].betaValue = POWER_SUPPLY_THERMISTOR_BETA_VALUE; + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].betaValue = POWER_SUPPLY_THERMISTOR_BETA_VALUE; + // Initialize a persistent alarm for thermistors temeprature out of range initPersistentAlarm( ALARM_ID_DG_THERMISTORS_TEMPERATURE_OUT_OF_RANGE, MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD, MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD ); } @@ -142,15 +149,6 @@ break; } - // First convert the values - convertADC2Temperature(); - - // Monitor the values for a gross range check - // Monitor is called in this function because this driver is constantly reading - // the thermistor values. Also the internal ADC values are processed with moving average in the internalADC driver - // So the thermistors drivers just gets the latest ADC value and converts it to temperature - monitorThermistors(); - // Check if it is time to publish any data publishThermistorsData(); } @@ -171,7 +169,7 @@ // Check if the thermistor of sensor is in range if ( thermistor < NUM_OF_THERMISTORS ) { - if ( OVERRIDE_KEY == thermistorsStatus[ thermistor ].temperatureValue.override ) + if ( thermistorsStatus[ thermistor ].temperatureValue.override == OVERRIDE_KEY ) { temperature = thermistorsStatus[ thermistor ].temperatureValue.ovData; } @@ -230,6 +228,12 @@ thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_1_THERMISTOR ); thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_2_THERMISTOR ); + // Monitor the values for a gross range check + // Monitor is called in this function because this driver is constantly reading + // the thermistor values. Also the internal ADC values are processed with moving average in the internalADC driver + // So the thermistors drivers just gets the latest ADC value and converts it to temperature + monitorThermistors(); + // Zero the counter for the next round of reading adcReadCounter = 0; } @@ -250,10 +254,13 @@ THERMISTORS_TEMP_SENSORS_T thermistor; F32 temperature; + // First convert the values + convertADC2Temperature(); + for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) { temperature = getThermistorTemperatureValue( thermistor ); - BOOL isTempOutOfRange = ( temperature > MAX_ALLOWED_TEMPERATURE ) || ( temperature < MIN_ALLOWED_TEMPERATURE ); + BOOL const isTempOutOfRange = ( temperature > MAX_ALLOWED_TEMPERATURE ) || ( temperature < MIN_ALLOWED_TEMPERATURE ); checkPersistentAlarm( ALARM_ID_DG_THERMISTORS_TEMPERATURE_OUT_OF_RANGE, isTempOutOfRange, temperature, MAX_ALLOWED_TEMPERATURE ); } @@ -263,55 +270,59 @@ * @brief * The convertADCtoTemperature function converts the ADC values of different * thermistors and temperature sensors to temperature value. - * @details Inputs: none + * @details Inputs: thermistorsStatus, fpgaBoardTempSensorConvCoeff, + * adcTempSensorsConversionCoeff1, adcTempSensorsConversionCoeff2 * @details Outputs: thermistorsStatus * @return none *************************************************************************/ static void convertADC2Temperature( void ) { THERMISTORS_TEMP_SENSORS_T thermistor; F32 temperature; - S32 rawADC; + U32 rawADC; // Loop through the list and update the temperature values for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) { - rawADC = (S32)thermistorsStatus[ thermistor ].rawADCRead; + rawADC = thermistorsStatus[ thermistor ].rawADCRead; - temperature = calculateThemristorTemperature( rawADC ); + temperature = calculateOnBoardThemristorTemperature( rawADC, thermistorsStatus[ thermistor ].betaValue ); thermistorsStatus[ thermistor ].temperatureValue.data = temperature; } } /*********************************************************************//** * @brief - * The calculateThemristorTemperature function converts the ADC value - * of thermistors into temperature in C. Below are the calculation + * The calculateOnBoardThemristorTemperature function converts the ADC value + * of the onboard thermistor into temperature in C. Below are the calculation * steps: * voltage = ADC x 3 / 2^12 * voltage = 3 x 10 / ( 10 + R(T) ) * R(T) = 10000 x e^(beta x (1/T - 1/298)) * Solve for T which is temperature in Kelvin - * @details Inputs: none + * @details Inputs: onBoardThermistorVoltageConvCoeff, + * onBoardThermistorBetaValueInv * @details Outputs: none * @param ADC value to be converted into temperature in C + * @param beta value which is used to calculate temperature from ADC * @return calculated temperature in C *************************************************************************/ -static F32 calculateThemristorTemperature( U32 adcValue ) +static F32 calculateOnBoardThemristorTemperature( U32 adcValue, F32 betaValue ) { // Voltage = ADC x 3 / 2^12 for 12 bits resolution and a 3V ADC // The value of 3 / 2^12 has been calculated in a const to prevent the division again - F32 thermistorVoltage = adcValue * THERMISTOR_VOLTAGE_CONV_COEFF; + F32 const thermistorVoltage = adcValue * THERMISTOR_VOLTAGE_CONV_COEFF; // Calculate the thermistor resistor by solving: thermistorVoltage = (3 x 10) / (10 + R(T)) - F32 thermistorResistor = ( ( THERMISTOR_REFERENCE_RESISTOR_AT_25 * THERMISTOR_REFERENCE_VOLTAGE ) - - ( THERMISTOR_REFERENCE_RESISTOR_AT_25 * thermistorVoltage ) ) / thermistorVoltage; + F32 const thermistorResistor = ( ( THERMISTOR_REFERENCE_RESISTOR_AT_25 * THERMISTOR_REFERENCE_VOLTAGE ) - + ( THERMISTOR_REFERENCE_RESISTOR_AT_25 * thermistorVoltage ) ) / thermistorVoltage; // 1/T = Ln(thermistorResistor/10000)/3380 + 1/298 - F32 invTemperature = ( logf( thermistorResistor / THERMISTOR_REFERENCE_RESISTOR_AT_25 ) / THERMISTOR_BETA_VALUE ) + THERMISTOR_REF_TEMP_INV; + F32 const invTemperature = ( logf( thermistorResistor / THERMISTOR_REFERENCE_RESISTOR_AT_25 ) / betaValue ) + + ON_BOARD_THERMISTOR_REF_TEMP_INV; // Inverse the value to get the temperature in Kelvin and then convert it to Celsius - F32 temperature = ( 1 / invTemperature ) - CELSIUS_TO_KELVIN_CONVERSION; + F32 const temperature = ( 1 / invTemperature ) - CELSIUS_TO_KELVIN_CONVERSION; return temperature; } @@ -411,11 +422,11 @@ { BOOL result = FALSE; - if ( ( thermistor < NUM_OF_THERMISTORS ) && ( TRUE == isTestingActivated() ) ) + if ( thermistor < NUM_OF_THERMISTORS && isTestingActivated() ) { // There is a temperature range that the thermistors can be set to, otherwise, the driver // will throw an alarm. Also, the fans driver depends on these values to continuously control the fans - if ( ( temperature >= MIN_ALLOWED_TEMPERATURE ) && ( temperature < MAX_ALLOWED_TEMPERATURE ) ) + if ( temperature >= MIN_ALLOWED_TEMPERATURE && temperature < MAX_ALLOWED_TEMPERATURE ) { result = TRUE; thermistorsStatus[ thermistor ].temperatureValue.ovData = temperature; @@ -439,7 +450,7 @@ { BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { if ( thermistor < NUM_OF_THERMISTORS ) { Index: firmware/App/DGCommon.h =================================================================== diff -u -r0a040a300ce592c2a7cfc095d20f6ddc31036a54 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision 0a040a300ce592c2a7cfc095d20f6ddc31036a54) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -25,7 +25,7 @@ #define DG_VERSION_MAJOR 0 #define DG_VERSION_MINOR 6 #define DG_VERSION_MICRO 0 -#define DG_VERSION_BUILD 18 +#define DG_VERSION_BUILD 97 // ********** build switches ********** @@ -34,7 +34,7 @@ // TODO: Removed debug build flags when release build is ready // #define BOARD_WITH_NO_HARDWARE 1 // #define TASK_TIMING_OUTPUT_ENABLED 1 // re-purposes drain pump enable pin for task timing -// #define DISABLE_HEATERS_AND_TEMPS 1 +// #define DISABLE_HEATERS_AND_TEMPS 1 // #define DISABLE_ACCELS 1 // #define SKIP_POST 1 #define SKIP_CAL_CHECK 1 @@ -53,12 +53,13 @@ #define THD_USING_TRO_CONNECTOR 1 #define DISABLE_FLOW_CHECK_IN_FILL 1 #define IGNORE_CONC_PUMP_IN_HEAT_DISINFECT 1 -// #define NEW_FMD_FLOW_SENSOR 1 // Turn these flags on to disable dialysate mixing #define DISABLE_DIALYSATE_CHECK 1 // Disabled for Tom // #define DISABLE_MIXING 1 //#define DISABLE_FLOW_CONTROL_TREATMENT 1 + //#define DISABLE_TRIMMER_HEATER 1 + #define DIALYSATE_FLOW_METER_ENABLED 1 #define DISABLE_ACK_ALARM 1 #include Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -62,6 +62,8 @@ static BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines. static U32 rinseConcentrateLinesTimerCtr; ///< Timer counter for rinsing concentrate lines. static U32 dialysateDrainStartTime; ///< Dialysate drain start time. +static BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines. +static U32 rinseConcentrateLinesTimerCtr; ///< Timer counter for rinsing concentrate lines. // ********** private function prototypes ********** static DG_DRAIN_STATE_T handleDrainStateStart( void ); Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -48,7 +48,6 @@ #define DIALYSATE_FILL_TIME_OUT ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time out period when reservoir is not filled with correct dialysate. #define EMPTY_BOTTLE_DETECT_PERSISTENT_PERIOD_MS ( 5 * MS_PER_SECOND ) ///< Persistent period for empty bottle detect. - #define CONCENTRATE_PUMP_PRIME_INTERVAL ( 3 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Persistent time interval for concentrate pumps prime. #define ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER 1.06 ///< Acid and bicarbonate concentrates make up around 6% to total volume. Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -49,13 +49,13 @@ #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 ( 2 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo it was 2 minutes +#define FLUSH_DRAIN_WAIT_TIME_MS ( 2 * 60 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. // Flush dialysate state defines -#define FLUSH_DIALYSATE_WAIT_TIME_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Flush dialysate wait time in milliseconds. +#define FLUSH_DIALYSATE_WAIT_TIME_MS ( 1 * 60 * MS_PER_SECOND ) ///< Flush dialysate wait time in milliseconds. // Flush concentrate straws state defines -#define FLUSH_CONCENTRATE_STRAWS_TIME_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Flush concentrate straws wait time in milliseconds. todo was 3 minutes +#define FLUSH_CONCENTRATE_STRAWS_TIME_MS ( 3 * 60 * MS_PER_SECOND ) ///< Flush concentrate straws wait time in milliseconds. #define ACID_PUMP_SPEED_ML_PER_MIN -30.0 ///< Acid pump speed in mL/min. // The bicarb pump is 2% faster than the acid pump to create a flow from acid to bicarb line during flush #define BICARB_PUMP_SPEED_ML_PER_MIN 30.6 ///< Bicarb pump speed in mL/min. @@ -303,6 +303,7 @@ // Close VPi to prevent wasting water setValveState( VPI, VALVE_STATE_CLOSED ); + // Set the actuators to drain R1 setValveState( VRD1, VALVE_STATE_OPEN ); Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -297,15 +297,15 @@ { DG_POST_STATE_T result = postState; - if ( ( SELF_TEST_STATUS_PASSED == testStatus ) || ( SELF_TEST_STATUS_FAILED == testStatus ) ) + if ( ( testStatus == SELF_TEST_STATUS_PASSED ) || ( testStatus == SELF_TEST_STATUS_FAILED ) ) { - BOOL passed = ( SELF_TEST_STATUS_PASSED == testStatus ? TRUE : FALSE ); + BOOL passed = ( testStatus == SELF_TEST_STATUS_PASSED ? TRUE : FALSE ); // Broadcast passed POST result sendPOSTTestResult( (DG_POST_STATE_T)((int)postState), passed ); // Move on to next POST test result = (DG_POST_STATE_T)((int)postState + 1); - if ( SELF_TEST_STATUS_FAILED == testStatus ) + if ( testStatus == SELF_TEST_STATUS_FAILED ) { tempPOSTPassed = FALSE; } Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -125,7 +125,6 @@ void execOperationModes( void ) { DG_OP_MODE_T newMode; - U32 priorSubMode = currentSubMode; priorSubMode = currentSubMode; @@ -144,7 +143,6 @@ if ( currentMode != newMode ) { // handle transition to new mode - priorSubMode = 0; lastMode = currentMode; transitionToNewOperationMode( newMode ); currentMode = newMode; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -82,8 +82,8 @@ #define FPGA_FLUIDLEAK_STATE_MASK 0x0004 ///< Bit mask for fluid leak detector. #define FLUID_DOOR_SWITCH_MASK 0x08 ///< Fluid door switch bit mask. -#define CONCENTRATE_CAP_SWITCH_MASK 0x10 ///< Concentrate cap switch bit mask -#define DIALYSATE_CAP_SWITCH_MASK 0x20 ///< Dialysate cap switch bit mask.. +#define DIALYSATE_CAP_SWITCH_MASK 0x10 ///< Dialysate cap switch bit mask. +#define CONCENTRATE_CAP_SWITCH_MASK 0x1A ///< Concentrate cap switch bit mask. #define FPGA_POWER_OUT_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< FPGA power out timeout in milliseconds. #define FPGA_GPIO_POWER_STATUS_PIN 7 ///< FPGA GPIO power status pin @@ -186,6 +186,7 @@ U16 fpgaFanIn3Pulse; ///< Reg 400. Fan inlet 3 pulse time in 2.5 resolution U16 fpgaFanOut3Pulse; ///< Reg 402. Fan outlet 3 pulse time in 2.5 resolution U16 fpgaTimerCount_ms; ///< Reg 404. Internal FPGA timer count in ms. + U16 fpgaADCVccInt; ///< Reg 406. Internal FPGA Vcc Voltage. U16 fpgaADCVccAux; ///< Reg 408. Internal FPGA Vcc auxiliary voltage. U16 fpgaADCVPVN; ///< Reg 410. Internal FPGA VPVN voltage. Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -1117,11 +1117,11 @@ break; case MSG_ID_FILTER_FLUSH_TIME_PERIOD_OVERRIDE: - handleFilterFlushTimePeriodOverride( message ); + handleFilterFlushTimePeriodOverride(message); break; - case MSG_ID_DG_FANS_RPM_OVERRIDE: - handleFansRPMOverride( message ); + case MSG_ID_DG_BLOCK_MESSAGE_TRANSMISSION: + handleTestBlockMessagesRequest( message ); break; case MSG_ID_DG_STOP_RTC_CLOCK: @@ -1132,10 +1132,6 @@ handleSetDrainPumpMeasuredRPMOverrideRequest( message ); break; - case MSG_ID_DG_BLOCK_MESSAGE_TRANSMISSION: - handleTestBlockMessagesRequest( message ); - break; - case MSG_ID_DG_SUPER_CLEAR_ALARMS_CMD: handleTestSuperClearAlarmsRequest( message ); break; @@ -1148,6 +1144,10 @@ handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( message ); break; + case MSG_ID_DG_FANS_RPM_OVERRIDE: + handleFansRPMOverride( message ); + break; + case MSG_ID_DG_GET_SW_CONFIG_RECORD: handleGetDGSoftwareConfigRecord( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -22,7 +22,6 @@ #include "Accel.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" -#include "Fans.h" #include "FPGA.h" #include "Heaters.h" #include "ModeFlush.h" @@ -363,7 +362,6 @@ return result; } - // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -2977,37 +2975,6 @@ } /*********************************************************************//** - * @brief - * The handleFansRPMOverride function handles a request to override a fans RPM value. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleFansRPMOverride( MESSAGE_T *message ) -{ - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetFanRPMOverride( payload.index, payload.state.f32 ); - } - else - { - result = testResetFanRPMOverride( payload.index ); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** * @brief * The handleStopDGRTCClock function handles a request to stop the RTC clock. * @details Inputs: none @@ -3181,6 +3148,37 @@ /*********************************************************************//** * @brief + * The handleFansRPMOverride function handles a request to override a fans RPM value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFansRPMOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetFanRPMOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetFanRPMOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestFansRPMAlarmStartTimeOverrideRequest function handles a * request to override the fan RPM alarm start time. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r44222e803e04d057ab793ce6b72902b8bfe9b7d0 -radeea598350354a833fff375526b888d0e6b6d48 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 44222e803e04d057ab793ce6b72902b8bfe9b7d0) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision adeea598350354a833fff375526b888d0e6b6d48) @@ -350,6 +350,12 @@ // MSG_ID_DG_DRAIN_PUMP_MEASURED_RPM_OVERRIDE void handleSetDrainPumpMeasuredRPMOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DG_ALARM_INFO_SEND_INTERVAL_OVERRIDE +void handleTestAlarmInfoSendIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DG_SUPER_CLEAR_ALARMS_CMD +void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ); + // MSG_ID_DG_FAN_RPM_ALARM_START_TIME_OFFSET_OVERRIDE void handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( MESSAGE_T *message );