Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r19056bcb960b73405326d038abcea63b6862e344 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 19056bcb960b73405326d038abcea63b6862e344) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -7,8 +7,8 @@ * * @file LoadCell.c * -* @author (last) Dara Navaei -* @date (last) 13-Jul-2022 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * * @author (original) Saeed Nejatali * @date (original) 25-Feb-2020 @@ -48,23 +48,23 @@ #define LOAD_CELL_MIN_ALLOWED_WEIGHT_BEFORE_TARE_GRAMS 1600.0F ///< Load cell minimum allowed weight before tare in grams. #define LOAD_CELL_WEIGHT_OUT_RANGE_PERSISTENT_PERIOD_MS (5 * MS_PER_SECOND) ///< Load cell weight out of range persistent period in milliseconds. #define LOAD_CELL_PRIMARY_BACKUP_MAX_DRIFT_PERSISTENT_PERIOD_MS (5 * MS_PER_SECOND) ///< Load cell primary and backup maximum allowed weight drift persistent period in milliseconds. -#define EMPTY_RESERVOIR_WEIGHT_GRAMS 1600 ///< Reservoirs empty weight in grams. -#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS 300 ///< Max allowed extra weight before first tare in grams. -#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS 60 ///< Max allowed extra weight before tare in grams. +#define EMPTY_RESERVOIR_WEIGHT_GRAMS 1600.0F ///< Reservoirs empty weight in grams. +#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS 300.0F ///< Max allowed extra weight before first tare in grams. +#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS 60.0F ///< Max allowed extra weight before tare in grams. #define LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS 60.0F ///< Load cell primary and backup maximum allowed weight drift in grams. #define DATA_PUBLISH_COUNTER_START_COUNT 0 ///< Data publish counter start count. /// Load cell data structure. typedef struct { U32 rawReading; ///< Latest raw load cell reading. - OVERRIDE_F32_T weight; ///< Latest load cell weight. + F32 weight; ///< Latest load cell weight. F32 autoCalOffset; ///< Load cell auto-calibration offset. F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. F32 smallFilterReadings[ SIZE_OF_SMALL_LOAD_CELL_AVG ]; ///< Load cell samples for small load cell moving average. F64 smallFilterTotal; ///< Small filter rolling total - used to calc small load cell moving average. - F32 smallFilteredWeight; ///< Load cell small filtered (100 100Hz raw sample) weight. + OVERRIDE_F32_T smallFilteredWeight; ///< Load cell small filtered (100 100Hz raw sample) weight. F32 largeFilterReadings[ SIZE_OF_LARGE_LOAD_CELL_AVG ]; ///< Load cell samples for large load cell moving average. F64 largeFilterTotal; ///< Large filter rolling total - used to calc small load cell moving average. @@ -76,12 +76,13 @@ static OVERRIDE_U32_T loadCellDataPublishInterval = { LOAD_CELL_REPORT_PERIOD, LOAD_CELL_REPORT_PERIOD, 0, 0 }; ///< Broadcast load cell data publish interval. static LOADCELL_T loadcells[ NUM_OF_LOAD_CELLS ]; ///< Load cell data structures. -static U32 loadCellFilterTimerCount = 0; ///< Load cell filtering timer count. +static U32 loadCellFilterTimerCount; ///< Load cell filtering timer count. static U32 loadCellDataPublicationTimerCounter; ///< Load cell data publication timer counter to CAN bus. static U32 smallReadingsIdx; ///< Index for next sample in load cell small rolling average sample array. static U32 largeReadingsIdx; ///< Index for next sample in load cell large rolling average sample array. static DG_LOAD_CELLS_CAL_RECORD_T loadCellsCalRecord; ///< Load cells calibration record. +static BOOL hasLoadCellBeenTared[ NUM_OF_LOAD_CELLS ]; ///< Flags indicating whether loadcells have been tared yet. // ********** private function prototypes ********** @@ -95,7 +96,7 @@ * @details Outputs: LoadCell module initialized. * @return none *************************************************************************/ - void initLoadCell( void ) +void initLoadCell( void ) { U32 i; U32 j; @@ -105,21 +106,24 @@ loadCellDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; loadCellFilterTimerCount = 0; + // Initialize load cell filter data and set calibration data as benign until loaded from non-volatile memory for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { benignPolynomialCalRecord( &loadCellsCalRecord.loadCells[ i ] ); - loadcells[ i ].rawReading = 0; - loadcells[ i ].weight.data = 0.0; - loadcells[ i ].weight.ovData = 0.0; - loadcells[ i ].weight.ovInitData = 0.0; - loadcells[ i ].weight.override = OVERRIDE_RESET; - loadcells[ i ].autoCalOffset = 0.0; - loadcells[ i ].largeFilterTotal = 0.0; - loadcells[ i ].largeFilteredWeight = 0.0; - loadcells[ i ].smallFilterTotal = 0.0; - loadcells[ i ].smallFilteredWeight = 0.0; + hasLoadCellBeenTared[ i ] = FALSE; + loadcells[ i ].rawReading = 0; + loadcells[ i ].weight = 0.0; + loadcells[ i ].autoCalOffset = 0.0; + loadcells[ i ].largeFilterTotal = 0.0; + loadcells[ i ].largeFilteredWeight = 0.0; + loadcells[ i ].smallFilterTotal = 0.0; + loadcells[ i ].smallFilteredWeight.data = 0.0; + loadcells[ i ].smallFilteredWeight.ovData = 0.0; + loadcells[ i ].smallFilteredWeight.ovInitData = 0.0; + loadcells[ i ].smallFilteredWeight.override = OVERRIDE_RESET; + for ( j = 0; j < SIZE_OF_SMALL_LOAD_CELL_AVG; j++ ) { loadcells[ i ].smallFilterReadings[ j ] = 0.0; @@ -198,11 +202,11 @@ // Apply the calibration factors to the data. // load_cell_weight = fourth_order_coeff * (load_cell^4) + third_order_coeff * (load_cell^3) + second_order_coeff * (load_cell^2) + gain * load_cell + offset - loadcells[ ii ].weight.data = pow(loadCell, 4) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].fourthOrderCoeff + - pow(loadCell, 3) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].thirdOrderCoeff + - pow(loadCell, 2) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].secondOrderCoeff + - loadCell * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].gain + - loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].offset; + loadcells[ ii ].weight = pow(loadCell, 4) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].fourthOrderCoeff + + pow(loadCell, 3) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].thirdOrderCoeff + + pow(loadCell, 2) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].secondOrderCoeff + + loadCell * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].gain + + loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].offset; loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -213,13 +217,13 @@ loadcells[ ii ].smallFilterTotal += getLoadCellWeight( (LOAD_CELL_ID_T)ii ); // Calculate the load cell value before applying calibration to it - loadcells[ ii ].smallFilteredWeight = (F32)( loadcells[ ii ].smallFilterTotal / (F64)SIZE_OF_SMALL_LOAD_CELL_AVG ); + loadcells[ ii ].smallFilteredWeight.data = (F32)( loadcells[ ii ].smallFilterTotal / (F64)SIZE_OF_SMALL_LOAD_CELL_AVG ); // Monitor the load cells weight monitorLoadCellsWeightOutOfRange( (LOAD_CELL_ID_T)ii ); // Apply the tare offset. NOTE: tare must be applied after checking the weight out of range. - loadcells[ ii ].smallFilteredWeight -= loadcells[ ii ].autoCalOffset; + loadcells[ ii ].smallFilteredWeight.data -= loadcells[ ii ].autoCalOffset; } smallReadingsIdx = INC_WRAP( smallReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 ); @@ -231,8 +235,8 @@ { // Update large filter with new small filter weight sample loadcells[ ii ].largeFilterTotal -= loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ]; - loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ] = loadcells[ ii ].smallFilteredWeight; - loadcells[ ii ].largeFilterTotal += loadcells[ ii ].smallFilteredWeight; + loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ] = getLoadCellSmallFilteredWeight((LOAD_CELL_ID_T) ii); + loadcells[ ii ].largeFilterTotal += getLoadCellSmallFilteredWeight((LOAD_CELL_ID_T) ii); loadcells[ ii ].largeFilteredWeight = (F32)( loadcells[ ii ].largeFilterTotal / (F64)SIZE_OF_LARGE_LOAD_CELL_AVG ); } @@ -325,7 +329,7 @@ F32 weight = getLoadCellSmallFilteredWeight( loadCellID ); // Check if the load cell is being tared for the first time - if ( fabs( loadcells[ loadCellID ].autoCalOffset ) < NEARLY_ZERO ) + if ( hasLoadCellBeenTared[ loadCellID ] != TRUE ) { // For the first tare, the weight of the reservoir should be considered // The current weight of the load cell should not be greater than the weight of the reservoir + the extra weight @@ -340,7 +344,8 @@ if ( FALSE == isWeightOutOfRange ) { // Add old auto calibration offset to get back to actual weight value - loadcells[ loadCellID ].autoCalOffset = ( loadcells[ loadCellID ].smallFilteredWeight + loadcells[ loadCellID ].autoCalOffset ); + loadcells[ loadCellID ].autoCalOffset = ( loadcells[ loadCellID ].smallFilteredWeight.data + loadcells[ loadCellID ].autoCalOffset ); + hasLoadCellBeenTared[ loadCellID ] = TRUE; } else { @@ -373,14 +378,11 @@ *************************************************************************/ F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ) { - F32 result = loadcells[ loadCellID ].weight.data; + F32 result = 0.0; if ( loadCellID < NUM_OF_LOAD_CELLS ) { - if ( OVERRIDE_KEY == loadcells[ loadCellID ].weight.override ) - { - result = loadcells[ loadCellID ].weight.ovData; - } + result = loadcells[ loadCellID ].weight; } else { @@ -405,7 +407,12 @@ if ( loadCellID < NUM_OF_LOAD_CELLS ) { - result = loadcells[ loadCellID ].smallFilteredWeight; + result = loadcells[ loadCellID ].smallFilteredWeight.data; + + if ( OVERRIDE_KEY == loadcells[ loadCellID ].smallFilteredWeight.override ) + { + result = loadcells[ loadCellID ].smallFilteredWeight.ovData; + } } else { @@ -469,6 +476,8 @@ * @brief * The monitorLoadCellsWeightOutOfRange function monitors the weight of the * load cells and if they are not in range, it raises an alarm. + * Function must be called prior to applying tare so that un-tared weight + * is checked for out of range. * @details Inputs: none * @details Outputs: none * @param loadCell which is the load cell ID that its range is checked @@ -477,7 +486,7 @@ static void monitorLoadCellsWeightOutOfRange( LOAD_CELL_ID_T loadCell ) { F32 weight = getLoadCellSmallFilteredWeight( loadCell ); - BOOL isWeightOutOfRange = ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ); + BOOL isWeightOutOfRange = ( ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ) ? TRUE : FALSE ); checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_WEIGHT_OUT_OF_RANGE, isWeightOutOfRange, weight, LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ); } @@ -551,8 +560,8 @@ { result = TRUE; // Add tare to given value so reported load will be what is requested when tare is subtracted later - loadcells[ loadCellID ].weight.ovData = value + loadcells[ loadCellID ].autoCalOffset; - loadcells[ loadCellID ].weight.override = OVERRIDE_KEY; + loadcells[ loadCellID ].smallFilteredWeight.ovData = value; + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_KEY; } } @@ -576,8 +585,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - loadcells[ loadCellID ].weight.override = OVERRIDE_RESET; - loadcells[ loadCellID ].weight.ovData = loadcells[ loadCellID ].weight.ovInitData; + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_RESET; + loadcells[ loadCellID ].smallFilteredWeight.ovData = loadcells[ loadCellID ].smallFilteredWeight.ovInitData; } } Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -7,8 +7,8 @@ * * @file ROPump.c * -* @author (last) Dara Navaei -* @date (last) 25-May-2022 +* @author (last) Bill Bracken +* @date (last) 25-Aug-2022 * * @author (original) Sean * @date (original) 04-Apr-2020 @@ -37,9 +37,6 @@ #include "TaskPriority.h" #include "Timers.h" #include "Valves.h" -#ifdef EMC_TEST_BUILD -#include "Heaters.h" -#endif /** * @addtogroup ROPump @@ -57,7 +54,7 @@ #define ROP_RAMP_UP_CONTROL_INTERVAL ( 500 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO pump is controlled. #define ROP_RAMP_UP_P_COEFFICIENT 0.22F ///< P term for RO pump ramp up to flow control. #define ROP_FLOW_CONTROL_P_COEFFICIENT 0.4F ///< P term for RO pump flow control. -#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.05F ///< I term for RO pump flow control. +#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.3F ///< I term for RO pump flow control. #define ROP_MAX_PRESSURE_P_COEFFICIENT 0.01F ///< P term for RO pump max pressure control. #define ROP_MAX_PRESSURE_I_COEFFICIENT 0.01F ///< I term for RO pump max pressure control. @@ -66,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: @@ -79,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. @@ -93,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. @@ -118,34 +112,22 @@ // ********** private data ********** -static RO_PUMP_STATE_T roPumpState = RO_PUMP_OFF_STATE; ///< Current state of RO pump controller state machine. -static U32 roPumpDataPublicationTimerCounter = 0; ///< Used to schedule RO pump data publication to CAN bus. -static BOOL isROPumpOn = FALSE; ///< RO pump is currently running. -static F32 roPumpPWMDutyCyclePct = 0.0; ///< Initial RO pump PWM duty cycle. -static F32 roPumpDutyCyclePctSet = 0.0; ///< Currently set RO pump PWM duty cycle. -static F32 roPumpFeedbackDutyCyclePct = 0.0; ///< RO pump feedback duty cycle in percent. -static PUMP_CONTROL_MODE_T roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested RO pump control mode. - -static F32 pendingROPumpCmdMaxPressure = 0.0; ///< Delayed (pending) RO pump max pressure (in PSI) setting. -static F32 pendingROPumpCmdTargetFlow = 0.0; ///< Delayed (pending) RO pump target flow rate (in mL/min) setting. -static U32 pendingROPumpCmdCountDown = 0; ///< Delayed (pending) RO pump command count down timer (in task intervals). - +static RO_PUMP_STATE_T roPumpState; ///< Current state of RO pump controller state machine. +static U32 roPumpDataPublicationTimerCounter; ///< Used to schedule RO pump data publication to CAN bus. +static BOOL isROPumpOn; ///< RO pump is currently running. +static F32 roPumpPWMDutyCyclePct; ///< Initial RO pump PWM duty cycle. +static F32 roPumpDutyCyclePctSet; ///< Currently set RO pump PWM duty cycle. +static F32 roPumpFeedbackDutyCyclePct; ///< RO pump feedback duty cycle in percent. +static PUMP_CONTROL_MODE_T roPumpControlMode; ///< Requested RO pump control mode. +static F32 pendingROPumpCmdMaxPressure; ///< Delayed (pending) RO pump max pressure (in PSI) setting. +static F32 pendingROPumpCmdTargetFlow; ///< Delayed (pending) RO pump target flow rate (in mL/min) setting. +static U32 pendingROPumpCmdCountDown; ///< Delayed (pending) RO pump command count down timer (in task intervals). static F32 targetROPumpFlowRateLPM; ///< Target RO flow rate (in L/min). -static F32 targetROPumpMaxPressure = 0.0; ///< Target RO max allowed pressure (in PSI). - +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 = 0; ///< Determines when to perform control on RO pump. - -static F32 roPumpOpenLoopTargetDutyCycle = 0; ///< Target RO pump open loop PWM. - -static S32 measuredFlowReadingsSum = 0; ///< Raw flow reading sums for averaging. -static U32 flowFilterCounter = 0; ///< 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 U32 roControlTimerCounter; ///< Determines when to perform control on RO pump. +static F32 roPumpOpenLoopTargetDutyCycle; ///< Target RO pump open loop PWM. static F32 roVolumeL; ///< RO water generated in liters. // ********** private function prototypes ********** @@ -165,9 +147,10 @@ * @brief * The initROPump function initializes the RO Pump module. * @details Inputs: roControlTimerCounter,roPumpOpenLoopTargetDutyCycle, - * roPumpFlowRateRunningSum, roPumpPressureRunningSum, measuredFlowReadingsSum, - * flowFilterCounter, flowVerificationCounter, roPumpState, roPumpControlMode - * roPumpDataPublicationTimerCounter, rawFlowLP + * roPumpPressureRunningSum, flowFilterCounter, flowVerificationCounter, + * roPumpState, roPumpControlMode, roPumpDataPublicationTimerCounter, rawFlowLP, + * roPumpPWMDutyCyclePct, roPumpDutyCyclePctSet, pendingROPumpCmdMaxPressure, + * pendingROPumpCmdTargetFlow, pendingROPumpCmdCountDown, targetROPumpMaxPressure, * @details Outputs: none * @return none *************************************************************************/ @@ -197,15 +180,19 @@ // 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; isROPumpOn = FALSE; roPumpFeedbackDutyCyclePct = 0.0; roVolumeL = 0.0; targetROPumpFlowRateLPM = 0.0; + roPumpPWMDutyCyclePct = 0.0; + roPumpDutyCyclePctSet = 0.0; + pendingROPumpCmdMaxPressure = 0.0; + pendingROPumpCmdTargetFlow = 0.0; + pendingROPumpCmdCountDown = 0; + targetROPumpMaxPressure = 0.0; } /*********************************************************************//** @@ -234,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 @@ -346,69 +333,32 @@ 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 { - // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V - // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). - roPumpFeedbackDutyCyclePct = 1.0 - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); - // To monitor the flow, the control mode must be in closed loop mode and the pump should be control to flow state // If the pump is controlled to the maximum pressure, the flow might be different from the target flow for more than 10% // 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.0 - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); + BOOL isFlowOutOfRange = ( fabs( 1.0F - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); // Figure out whether flow is out of range from which side BOOL isFlowOutOfUpperRange = ( isFlowOutOfRange && ( currentFlow > targetFlow ) ? TRUE : FALSE ); BOOL isFlowOutOfLowerRange = ( isFlowOutOfRange && ( currentFlow < targetFlow ) ? TRUE : FALSE ); @@ -417,18 +367,23 @@ checkPersistentAlarm( ALARM_ID_FLOW_RATE_OUT_OF_LOWER_RANGE, isFlowOutOfLowerRange, currentFlow, targetFlow ); } - // Check whether the Duty cycle is out of range - BOOL isDCOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V + // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). + roPumpFeedbackDutyCyclePct = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); + isDutyCylceOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); - /* TODO this is commented out until the DVT boards are available - checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDCOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); + checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDutyCylceOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); - // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown - - if ( ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) - { - activateSafetyShutdown(); - }*/ + // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown + if ( ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) + { + activateSafetyShutdown(); + } + } } // Publish RO pump data on interval @@ -503,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; } @@ -551,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 @@ -591,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 ) @@ -601,6 +517,18 @@ /*********************************************************************//** * @brief + * The resetROGenerateVolumeL function resets the RO generated volume in liters. + * @details Inputs: none + * @details Outputs: roVolumeL + * @return none + *************************************************************************/ +void resetROGenerateVolumeL( void ) +{ + roVolumeL = 0.0; +} + +/*********************************************************************//** + * @brief * The handleROPumpOffState function handles the RO pump off state of the * controller state machine. * @details Inputs: roPumpControlMode, roPumpPWMDutyCyclePctSet, @@ -613,7 +541,7 @@ RO_PUMP_STATE_T state = RO_PUMP_OFF_STATE; // If there is a flow, transition to the PI controller to get the corresponding pressure of that flow - if ( getTargetROPumpFlowRateLPM() > 0 && roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) + if ( getTargetROPumpFlowRateLPM() > 0.0F && roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) { // Set pump to on isROPumpOn = TRUE; @@ -623,7 +551,7 @@ } // If the target duty cycle is greater than zero (minimum is 10%) and the mode has been set to open // loop, set the duty cycle - if ( roPumpOpenLoopTargetDutyCycle > 0 && roPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) + if ( roPumpOpenLoopTargetDutyCycle > 0.0F && roPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) { setROPumpControlSignalDutyCycle( roPumpOpenLoopTargetDutyCycle ); isROPumpOn = TRUE; @@ -650,7 +578,7 @@ // Get the current pressure from the sensor F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); F32 targetFlowRate = getTargetROPumpFlowRateLPM(); - F32 actualFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); //(F32)getMeasuredROFlowRateLPM(); + F32 actualFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); F32 flowRateDeviation = fabs( targetFlowRate - actualFlowRate ) / targetFlowRate; BOOL isFlowOutOfRange = flowRateDeviation > ROP_FLOW_TARGET_TOLERANCE; F32 targetPressure = getTargetROPumpPressure(); @@ -714,7 +642,7 @@ } else { - roPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, getTargetROPumpFlowRateLPM(), getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) /*getMeasuredROFlowRateLPM()*/ ); + roPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, getTargetROPumpFlowRateLPM(), getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) ); } setROPumpControlSignalDutyCycle( roPumpDutyCyclePctSet ); @@ -750,7 +678,7 @@ } else { - roPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_RO_PUMP_MAX_PRES, getTargetROPumpFlowRateLPM(), getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) /*getMeasuredROFlowRateLPM()*/ ); + roPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_RO_PUMP_MAX_PRES, getTargetROPumpFlowRateLPM(), getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) ); } setROPumpControlSignalDutyCycle( roPumpDutyCyclePctSet ); @@ -847,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; @@ -972,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/Services/AlarmMgmt.c =================================================================== diff -u -r9826fc85bd1497ec617ae0e825f78b91972de2b3 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 9826fc85bd1497ec617ae0e825f78b91972de2b3) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -185,7 +185,7 @@ * @return none *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) -{ +{ // broadcast alarm and data if alarm not already active if ( ( FALSE == alarmIsActive[ alarm ] ) && ( TRUE == isHDCommunicating() ) ) { Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rcd3f58205f4dab89291b29ee73b7fa9c31773abc -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -29,6 +29,7 @@ #include "OperationModes.h" #include "PersistentAlarm.h" #include "SystemCommMessages.h" +#include "Timers.h" #include "Utilities.h" /** @@ -94,9 +95,12 @@ #define FPGA_GPIO_POWER_STATUS_PIN 7 ///< FPGA GPIO power status pin. #define FPGA_READ_V3_START_BYTE_NUM 256 ///< FPGA V3 read sensors start byte number. #define FPGA_READ_V3_END_BYTE_NUM 430 ///< FPGA V3 read sensors end byte number. + /// FPGA size of V3 read bytes. #define FPGA_SIZE_OF_V3_READ_BYTES ( FPGA_READ_V3_END_BYTE_NUM - FPGA_READ_V3_START_BYTE_NUM ) +#define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. + // FPGA header struct. #pragma pack(push,1) typedef struct @@ -343,6 +347,10 @@ static DG_FPGA_SENSORS_T fpgaSensorReadings; ///< DG FPGA sensors structure. static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< FPGA actuator set points structure. static U08 fpgaReadByteSize; ///< FPGA read byte size. +#ifndef DEBUG_ENABLED +static U16 currentFPGATimerCount_ms; ///< Current FPGA timer count in ms. +static U32 currentTimerCount_ms; ///< Current processor timer count in ms. +#endif // ********** private function prototypes ********** @@ -578,8 +586,6 @@ fpgaState = handleFPGAReceiveHeaderState(); break; - // TODO - sensor/ADC init/configuration states - case FPGA_STATE_RCV_ALL_SENSORS: fpgaState = handleFPGAReceiveAllSensorsState(); break; @@ -643,8 +649,6 @@ fpgaState = handleFPGAReadHeaderState(); break; - // TODO - sensor/ADC init/configuration states - case FPGA_STATE_WRITE_ALL_ACTUATORS: fpgaState = handleFPGAWriteAllActuatorsState(); break; @@ -891,6 +895,38 @@ /*********************************************************************//** * @brief + * The execFPGAClockSpeedTest function verifies the processor clock speed + * against the FPGA clock. + * @details Inputs: fpgaHeader + * @details Outputs: none + * @return passed, or failed + *************************************************************************/ +void execFPGAClockSpeedTest( void ) +{ +#ifndef DEBUG_ENABLED + U16 const newFPGATimerCount_ms = getFPGATimerCount(); + U32 const newTimerCount_ms = getMSTimerCount(); + U32 const diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); + U32 const diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); + + if ( getCurrentOperationMode() != DG_MODE_INIT ) + { + if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) + { + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); + } + } + } + + currentFPGATimerCount_ms = newFPGATimerCount_ms; + currentTimerCount_ms = newTimerCount_ms; +#endif +} + +/*********************************************************************//** + * @brief * The setupDMAForWriteCmd function sets the byte count for the next DMA * write command to the FPGA. * @details Inputs: none @@ -2031,7 +2067,8 @@ *************************************************************************/ U16 getFPGATimerCount( void ) { - return fpgaSensorReadings.fpgaTimerCountMS; + //return fpgaSensorReadings.fpgaTimerCountMS; // Commented for testing ONLY. TODO: uncomment DN-20SEPT2022 + return fpgaSensorReadings.fpgaTimerCountMS + 5; // + 5 for tetsing ONLY. TODO: remove this line. DN-20SEPT2022 } /*********************************************************************//** Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rb49fcf5c295e49f7133ea07398c54b083bf65d49 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision b49fcf5c295e49f7133ea07398c54b083bf65d49) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -36,6 +36,7 @@ void initFPGA( void ); void execFPGAIn( void ); void execFPGAOut( void ); +void execFPGAClockSpeedTest( void ); SELF_TEST_STATUS_T execFPGATest( void ); void signalFPGAReceiptCompleted( void ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r7bd4510581254bc4e7292159c630a95b6ab4b368 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 7bd4510581254bc4e7292159c630a95b6ab4b368) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -7,8 +7,8 @@ * * @file SystemComm.c * -* @author (last) Dara Navaei -* @date (last) 23-May-2022 +* @author (last) Michael Garthwaite +* @date (last) 08-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -819,6 +819,10 @@ handleAlarmClear( message ); break; + case MSG_ID_RTC_EPOCH: + handleRTCSyncFromHD( message ); + break; + case MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS: handleSetDialysateTemperatureCmd( message ); break; @@ -880,7 +884,7 @@ handleDGPOSTResultRequest( message ); break; - case MSG_ID_UI_REQUEST_SERVICE_INFO: + case MSG_ID_HD_REQUEST_DG_SERVICE_RECORD: handleDGServiceScheduleRequest( message ); break; @@ -892,6 +896,14 @@ handleDGScheduledRunsRequest( message ); break; + case MSG_ID_HD_REQUEST_DG_SERVICE_MODE: + handleServiceModeRequest( message ); + break; + + case MSG_ID_HD_REQUEST_DG_USAGE_INFO: + handleHDRequestDGUsageInfo( message ); + break; + // NOTE: This case must be last case MSG_ID_DG_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); @@ -940,20 +952,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: @@ -1064,10 +1072,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; @@ -1133,11 +1137,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: @@ -1148,10 +1152,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; @@ -1164,6 +1164,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; @@ -1196,6 +1200,14 @@ handleSetDGUsageInfoRecord( 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; Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -ra89d6b091874136d75a9bfbdbbc1ff00f42467b3 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision a89d6b091874136d75a9bfbdbbc1ff00f42467b3) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -23,6 +23,7 @@ #include "DrainPump.h" #include "Fans.h" #include "Heaters.h" +#include "Integrity.h" #include "NVDataMgmt.h" #include "OperationModes.h" #include "Reservoirs.h" @@ -128,6 +129,9 @@ // Run alarm management execAlarmMgmt(); + // Monitor RAM error status + execRAMMonitor(); + // manage data to be transmitted to other sub-systems execSystemCommTx(); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r19056bcb960b73405326d038abcea63b6862e344 -r237bd674ddef86d5137221163e74162cd12e4fb9 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 19056bcb960b73405326d038abcea63b6862e344) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 237bd674ddef86d5137221163e74162cd12e4fb9) @@ -8,7 +8,7 @@ * @file TaskPriority.c * * @author (last) Dara Navaei -* @date (last) 23-May-2022 +* @date (last) 06-Jul-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -28,7 +28,6 @@ #include "LoadCell.h" #include "Pressures.h" #include "ROPump.h" -#include "DialysateFlow.h" #include "TaskPriority.h" #include "TemperatureSensors.h" #include "Valves.h" @@ -71,9 +70,6 @@ // Monitor load cells execLoadCell(); - - // Monitor dialysate flow meter - execDialysateFlowMeterMonitor(); // Temperature sensors read execTemperatureSensors(); @@ -102,6 +98,7 @@ // Monitor fluid leak detector execFluidLeak(); + // Monitor flow sensors execFlowSesnorsMonitor(); // Second pass for FPGA