Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r4d637d588c0d78d95645e24ccbfdc01d45718a2f -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 4d637d588c0d78d95645e24ccbfdc01d45718a2f) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -56,6 +56,7 @@ #define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS ( 60 * MS_PER_SECOND ) ///< Conductivity sensor error window. #define RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE 1.0F ///< Out of range value for RO rejection ratio when CPi conductivity is zero. + #define MAX_RO_REJECTION_RATIO_ALLOW 0.10F ///< Maximum RO rejection ratio. #define MAX_CPO_CONDUCTIVITY_ALLOW 30.0F ///< Maximum CPo sensor conductivity value. @@ -273,11 +274,9 @@ /*********************************************************************//** * @brief * The checkInletWaterConductivity function checks inlet water conductivity value - * and triggers an alarm when conductivity value is not within the specified - * values. + * and triggers an alarm when conductivity value is out of allowed range. * @details Inputs: CPi sensor conductivity - * @details Outputs: Trigger warning alarm if conductivity is in the warning - * range. Trigger alarm if conductivity is below minimum conductivity. + * @details Outputs: Trigger alarms when conductivity is out of allowed range * @return none *************************************************************************/ void checkInletWaterConductivity( void ) Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rd5f2ac4d84453feb1b782f35f9d69432977a95f6 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision d5f2ac4d84453feb1b782f35f9d69432977a95f6) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -30,7 +30,6 @@ #include "OperationModes.h" #include "PersistentAlarm.h" #include "Reservoirs.h" -#include "ROPump.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -69,10 +68,12 @@ #define PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C 0.015F ///< Primary heaters duty cycle per temperature in C. #define DATA_PUBLISH_COUNTER_START_COUNT 70 ///< Data publish counter start count. #define MIN_RO_HEATER_FLOWRATE_LPM 0.2F ///< Minimum target RO heater flow rate in L/min. +#define PRIMARY_HEATER_POWER_TOL 0.1F ///< Primary heater power tolerance. static const F32 WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES = 4184 / SEC_PER_MIN; ///< Water specific heat in J/KgC / 60. static const F32 PRIMARY_HEATERS_MAXIMUM_POWER_WATTS = 475 + 237.5F; ///< Primary heaters maximum power (main primary = 475W and small primary = 237.5W). static const F32 HEATERS_VOLTAGE_TOLERANCE_V = HEATERS_MAX_OPERATING_VOLTAGE_V * HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL; ///< Heaters voltage tolerance in volts. +static const F32 PRIMARY_HEATER_VOLTAGE_TOLERANCE_V = HEATERS_MAX_OPERATING_VOLTAGE_V * PRIMARY_HEATER_POWER_TOL; ///< Primary heater power voltage tolerance in volts. /// Heaters data structure typedef struct @@ -147,6 +148,7 @@ initPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_DG_PRIMARY_HEATER_POWER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON, HEATERS_ON_NO_FLOW_TIMEOUT_MS, HEATERS_ON_NO_FLOW_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_TOO_LOW_WHILE_TRIMMER_HEATER_IS_ON, HEATERS_ON_NO_FLOW_TIMEOUT_MS, HEATERS_ON_NO_FLOW_TIMEOUT_MS ); } @@ -167,6 +169,7 @@ if( heater < NUM_OF_DG_HEATERS ) { +#ifndef DISABLE_HEATERS_AND_TEMPS // Assume the target temperature has not changed heatersStatus[ heater ].hasTargetTempChanged = FALSE; @@ -177,6 +180,7 @@ heatersStatus[ heater ].hasTargetTempChanged = TRUE; result = TRUE; } +#endif } else { @@ -210,6 +214,7 @@ { BOOL status = FALSE; + if( heater < NUM_OF_DG_HEATERS ) { if ( HEATER_EXEC_STATE_OFF == heatersStatus[ heater ].state ) @@ -326,7 +331,7 @@ { alarm = ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON; measFlow = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); - minFlow = MIN_RO_FLOWRATE_LPM; + minFlow = MIN_RO_HEATER_FLOWRATE_LPM; } else { @@ -341,8 +346,14 @@ } else { - checkPersistentAlarm( ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON, FALSE, 0.0, 0.0 ); - checkPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_TOO_LOW_WHILE_TRIMMER_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + if ( DG_PRIMARY_HEATER == heater ) + { + checkPersistentAlarm( ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + } + else + { + checkPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_TOO_LOW_WHILE_TRIMMER_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + } } } @@ -430,7 +441,7 @@ heatersStatus[ heater ].startHeaterSignal = FALSE; // Depending on which heater is called, go to different states - state = ( heater == DG_PRIMARY_HEATER ? HEATER_EXEC_STATE_PRIMARY_RAMP_TO_TARGET : HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET ); + state = ( DG_PRIMARY_HEATER == heater ? HEATER_EXEC_STATE_PRIMARY_RAMP_TO_TARGET : HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET ); } return state; @@ -457,7 +468,7 @@ if ( DG_MODE_FILL == opMode ) { // If the previous average fill flow rate is 0, use the nominal target RO flow from the RO pump - targetFlow = ( getAvgFillFlowRateLPM() - 0.0 > NEARLY_ZERO ? getAvgFillFlowRateLPM() : getTargetROPumpFlowRateLPM() ); + targetFlow = ( getAvgFillFlowRateLPM() - 0.0F > NEARLY_ZERO ? getAvgFillFlowRateLPM() : getTargetROPumpFlowRateLPM() ); dutyCycle = calculatePrimaryHeaterDutyCycle( targetTemperature, inletTemperature, targetFlow, TRUE ); state = HEATER_EXEC_STATE_PRIMARY_CONTROL_TO_TARGET; } @@ -478,8 +489,7 @@ } else { - // No other modes are using the heaters - // TODO software fault + // Do nothing the mode that DG is in right now, does not need heaters to be on } // Update the calculated target temperature @@ -593,7 +603,6 @@ heatersStatus[ heater ].calculatedTemperature = currentTemperature; heatersStatus[ heater ].inactiveRsrvr = getInactiveReservoir(); heatersStatus[ heater ].targetFlow = targetFlowLPM; - heatersStatus[ heater ].dutyCycle = 0.0F; trimmerHeaterControlCounter = 0; // Cap the minimum duty cycle. So if it is calculated to negative, set it to 0 @@ -653,10 +662,7 @@ *************************************************************************/ static void setHeaterDutyCycle( DG_HEATERS_T heater, F32 pwm ) { - // Check if the requested duty cycle is different from what the heater's duty cycle is. - // If the same duty cycle is requested, then it is not needed to send it again. This is to make sure - // the same duty cycle is not sent to the hardware all the time. - if ( fabs( heatersStatus[ heater ].dutyCycle - pwm ) > NEARLY_ZERO ) + if ( heater < NUM_OF_DG_HEATERS ) { if ( DG_PRIMARY_HEATER == heater ) { @@ -668,9 +674,12 @@ setTrimmerHeaterPWM( pwm ); } - // Updated the heater's information heatersStatus[ heater ].dutyCycle = pwm; } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_HEATERS_INVALID_HEATER_ID_SELECTED, heater ); + } } /*********************************************************************//** @@ -721,7 +730,7 @@ { if ( TRUE == checkEfficiency ) { - // TODO Do we need efficiency for the trimmer heater? + // Do nothing right now. Efficiency will be implemented later if needed } } @@ -770,7 +779,15 @@ *************************************************************************/ static void setMainPrimaryHeaterPWM( F32 pwm ) { - etpwmSetCmpA( etpwmREG1, (U32)( (S32)( ( pwm * (F32)(etpwmREG1->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ) ); + etpwm_config_reg_t mainPriConfig; + U32 pwmValue = (U32)( (S32)( ( pwm * (F32)(etpwmREG1->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ); + + etpwm1GetConfigValue( &mainPriConfig, CurrentValue ); + + if ( mainPriConfig.CONFIG_CMPA != pwmValue ) + { + etpwmSetCmpA( etpwmREG1, pwmValue ); + } } /*********************************************************************//** @@ -783,7 +800,15 @@ *************************************************************************/ static void setSmallPrimaryHeaterPWM( F32 pwm ) { - etpwmSetCmpB( etpwmREG1, (U32)( (S32)( ( pwm * (F32)(etpwmREG1->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ) ); + etpwm_config_reg_t smallPriConfig; + U32 pwmValue = (U32)( (S32)( ( pwm * (F32)(etpwmREG1->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ); + + etpwm1GetConfigValue( &smallPriConfig, CurrentValue ); + + if ( smallPriConfig.CONFIG_CMPB != pwmValue ) + { + etpwmSetCmpB( etpwmREG1, pwmValue ); + } } /*********************************************************************//** @@ -796,7 +821,15 @@ *************************************************************************/ static void setTrimmerHeaterPWM( F32 pwm ) { - etpwmSetCmpA( etpwmREG3, (U32)( (S32)( ( pwm * (F32)(etpwmREG3->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ) ); + etpwm_config_reg_t trimmerConfig; + U32 pwmValue = (U32)( (S32)( ( pwm * (F32)(etpwmREG3->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ); + + etpwm3GetConfigValue( &trimmerConfig, CurrentValue ); + + if ( trimmerConfig.CONFIG_CMPA != pwmValue ) + { + etpwmSetCmpA( etpwmREG3, pwmValue ); + } } /*********************************************************************//** @@ -813,9 +846,9 @@ { HEATERS_DATA_T data; - data.mainPrimayHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; // The duty cycle of the primary heater is divided into 2 parts and is applied to main // and small primary heaters. So they are always the same. + data.mainPrimayHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; data.smallPrimaryHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; data.trimmerHeaterDC = heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle * 100.0; data.primaryTargetTemp = heatersStatus[ DG_PRIMARY_HEATER ].targetTemp; @@ -840,18 +873,19 @@ *************************************************************************/ static void monitorHeatersVoltage( void ) { - // NOTE: Default to using Primary heater voltage from FPGA - F32 mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_GND_V ); + F32 mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_GND_MAIN_PRIM_HTR_V ); + #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) { // V3 use CPU based value for Primary, same as Secondary - mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_SEC_HTR_V ); + mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_GND_SMALL_PRIM_HTR_V ); } #endif - F32 smallPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_SEC_HTR_V ); - F32 trimmerVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_TRIM_HTR_V ); + F32 smallPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_GND_SMALL_PRIM_HTR_V ); + F32 trimmerVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_GND_TRIM_HTR_V ); + // Voltage to PWM is reverse. If PWM = 0 -> V = 24V F32 mainPriDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle; F32 smallPriDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle; @@ -870,6 +904,17 @@ checkPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isMainPriOut, mainPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); checkPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isSmallPriOut, smallPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); checkPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, isTrimmerOut, trimmerDC, HEATERS_VOLTAGE_TOLERANCE_V ); + +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE != getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) +#endif + { + // If the system is DVT, check the primary heater's power line voltage + F32 powerMainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_POWER_PRIM_HTR_V ); + BOOL isPriPowerOut = ( fabs( powerMainPriVoltage - HEATERS_MAX_OPERATING_VOLTAGE_V ) > PRIMARY_HEATER_VOLTAGE_TOLERANCE_V ? TRUE : FALSE ); + + checkPersistentAlarm( ALARM_ID_DG_PRIMARY_HEATER_POWER_VOLTAGE_OUT_OF_RANGE, isPriPowerOut, powerMainPriVoltage, PRIMARY_HEATER_VOLTAGE_TOLERANCE_V ); + } } } Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rd5f2ac4d84453feb1b782f35f9d69432977a95f6 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision d5f2ac4d84453feb1b782f35f9d69432977a95f6) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -96,7 +96,7 @@ * @details Outputs: LoadCell module initialized. * @return none *************************************************************************/ - void initLoadCell( void ) +void initLoadCell( void ) { U32 i; U32 j; @@ -350,7 +350,7 @@ else { // Raise the alarm - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_LOAD_CELLS_TARE_WEIGHT_OUT_OF_RANGE, weight ) + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_LOAD_CELLS_TARE_WEIGHT_OUT_OF_RANGE, weight ); } } Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r4e11c80367b5ae522aa34fb137079e516c98831b -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 4e11c80367b5ae522aa34fb137079e516c98831b) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -433,12 +433,12 @@ static F32 calculateBaroPressure( U32 adcSum ) { S32 tempDiff = getBaroSensorTemperatureDiff(); - U64 tempOffset = ( baroConvConsts.pressureOffsetTempCoeff * tempDiff ) / TWO_TO_POWER_OF_6; - U64 presOffset = baroConvConsts.pressureOffset * TWO_TO_POWER_OF_17; - U64 offset = presOffset + tempOffset; - U64 tempSensitivity = ( baroConvConsts.pressureSensitivityTempCoeff * tempDiff ) / TWO_TO_POWER_OF_7; - U64 presSensitivity = baroConvConsts.pressureSensitivity * TWO_TO_POWER_OF_16; - U64 sensitivity = tempSensitivity + presSensitivity; + S64 tempOffset = ( baroConvConsts.pressureOffsetTempCoeff * tempDiff ) / TWO_TO_POWER_OF_6; + S64 presOffset = baroConvConsts.pressureOffset * TWO_TO_POWER_OF_17; + S64 offset = presOffset + tempOffset; + S64 tempSensitivity = ( baroConvConsts.pressureSensitivityTempCoeff * tempDiff ) / TWO_TO_POWER_OF_7; + S64 presSensitivity = baroConvConsts.pressureSensitivity * TWO_TO_POWER_OF_16; + S64 sensitivity = tempSensitivity + presSensitivity; S32 pres = (S32)( ( ( adcSum * sensitivity ) / TWO_TO_POWER_OF_21 ) - offset ) / TWO_TO_POWER_OF_15; F32 presPSI = ( (F32)pres / (F32)( COUNTS_TO_MILLI_BAR * ONE_BAR_TO_MILLI_BAR ) ) * ONE_BAR_TO_PSI_CONVERSION; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r4d637d588c0d78d95645e24ccbfdc01d45718a2f -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 4d637d588c0d78d95645e24ccbfdc01d45718a2f) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -63,7 +63,6 @@ #define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor). -#define FLOW_SAMPLES_TO_AVERAGE ( 250 / TASK_PRIORITY_INTERVAL ) ///< Averaging flow data over 250 ms intervals. #define FLOW_AVERAGE_MULTIPLIER ( 1.0F / (F32)FLOW_SAMPLES_TO_AVERAGE ) ///< Optimization - multiplying is faster than dividing. // The ADC to LPM factor is calculated using the following steps: @@ -76,7 +75,6 @@ /// Initial conversion factor from target flow rate to PWM duty cycle estimate. #define ROP_FLOW_TO_PWM_DC(flow) ( ROP_FLOW_TO_PWM_SLOPE * flow + ROP_FLOW_TO_PWM_INTERCEPT ) - #define MAX_ALLOWED_FLOW_DEVIATION 0.1F ///< Max allowed deviation from target flow. #define FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in counts. #define MAX_PRESSURE_TARGET_TOLERANCE 5 ///< Pressure tolerance from maximum set pressure by user in psi. @@ -90,7 +88,6 @@ #define ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE 2.51F ///< RO pump 0% duty cycle feedback voltage. #define ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE 0.05F ///< RO pump duty cycle out of range tolerance. - #define DATA_PUBLISH_COUNTER_START_COUNT 50 ///< Data publish counter start count. /// Enumeration of RO pump states. @@ -129,14 +126,8 @@ static F32 targetROPumpMaxPressure; ///< Target RO max allowed pressure (in PSI). static OVERRIDE_U32_T roPumpDataPublishInterval = { RO_PUMP_DATA_PUB_INTERVAL, RO_PUMP_DATA_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish RO flow data to CAN bus. -static OVERRIDE_F32_T measuredROFlowRateLPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured RO flow rate (in L/min). static U32 roControlTimerCounter; ///< Determines when to perform control on RO pump. static F32 roPumpOpenLoopTargetDutyCycle; ///< Target RO pump open loop PWM. -static S32 measuredFlowReadingsSum; ///< Raw flow reading sums for averaging. -static U32 flowFilterCounter; ///< Flow filtering counter. -static DG_FLOW_SENSORS_CAL_RECORD_T flowSensorsCalRecord; ///< Flow sensors calibration record. -static OVERRIDE_F32_T measuredROFlowRateWithConcPumpsLPM = { 0.0, 0.0, 0.0, 0 }; ///< Measure RO flow rate with concentrate pumps (L/min). -static DG_RO_PUMP_CAL_RECORD_T roPumpCalRecord; ///< RO pump calibration record. static F32 roVolumeL; ///< RO water generated in liters. // ********** private function prototypes ********** @@ -156,11 +147,10 @@ * @brief * The initROPump function initializes the RO Pump module. * @details Inputs: roControlTimerCounter,roPumpOpenLoopTargetDutyCycle, - * roPumpFlowRateRunningSum, roPumpPressureRunningSum, measuredFlowReadingsSum, - * flowFilterCounter, flowVerificationCounter, roPumpState, roPumpControlMode - * roPumpDataPublicationTimerCounter, rawFlowLP, targetROPumpFlowRateLPM, + * roPumpPressureRunningSum, flowFilterCounter, flowVerificationCounter, + * roPumpState, roPumpControlMode, roPumpDataPublicationTimerCounter, rawFlowLP, * roPumpPWMDutyCyclePct, roPumpDutyCyclePctSet, pendingROPumpCmdMaxPressure, - * pendingROPumpCmdTargetFlow, pendingROPumpCmdCountDown, targetROPumpMaxPressure + * pendingROPumpCmdTargetFlow, pendingROPumpCmdCountDown, targetROPumpMaxPressure, * @details Outputs: none * @return none *************************************************************************/ @@ -190,8 +180,6 @@ // Initialize the variables roControlTimerCounter = 0; roPumpOpenLoopTargetDutyCycle = 0; - measuredFlowReadingsSum = 0; - flowFilterCounter = 0; roPumpDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; roPumpState = RO_PUMP_OFF_STATE; roPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; @@ -233,7 +221,7 @@ // For now maximum allowed pressure is inserted into the target pressure override // if the target flow rate exceeded the max pressure, it will set the maximum pressure targetROPumpMaxPressure = maxPressure; - targetROPumpFlowRateLPM = roFlowRate; + targetROPumpFlowRateLPM = roFlowRate; roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; roPumpState = RO_PUMP_RAMP_UP_TO_TARGET_FLOW_STATE; // Get the initial guess of the duty cycle @@ -345,53 +333,19 @@ F32 roFeedbackVoltage = getIntADCVoltageConverted( INT_ADC_RO_PUMP_FEEDBACK_DUTY_CYCLE ); // Read the pressure at the sensor. The pump cannot be more that the maximum allowed pressure // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately - F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); - BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); + F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); + BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); BOOL isDutyCylceOutOfRange = FALSE; - // Update sum for flow average calculation - measuredFlowReadingsSum += (S32)roFlowReading; - checkPersistentAlarm( ALARM_ID_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); - // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) + if ( ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) > NEARLY_ZERO ) && ( VALVE_STATE_CLOSED == getValveStateName( VBF ) ) ) { - getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_RO_FLOW_SENSOR_INVALID_CAL_RECORD ); + // If the RO pump's flow is greater than zero, and the VBf valve is not open (like heat disinfect) it means RO water is being generated + // Add that water to the variable + roVolumeL += ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) / ( SEC_PER_MIN * MS_PER_SECOND ) ) * TASK_PRIORITY_INTERVAL; } - // Read flow at the control set - if ( ++flowFilterCounter >= FLOW_SAMPLES_TO_AVERAGE ) - { - F32 flow = RO_FLOW_ADC_TO_LPM_FACTOR / ( (F32)measuredFlowReadingsSum * FLOW_AVERAGE_MULTIPLIER ); - - flow = 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 + - flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; - - measuredROFlowRateWithConcPumpsLPM.data = flow; - measuredROFlowRateLPM.data = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); - - // 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; - } - - if ( ( measuredROFlowRateLPM.data > NEARLY_ZERO ) && ( (U32)VALVE_STATE_CLOSED == getValveState( (U32)VBF ) ) ) - { - roVolumeL += ( measuredROFlowRateLPM.data * SEC_PER_MIN ); - } - #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RO_PUMP_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -401,7 +355,7 @@ // but the pump is not able to achieve the flow. if ( ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) && ( RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE == roPumpState ) ) { - F32 currentFlow = getMeasuredROFlowRateLPM(); + F32 currentFlow = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); F32 targetFlow = getTargetROPumpFlowRateLPM(); // The flow cannot be out of range for than 10% of the target flow BOOL isFlowOutOfRange = ( fabs( 1.0F - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); @@ -504,23 +458,9 @@ SELF_TEST_STATUS_T execROPumpSelfTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = FALSE; - calStatus |= getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_RO_FLOW_SENSOR_INVALID_CAL_RECORD ); + // TODO is there anything else needed in POST for the RO pump? - calStatus |= getNVRecord2Driver( GET_CAL_RO_PUMP_RECORD, (U08*)&roPumpCalRecord, sizeof( DG_RO_PUMP_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_NO_ALARM ); - - if ( TRUE == calStatus ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - } - return result; } @@ -552,31 +492,6 @@ /*********************************************************************//** * @brief - * The getMeasuredROFlowRateLPM function gets the measured RO pump flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @return the current RO pump flow rate (in L/min). - *************************************************************************/ -F32 getMeasuredROFlowRateLPM( void ) -{ - return getF32OverrideValue( &measuredROFlowRateLPM ); -} - -/*********************************************************************//** - * @brief - * The getMeasuredROFlowRateWithConcPumpsLPM function gets the measured RO - * pump flow rate with the concentrate pumps. - * @details Inputs: measuredROFlowRateWithConcPumpsLPM - * @details Outputs: measuredROFlowRateWithConcPumpsLPM - * @return the current RO pump flow rate with the concentrate pumps (in L/min). - *************************************************************************/ -F32 getMeasuredROFlowRateWithConcPumpsLPM( void ) -{ - return getF32OverrideValue( &measuredROFlowRateWithConcPumpsLPM ); -} - -/*********************************************************************//** - * @brief * The getTargetROPumpPressure function gets the current target RO pump * pressure. * @details Inputs: targetROPumpPressure @@ -592,7 +507,7 @@ * @brief * The getROGeneratedVolumeL function returns the RO generated volume in liters. * @details Inputs: none - * @details Outputs: none + * @details Outputs: roVolumeL * @return the RO generated volume in liters *************************************************************************/ F32 getROGeneratedVolumeL( void ) @@ -860,13 +775,13 @@ if ( ++roPumpDataPublicationTimerCounter >= getU32OverrideValue( &roPumpDataPublishInterval ) ) { RO_PUMP_DATA_T pumpData; + pumpData.roPumpTgtFlowRateLM = getTargetROPumpFlowRateLPM(); pumpData.roPumpTgtPressure = getTargetROPumpPressure(); - pumpData.measROFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); //getMeasuredROFlowRateLPM(); + pumpData.measROFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); pumpData.roPumpDutyCycle = roPumpDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; pumpData.roPumpState = (U32)roPumpState; pumpData.roPumpFBDutyCycle = roPumpFeedbackDutyCyclePct * FRACTION_TO_PERCENT_FACTOR; - pumpData.roPumpMeasFlowWithConcPumps = getMeasuredROFlowRateWithConcPumpsLPM(); broadcastData( MSG_ID_RO_PUMP_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&pumpData, sizeof( RO_PUMP_DATA_T ) ); roPumpDataPublicationTimerCounter = 0; @@ -985,54 +900,6 @@ /*********************************************************************//** * @brief - * The testSetMeasuredROFlowRateOverride function overrides the measured - * RO flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @param: value : override measured RO pump motor speed (in L/min) - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetMeasuredROFlowRateOverride( F32 value ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - measuredROFlowRateLPM.ovInitData = measuredROFlowRateLPM.data; - measuredROFlowRateLPM.ovData = value; - measuredROFlowRateLPM.override = OVERRIDE_KEY; - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetMeasuredROFlowRateOverride function resets the override - * of the measured RO flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testResetMeasuredROFlowRateOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - measuredROFlowRateLPM.data = measuredROFlowRateLPM.ovInitData; - measuredROFlowRateLPM.override = OVERRIDE_RESET; - measuredROFlowRateLPM.ovInitData = 0.0; - measuredROFlowRateLPM.ovData = 0.0; - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief * The testSetTargetDutyCycleOverride function overrides the target duty * cycle of the RO pump. * @details Inputs: none Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rd5f2ac4d84453feb1b782f35f9d69432977a95f6 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision d5f2ac4d84453feb1b782f35f9d69432977a95f6) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -83,7 +83,6 @@ #define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. #define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. -#define TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors error bit timeout in milliseconds. #define TEMP_SENSORS_MIN_ALLOWED_DEGREE_C 0.0F ///< Temperature sensors minimum allowed temperature in C. #define TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 120.0F ///< Temperature sensors maximum allowed temperature in C. @@ -330,9 +329,6 @@ // Persistent alarm for the temperature sensors range check initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_ADC_FAULT, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ); - // Persistent alarm for the temperature sensors error bit fault check - initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_ERROR_BIT_FAULT, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ); - // Initialize the FPGA persistent alarms initFPGAPersistentAlarm( TWO_WIRE_ADC_TEMP_SENSORS, ALARM_ID_DG_TWO_WIRE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); initFPGAPersistentAlarm( THD_ADC_TEMP_SENSORS, ALARM_ID_DG_THD_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); @@ -470,14 +466,33 @@ // the electrical connection of THd sensor. if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) { - if ( ( TEMPSENSORS_HEAT_DISINFECT == sensorIndex ) || ( TEMPSENSORS_INTERNAL_THD_RTD == sensorIndex ) ) + if ( TEMPSENSORS_HEAT_DISINFECT == sensorIndex ) { - temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_OUTLET_REDUNDANT ].temperatureValues ); + if ( OVERRIDE_KEY == tempSensors[ TEMPSENSORS_HEAT_DISINFECT ].temperatureValues.override ) + { + temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_HEAT_DISINFECT ].temperatureValues ); + } + else + { + temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_OUTLET_REDUNDANT ].temperatureValues ); + } } + if ( TEMPSENSORS_INTERNAL_THD_RTD == sensorIndex ) + { + temperature = 40.0F; + } + if ( TEMPSENSORS_OUTLET_REDUNDANT == sensorIndex ) { - temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_INLET_DIALYSATE ].temperatureValues ); + if ( OVERRIDE_KEY == tempSensors[ TEMPSENSORS_OUTLET_REDUNDANT ].temperatureValues.override ) + { + temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_OUTLET_REDUNDANT ].temperatureValues ); + } + else + { + temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_INLET_DIALYSATE ].temperatureValues ); + } } } #endif @@ -614,7 +629,9 @@ *************************************************************************/ static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ) { - S32 convertedADC = (S32)( adc & MASK_OFF_U32_MSB ); + // Some of the temperature sensors have an MSB bit that is used as an error flag. This flag will be a TRUE by default. + BOOL isErrorBitNotValid = FALSE; + S32 convertedADC = (S32)( adc & MASK_OFF_U32_MSB ); switch( sensorIndex ) { @@ -633,10 +650,6 @@ case TEMPSENSORS_INTERNAL_THD_RTD: { U08 i; - // Some of the temperature sensors have an MSB bit that is used as an - // error flag. This flag will be a TRUE by default. - BOOL isErrorBitNotValid = FALSE; - U32 faultySensorIndex = 0; // Shift bits by 31 to right to check the error bit status tempSensors[ sensorIndex ].sensorErrorBitStatus = adc >> SHIFT_BITS_BY_31; @@ -651,11 +664,8 @@ if ( tempSensors[ i ].sensorErrorBitStatus > 0 ) { isErrorBitNotValid = TRUE; - faultySensorIndex = i; } } - - checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_ERROR_BIT_FAULT, isErrorBitNotValid, faultySensorIndex, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ); } break; @@ -666,7 +676,11 @@ break; } - processADCRead( sensorIndex, convertedADC ); + if ( FALSE == isErrorBitNotValid ) + { + // Make sure the error bit is not true before + processADCRead( sensorIndex, convertedADC ); + } } /*********************************************************************//** @@ -930,12 +944,6 @@ data.internalTDIRTD = getTemperatureValue( TEMPSENSORS_INTERNAL_TDI_RTD ); data.interalTHDRTD = getTemperatureValue( TEMPSENSORS_INTERNAL_THD_RTD ); data.internalCondSnsrTemp = getTemperatureValue( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR ); - data.primaryThermoCoupleRaw = getFPGAPrimaryHeaterTemp(); - data.primaryColdjuncRaw = getFPGAPrimaryColdJunctionTemp(); - data.trimmerThermoCoupleRaw = getFPGATrimmerHeaterTemp(); - data.trimmerColdjuncRaw = getFPGATrimmerColdJunctionTemp(); - data.cond1Raw = tempSensors[ TEMPSENSORS_CONDUCTIVITY_SENSOR_1 ].rawADCReads[ MAX_NUM_OF_RAW_ADC_SAMPLES - 1 ]; - data.cond2Raw = tempSensors[ TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ].rawADCReads[ MAX_NUM_OF_RAW_ADC_SAMPLES - 1 ]; broadcastData( MSG_ID_DG_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); dataPublicationTimerCounter = 0; Index: firmware/App/Controllers/Voltages.c =================================================================== diff -u -r4e11c80367b5ae522aa34fb137079e516c98831b -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 4e11c80367b5ae522aa34fb137079e516c98831b) +++ firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -275,9 +275,11 @@ adcReadings[ ch ][ adcReadingsIdx[ ch ] ] = getFPGAHeaterGndADC(); break; +#ifndef _VECTORCAST_ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_INT_ADC_CHANNEL_NUMBER, ch ) break; +#endif } adcReadingsTotals[ ch ] += adcReadings[ ch ][ adcReadingsIdx[ ch ] ]; Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -rd5f2ac4d84453feb1b782f35f9d69432977a95f6 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision d5f2ac4d84453feb1b782f35f9d69432977a95f6) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -85,8 +85,8 @@ SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX, SW_FAULT_ID_CONCENTRATE_PUMP_EXEC_INVALID_STATE, // 55 SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID, - SW_FAULT_ID_SEMAPHORE_IN_USE_TIMEOUT, SW_FAULT_ID_SERVICE_MODE_INVALID_EXEC_STATE, + SW_FAULT_ID_SEMAPHORE_IN_USE_TIMEOUT, SW_FAULT_ID_UV_REACTORS_INVALID_EXEC_STATE, SW_FAULT_ID_UV_REACTORS_INVALID_SELF_TEST_STATE, SW_FAULT_ID_THERMISTORS_INVALID_EXEC_STATE, // 60 @@ -133,6 +133,10 @@ SW_FAULT_ID_ILLEGAL_MEM_ACCESS, SW_FAULT_ID_INVALID_CHEMICAL_BOTTLE_SELECTED, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED, + SW_FAULT_ID_INVALID_FLOW_SENSOR_SELECTED, + SW_FAULT_ID_INVALID_SERVICE_STATE_SELECTED, // 105 + SW_FAULT_ID_INVALID_NV_RECORD_SELECTED, + SW_FAULT_ID_WRITE_USAGE_INFO_TO_NV_FAILURE, SW_FAULT_ID_INVALID_FPGA_ERROR_GROUP_SELECTED, SW_FAULT_ID_INVALID_LED_COLOR_SELECTED, // 105 NUM_OF_SW_FAULT_IDS Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -re69a109cc497124ac5f438264647666b17276bf4 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e69a109cc497124ac5f438264647666b17276bf4) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -52,6 +52,9 @@ #define MSG_NOT_ACKED_MAX_RETRIES 3 ///< maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm #define PENDING_ACK_LIST_SIZE 25 ///< maximum number of Delanli messages that can be pending ACK at any given time +#define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm +#define MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< FPGA clock speed error window + #pragma pack(push, 1) /// Record for transmitted message that is pending acknowledgement from receiver. @@ -136,6 +139,9 @@ // initialize bad message CRC time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC, MAX_COMM_CRC_FAILURES, MAX_COMM_CRC_FAILURE_WINDOW_MS ); + // initialize FPGA clock speed error time windowed count + initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR, MAX_FPGA_CLOCK_SPEED_ERRORS, MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS); + // initialize pending ACK list for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { @@ -876,7 +882,7 @@ handleDGPOSTResultRequest( message ); break; - case MSG_ID_UI_REQUEST_SERVICE_INFO: + case MSG_ID_HD_REQUEST_DG_SERVICE_RECORD: handleDGServiceScheduleRequest( message ); break; @@ -892,6 +898,10 @@ handleServiceModeRequest( message ); break; + case MSG_ID_HD_REQUEST_DG_USAGE_INFO: + handleHDRequestDGUsageInfo( message ); + break; + case MSG_ID_REQUEST_CPLD_STATUS: handleCpldStatusRequest( message ); break; @@ -944,20 +954,16 @@ handleTestPressureDataBroadcastIntervalOverrideRequest( message ); break; - case MSG_ID_RO_MEASURED_FLOW_OVERRIDE: - handleTestROMeasuredFlowOverrideRequest( message ); + case MSG_ID_MEASURED_FLOW_SENSORS_OVERRIDE: + handleTestMeasuredFlowOverrideRequest( message ); break; - case MSG_ID_DIALYSATE_MEASURED_FLOW_OVERRIDE: - handleTestDialysateMeasuredFlowOverrideRequest( message ); - break; - case MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: handleTestROPumpDataBroadcastIntervalOverrideRequest( message ); break; - case MSG_ID_DIALYSATE_FLOW_SEND_INTERVAL_OVERRIDE: - handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( message ); + case MSG_ID_FLOW_DATA_PUBLISH_INTERVAL_OVERRIDE: + handleTestFlowSensorsDataBroadcastIntervalOverrideRequest( message ); break; case MSG_ID_DRAIN_PUMP_SET_RPM: @@ -1068,10 +1074,6 @@ handleTestROPumpDutyCycleOverride( message ); break; - case MSG_ID_DG_RO_FLOW_RATE_OVERRIDE: - handleTestROMeasuredFlowOverrideRequest( message ); - break; - case MSG_ID_DG_SET_RO_PUMP_TARGET_FLOW: handleTestROPumpTargetFlowOverride( message ); break; @@ -1137,11 +1139,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: @@ -1152,10 +1154,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; @@ -1168,6 +1166,10 @@ handleTestFansRPMAlarmStartTimeOffsetRequest( message ); break; + case MSG_ID_DG_FANS_RPM_OVERRIDE: + handleFansRPMOverride( message ); + break; + case MSG_ID_DG_USED_ACID_VOLUME_ML_OVERRIDE: handleTestUsedAcidVolumeMLOverrideRequest( message ); break; @@ -1200,18 +1202,19 @@ handleSetDGUsageInfoRecord( message ); break; - case MSG_ID_HD_REQUEST_DG_ALARMS: - handleResendAllAlarmsCommand( message ); - break; - case MSG_ID_DG_SET_OP_MODE_REQUEST: handleTestSetOpModeRequest( message ); break; case MSG_ID_DG_RESERVOIR_TARE_REQUEST: handleTestTareReservoirRequest( message ); + break; + case MSG_ID_HD_REQUEST_DG_ALARMS: + handleResendAllAlarmsCommand( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -re69a109cc497124ac5f438264647666b17276bf4 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision e69a109cc497124ac5f438264647666b17276bf4) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -25,6 +25,7 @@ #include "ConductivitySensors.h" #include "CPLD.h" #include "Fans.h" +#include "FlowSensors.h" #include "FPGA.h" #include "Heaters.h" #include "ModeFill.h" @@ -35,7 +36,6 @@ #include "MsgQueues.h" #include "NVDataMgmt.h" #include "OperationModes.h" -#include "DialysateFlow.h" #include "Pressures.h" #include "Reservoirs.h" #include "RTC.h" @@ -369,7 +369,6 @@ return result; } - // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -555,21 +554,19 @@ getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); U08 *payloadPtr = msg.payload; - if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) - { - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // Fill message payload - memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); - } + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + // Fill message payload + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } /*********************************************************************//** @@ -890,7 +887,7 @@ msg.hdr.msgID = MSG_ID_DG_SCHEDULED_RUNS_DATA; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // TODO this message is for Phase 1B. + // Do nothing this message is for Phase 1B. // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); @@ -1471,7 +1468,43 @@ return status; } +/*********************************************************************//** + * @brief + * The handleHDRequestDGUsageInfo function handles a request for DG + * usage information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none + *************************************************************************/ +void handleHDRequestDGUsageInfo( MESSAGE_T * message ) +{ + MESSAGE_T msg; + DG_USAGE_INFO_RECORD_T usageInfo; + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&usageInfo, sizeof( DG_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_USAGE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( BOOL ); + + // Fill message payload + memcpy( payloadPtr, &usageInfo.lastHeatDisDateEpoch, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &usageInfo.lastChemicalDisDateEpoch, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &usageInfo.isDisinfected, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); +} + + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -1835,32 +1868,31 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - /*********************************************************************//** * @brief - * The handleTestROMeasuredFlowOverrideRequest function handles a request to - * override the RO flow rate. + * The handleTestMeasuredFlowOverrideRequest function handles a request to + * override the measured flow sensor rate. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ) +void handleTestMeasuredFlowOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_PAYLOAD_T payload; + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); + result = testSetMeasuredFlowRateOverride( payload.index, payload.state.f32 ); } else { - result = testResetMeasuredROFlowRateOverride(); + result = testResetMeasuredFlowRateOverride( payload.index ); } } @@ -1870,38 +1902,6 @@ /*********************************************************************//** * @brief - * The handleTestDialysateMeasuredFlowOverrideRequest function handles a request to - * override the Dialysate flow rate. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialysateMeasuredFlowOverrideRequest( MESSAGE_T *message ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); - if ( FALSE == payload.reset ) - { - result = testSetMeasuredDialysateFlowRateOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredDialysateFlowRateOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. * @details Inputs: none @@ -1934,14 +1934,14 @@ /*********************************************************************//** * @brief - * The handleTestDialysateFlowDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for dialysate flow data. + * The handleTestFlowSensorsDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for the flow sensors data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +void handleTestFlowSensorsDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -1952,11 +1952,11 @@ memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetDialysateFlowDataPublishIntervalOverride( payload.state.u32 ); + result = testSetFlowDataPublishIntervalOverride( payload.state.u32 ); } else { - result = testResetDialysateFlowDataPublishIntervalOverride(); + result = testResetFlowDataPublishIntervalOverride(); } } @@ -3231,37 +3231,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 @@ -3400,10 +3369,41 @@ /*********************************************************************//** * @brief - * The handleTestFansRPMAlarmStartTimeOffsetRequest function handles a - * request to set the fans RPM alarm start time offset. + * 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 + * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ @@ -3426,7 +3426,6 @@ } /*********************************************************************//** - * @brief * The handleTestUsedAcidVolumeMLOverrideRequest function handles a * request to override the acid volume. * @details Inputs: none @@ -3719,30 +3718,6 @@ /*********************************************************************//** * @brief -* The handleResendAllAlarmsCommand function handles a request to re-send -* all active DG alarms. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -void handleResendAllAlarmsCommand( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // verify payload length - if ( 0 == message->hdr.payloadLen ) - { - handleResendActiveAlarmsRequest(); - result = TRUE; - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** -* @brief * The handleServiceModeRequest function handles a request to enter service * mode. * @details Inputs: none @@ -3812,6 +3787,33 @@ /*********************************************************************//** * @brief + * The handleResendAllAlarmsCommand function handles a request to re-send + * all active DG alarms. + * The sendUIServiceModeResponse function sends out the DG response to a + * UI request to go to service mode. + * @details Inputs: none + * @details Outputs: Service mode request response msg constructed and queued + * @param accepted TRUE if request was accepted, FALSE if not + * @param rejCode Reject reason code explaining why request was rejected + * @return none + *************************************************************************/ +void handleResendAllAlarmsCommand( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + handleResendActiveAlarmsRequest(); + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleCpldStatusRequest function handles a CPLD Status request message. * @details Inputs: none * @details Outputs: message handled Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -re69a109cc497124ac5f438264647666b17276bf4 -r059eb49a6f8fd2e2277b98b4aee986eb4519820a --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision e69a109cc497124ac5f438264647666b17276bf4) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 059eb49a6f8fd2e2277b98b4aee986eb4519820a) @@ -32,7 +32,6 @@ #include "NVDataMgmt.h" #include "Reservoirs.h" #include "ROPump.h" -#include "DialysateFlow.h" #include "Switches.h" #include "TemperatureSensors.h" #include "Thermistors.h" @@ -95,7 +94,7 @@ // MSG_ID_REQUEST_FW_VERSIONS void handleDGSerialNumberRequest( void ); -// MSG_ID_UI_REQUEST_SERVICE_INFO +// MSG_ID_HD_REQUEST_DG_SERVICE_RECORD void handleDGServiceScheduleRequest( MESSAGE_T *message ); // MSG_ID_HD_REQUEST_DG_CONCENTRATE_RATIOS @@ -155,15 +154,18 @@ // MSG_ID_DG_SCHEDULED_RUNS_INFO void handleDGScheduledRunsRequest( MESSAGE_T *message ); -// MSG_ID_HD_OP_MODE -BOOL handleSetHDOperationMode( MESSAGE_T *message ); - // MSG_ID_UI_REQUEST_SERVICE_MODE void handleServiceModeRequest( MESSAGE_T *message ); // MSG_ID_DG_RESPONSE_SERVICE_MODE_REQUEST BOOL sendServiceModeResponse( BOOL accepted, U32 rejCode ); +// MSG_ID_HD_OP_MODE +BOOL handleSetHDOperationMode( MESSAGE_T *message ); + +// MSG_ID_HD_REQUEST_DG_USAGE_INFO +void handleHDRequestDGUsageInfo( MESSAGE_T * message ); + // MSG_ID_REQUEST_CPLD_STATUS void handleCpldStatusRequest( MESSAGE_T *message ); @@ -200,17 +202,14 @@ // MSG_ID_PRESSURE_SEND_INTERVAL_OVERRIDE: void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); -// MSG_ID_RO_MEASURED_FLOW_OVERRIDE: -void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ); - // MSG_ID_DIALYSATE_MEASURED_FLOW_OVERRIDE: -void handleTestDialysateMeasuredFlowOverrideRequest( MESSAGE_T *message ); +void handleTestMeasuredFlowOverrideRequest( MESSAGE_T *message ); // MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); // MSG_ID_DIALYSATE_FLOW_SEND_INTERVAL_OVERRIDE: -void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); +void handleTestFlowSensorsDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); // MSG_ID_DRAIN_PUMP_SET_RPM_OVERRIDE void handleTestDrainPumpRPMOverrideRequest( MESSAGE_T *message ); @@ -374,6 +373,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_SET_FANS_RPM_ALARM_START_TIME_OFFSET void handleTestFansRPMAlarmStartTimeOffsetRequest( MESSAGE_T *message ); @@ -395,15 +400,18 @@ // MSG_ID_DG_HD_COMMUNICATION_STATUS void handleTestHDCommunicationStatusOverrideRequest(MESSAGE_T *message); +// MSG_ID_DG_USED_ACID_VOLUME_ML_OVERRIDE +void handleTestUsedAcidVolumeMLOverrideRequest(MESSAGE_T *message); + +// MSG_ID_DG_USED_BICARB_VOLUME_ML_OVERRIDE +void handleTestUsedBicarbVolumeMLOverrideRequest(MESSAGE_T *message); + // MSG_ID_DG_GET_USAGE_INFO_RECORD void handleGetDGUsageInfoRecord( MESSAGE_T *message ); // MSG_ID_DG_SET_USAGE_INFO_RECORD void handleSetDGUsageInfoRecord( MESSAGE_T *message ); -// MSG_ID_HD_REQUEST_DG_ALARMS -void handleResendAllAlarmsCommand( MESSAGE_T *message ); - // MSG_ID_DG_SET_OP_MODE_REQUEST void handleTestSetOpModeRequest( MESSAGE_T *message ); @@ -413,6 +421,9 @@ // MSG_ID_HD_OP_MODE BOOL handleSetHDOperationMode( MESSAGE_T *message ); +// MSG_ID_HD_REQUEST_DG_ALARMS +void handleResendAllAlarmsCommand( MESSAGE_T *message ); + /**@}*/ #endif