Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r4cabd64c4ff295eb985f0a62132fef94c4e92921 -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 4cabd64c4ff295eb985f0a62132fef94c4e92921) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -30,7 +30,7 @@ #include "TaskGeneral.h" #include "TaskPriority.h" #include "TDInterface.h" -#include "TemperatureSensors.h" +#include "Temperature.h" #include "Timers.h" #include "Utilities.h" @@ -551,7 +551,8 @@ if ( D5_HEAT == heater ) { - measuredTemperature = getTemperatureValue( D4_TEMP ); + // measuredTemperature = getTemperatureValue( D4_TEMP ); + measuredTemperature = getD4AverageTemperature(); if ( DD_MODE_HEAT != opMode ) { @@ -577,7 +578,8 @@ } else { - measuredTemperature = getTemperatureValue( D50_TEMP ); + //measuredTemperature = getTemperatureValue( D50_TEMP ); + measuredTemperature = getD50AverageTemperature(); if ( DD_MODE_HEAT != opMode ) { @@ -629,7 +631,8 @@ { if ( D5_HEAT == heater ) { - measuredTemperature = getTemperatureValue( D4_TEMP ); + //measuredTemperature = getTemperatureValue( D4_TEMP ); + measuredTemperature = getD4AverageTemperature(); // Inlet temperature post heat exchanger inletTemperature = getTemperatureValue( X6_TEMP ); @@ -662,7 +665,8 @@ } else { - measuredTemperature = getTemperatureValue( D50_TEMP ); + //measuredTemperature = getTemperatureValue( D50_TEMP ); + measuredTemperature = getD50AverageTemperature(); ctrl = runPIController( PI_CONTROLLER_ID_D45_HEAT, targetTemperature, measuredTemperature ); control[ heater ].data = ctrl; Index: firmware/App/DDCommon.h =================================================================== diff -u -r7f20b8512feec18ea42651ca6e77834e6b0ed87d -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 7f20b8512feec18ea42651ca6e77834e6b0ed87d) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -46,7 +46,7 @@ //#define __PITEST__ 1 //Uncomment below if diener concentrate pump used -#define __DIENER_CONC_PUMP__ 1 +//#define __DIENER_CONC_PUMP__ 1 //Uncomment below if barometric pressure sensor reading available //#define __BARO_PRES_SENSOR__ 1 Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -rbc30c54270ec51f947b129da3c7daad54ec4eb5f -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision bc30c54270ec51f947b129da3c7daad54ec4eb5f) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -21,6 +21,7 @@ #include "ModeFault.h" #include "Messaging.h" #include "OperationModes.h" +#include "SafetyShutdown.h" #include "Utilities.h" #include "Valves.h" @@ -36,13 +37,17 @@ // ********** private data ********** static DD_FAULT_STATE_T faultState; ///< Currently active fault state. +static DD_FAULT_NVDATA_STATE_T faultNVDataState; ///< Currently active NVdata fault state static SELF_TEST_STATUS_T faultPOSTSelfTestResult; ///< Fault POST self test result. // ********** private function prototypes ********** - static DD_FAULT_STATE_T handleFaultStartState( void ); -static DD_FAULT_STATE_T handleFaultRunNVPOSTsState( void ); +static DD_FAULT_STATE_T handleFaultDeenergizedState( void ); +static DD_FAULT_STATE_T handleFaultEnergizedState( void ); +static DD_FAULT_NVDATA_STATE_T handleFaultNVDataMgmtStartState( void ); +static DD_FAULT_NVDATA_STATE_T handleFaultRunNVPOSTsState( void ); + /*********************************************************************//** * @brief * The initFaultMode function initializes the Fault Mode unit. @@ -53,6 +58,7 @@ void initFaultMode( void ) { faultState = DD_FAULT_STATE_START; + faultNVDataState = DD_FAULT_NVDATA_STATE_START; faultPOSTSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; } @@ -65,8 +71,6 @@ *************************************************************************/ U32 transitionToFaultMode( void ) { - deenergizeActuators( PARK_CONC_PUMPS ); - initFaultMode(); setCurrentSubState( NO_SUB_STATE ); // Publish POST failure status to UI if fault triggered in Init/POST mode @@ -82,25 +86,27 @@ /*********************************************************************//** * @brief * The execFaultMode function executes the fault mode state machine. - * @details \b Inputs: none + * @details \b Inputs: faultState * @details \b Outputs: Fault mode state machine executed * @return current state of fault mode *************************************************************************/ U32 execFaultMode( void ) { - deenergizeActuators( NO_PARK_CONC_PUMPS ); - // execute current fault state switch ( faultState ) { case DD_FAULT_STATE_START: faultState = handleFaultStartState(); break; - case DD_FAULT_STATE_RUN_NV_POSTS: - faultState = handleFaultRunNVPOSTsState(); + case DD_FAULT_DEENERGIZED_STATE: + faultState = handleFaultDeenergizedState(); break; + case DD_FAULT_ENERGIZED_STATE: + faultState = handleFaultEnergizedState(); + break; + case DD_FAULT_STATE_COMPLETE: // Do nothing unless the test configuration to recover treatment is enabled if ( ( TRUE == getTestConfigStatus( TEST_CONFIG_RECOVER_TREATMENT ) ) && ( TRUE == hasRecoverFromFaultModeBeenSet() ) ) @@ -121,6 +127,39 @@ /*********************************************************************//** * @brief + * The execFaultNVdataMgmt function executes the fault mode NVData + * management state machine. + * @details \b Inputs: faultNVDataState + * @details \b Outputs: Fault mode NVdata state machine executed + * @return current state of fault NVDATA management mode + *************************************************************************/ +U32 execFaultNVdataMgmt( void ) +{ + // execute current fault NVData state manangement state + switch ( faultNVDataState ) + { + case DD_FAULT_NVDATA_STATE_START: + faultNVDataState = handleFaultNVDataMgmtStartState(); + break; + + case DD_FAULT_NVDATA_STATE_RUN_NV_POSTS: + faultNVDataState = handleFaultRunNVPOSTsState(); + break; + + case DD_FAULT_NVDATA_STATE_COMPLETE: + //Do Nothing + break; + + default: + faultNVDataState = DD_FAULT_NVDATA_STATE_COMPLETE; + break; + } + + return faultNVDataState; +} + +/*********************************************************************//** + * @brief * The getCurrentFaultState function returns the current state of the fault mode. * @details \b Inputs: faultState * @details \b Outputs: none @@ -145,7 +184,6 @@ U32 i; // De-energize all the hydraulics valves - // TODO : valve state name needs to be updated setValveStateDelayed( D53_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); setValveStateDelayed( D52_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); setValveStateDelayed( D8_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); @@ -167,13 +205,15 @@ setValveStateDelayed( (VALVES_T)i, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); } + // TODO: To be removed once HDD clean up is done for ( i = FIRST_UF_VALVE; i <= FIRST_UF_VALVE; i++ ) { setValveStateDelayed( (VALVES_T)i, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); } requestConcentratePumpOff( D11_PUMP, parkPumps ); requestConcentratePumpOff( D10_PUMP, parkPumps ); + requestConcentratePumpOff( D76_PUMP, parkPumps ); signalDialysatePumpHardStop( D12_PUMP ); signalDialysatePumpHardStop( D48_PUMP ); stopHeater( D5_HEAT ); @@ -182,14 +222,144 @@ /*********************************************************************//** * @brief - * The handleFaultStartState function handles the start state of the fault mode. + * The deenergizeActuatorsWithDrainEnabled function sets most of the actuators + * to reset and de-energized state, except drain and spent balancing chamber + * valves enabled. * @details \b Inputs: none * @details \b Outputs: none - * @return next state + * @param parkPumps TRUE if concentrate pumps should be parked, FALSE if not + * @return none *************************************************************************/ +void deenergizeActuatorsWithDrainEnabled( BOOL parkPumps ) +{ + U32 i; + + // Energize drain and spent balancing chamber valves to relieve the pressure. + setValveState( D53_VALV, VALVE_STATE_OPEN ); + setValveState( D23_VALV, VALVE_STATE_OPEN ); + setValveState( D24_VALV, VALVE_STATE_OPEN ); + setValveState( D25_VALV, VALVE_STATE_OPEN ); + setValveState( D26_VALV, VALVE_STATE_OPEN ); + + // De-energize hydraulics valves + setValveStateDelayed( D52_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D8_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D54_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D14_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D65_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D64_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D31_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D34_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D35_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D40_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D47_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D3_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( M4_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + + // De-energize portion of balancing chamber valves. + setValveStateDelayed( D19_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D20_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D21_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + setValveStateDelayed( D22_VALV, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + + // TODO: To be removed once HDD clean up is done + // De-energize Ultrafiltration valves + for ( i = FIRST_UF_VALVE; i <= FIRST_UF_VALVE; i++ ) + { + setValveStateDelayed( (VALVES_T)i, VALVE_STATE_CLOSED, DELAY_VALVE_MS ); + } + + requestConcentratePumpOff( D11_PUMP, parkPumps ); + requestConcentratePumpOff( D10_PUMP, parkPumps ); + requestConcentratePumpOff( D76_PUMP, parkPumps ); + signalDialysatePumpHardStop( D12_PUMP ); + signalDialysatePumpHardStop( D48_PUMP ); + stopHeater( D5_HEAT ); + stopHeater( D45_HEAT ); +} + +/*********************************************************************//** + * @brief + * The handleFaultStartState function handles the start state of + * the fault mode. + * @details \b Inputs: safetyShutdownActivated + * @details \b Outputs: none + * @return next fault state + *************************************************************************/ static DD_FAULT_STATE_T handleFaultStartState( void ) { - DD_FAULT_STATE_T state = DD_FAULT_STATE_START; + DD_FAULT_STATE_T state = DD_FAULT_STATE_START; + + // Check saftey shutdown line already pulled + if ( TRUE == isSafetyShutdownActivated() ) + { + state = DD_FAULT_DEENERGIZED_STATE; + } + else + { + state = DD_FAULT_ENERGIZED_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleFaultDeenergizedState function handles the deenergized + * state of the fault mode. + * @details \b Inputs: faultNVDataState + * @details \b Outputs: none + * @return fault state + *************************************************************************/ +static DD_FAULT_STATE_T handleFaultDeenergizedState( void ) +{ + DD_FAULT_STATE_T state = DD_FAULT_DEENERGIZED_STATE; + + deenergizeActuators( NO_PARK_CONC_PUMPS ); + + //Make sure the stored config datas read completely. + execFaultNVdataMgmt(); + + return state; +} + +/*********************************************************************//** + * @brief + * The handleFaultEnergizedState function handles the energized + * state of the fault mode (by enabling few valves). + * @details \b Inputs: none + * @details \b Outputs: none + * @return fault state + *************************************************************************/ +static DD_FAULT_STATE_T handleFaultEnergizedState( void ) +{ + DD_FAULT_STATE_T state = DD_FAULT_ENERGIZED_STATE; + + deenergizeActuatorsWithDrainEnabled( NO_PARK_CONC_PUMPS ); + + //Make sure the stored config datas read completely. + execFaultNVdataMgmt(); + + //if saftey shutdown line pulled meanwhile, trainsition to deenergized state + if ( TRUE == isSafetyShutdownActivated() ) + { + state = DD_FAULT_DEENERGIZED_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleFaultNVDataMgmtStartState function handles the start state of + * the fault NVdata management. + * @details \b Inputs: none + * @details \b Outputs: none + * @return next fault NVdata management state + *************************************************************************/ +static DD_FAULT_NVDATA_STATE_T handleFaultNVDataMgmtStartState( void ) +{ + DD_FAULT_NVDATA_STATE_T state = DD_FAULT_NVDATA_STATE_START; //NVDATAMGMT_RECORDS_READ_STATUS_T status = getNVRecordsReadStatus(); // switch ( status ) @@ -198,12 +368,12 @@ // // their CRCs. // case NVDATAMGMT_RECORDS_QUEUED: // case NVDATAMGMT_RECORDS_READ: -// state = DD_FAULT_STATE_RUN_NV_POSTS; +// state = DD_FAULT_NVDATA_STATE_RUN_NV_POSTS; // break; // // // If the NV post was completed prior to transitioning to fault mode, do nothing // case NVDATAMGMT_RECORDS_CRC_CHECKED: -// state = DD_FAULT_STATE_COMPLETE; +// state = DD_FAULT_NVDATA_STATE_COMPLETE; // break; // } @@ -215,18 +385,18 @@ * The handleFaultRunNVPOSTsState function handles running non-volatile POSTs. * @details \b Inputs: faultPOSTSelfTestResult * @details \b Outputs: faultPOSTSelfTestResult - * @return next state + * @return next fault NVdata management state *************************************************************************/ -static DD_FAULT_STATE_T handleFaultRunNVPOSTsState( void ) +static DD_FAULT_NVDATA_STATE_T handleFaultRunNVPOSTsState( void ) { - DD_FAULT_STATE_T state = DD_FAULT_STATE_RUN_NV_POSTS; + DD_FAULT_NVDATA_STATE_T state = DD_FAULT_NVDATA_STATE_RUN_NV_POSTS; // faultPOSTSelfTestResult = execNVDataMgmtSelfTest(); // // // Regardless of the status of the NV POST transition to the complete state. // if ( ( SELF_TEST_STATUS_PASSED == faultPOSTSelfTestResult ) || ( SELF_TEST_STATUS_FAILED == faultPOSTSelfTestResult ) ) // { -// state = DD_FAULT_STATE_COMPLETE; +// state = DD_FAULT_NVDATA_STATE_COMPLETE; // } return state; Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -rdc3647b737971d298748796d2455b3e021325d8a -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision dc3647b737971d298748796d2455b3e021325d8a) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -66,7 +66,7 @@ static OVERRIDE_F32_T targetHydChamberFluidTemp; ///< Target hydraulics chamber fluid temperature. static OVERRIDE_U32_T isDialDeliveryInProgress; ///< To indicate dialysate started delivering to dialyzer for treatment (overrideable) static OVERRIDE_U32_T isDialysateGoodtoDeliver; ///< Flag indicating whether ready to deliver dialysate or not. -static OVERRIDE_U32_T pendingStopDDGenDialRequest; ///< Flag indicating TD has requested DD stop the generate dialysate (Overridable). +static BOOL pendingStopDDGenDialRequest; ///< Flag indicating TD has requested DD stop the generate dialysate. static U32 genDialysateDataPublicationTimerCounter; ///< Used to schedule generate dialysate data publication to CAN bus. static OVERRIDE_U32_T genDialysateDataPublishInterval; ///< Generate dialysate mode data publish interval. static BOOL isTreatmentParamUpdated; ///< To indicate change in treatment parameters @@ -107,10 +107,7 @@ isDialDeliveryInProgress.ovData = FALSE; isDialDeliveryInProgress.ovInitData = FALSE; isDialDeliveryInProgress.override = OVERRIDE_RESET; - pendingStopDDGenDialRequest.data = FALSE; - pendingStopDDGenDialRequest.ovData = FALSE; - pendingStopDDGenDialRequest.ovInitData = FALSE; - pendingStopDDGenDialRequest.override = OVERRIDE_RESET; + pendingStopDDGenDialRequest = FALSE; genDialysateDataPublishInterval.data = GEN_DIALYSATE_DATA_PUBLISH_INTERVAL; genDialysateDataPublishInterval.ovData = GEN_DIALYSATE_DATA_PUBLISH_INTERVAL; genDialysateDataPublishInterval.ovInitData = 0; @@ -282,9 +279,9 @@ checkDialysateTemperature(); //TODO: Transition to post gen dialysate then standby. - if ( TRUE == getU32OverrideValue( &pendingStopDDGenDialRequest ) ) + if ( TRUE == pendingStopDDGenDialRequest ) { - pendingStopDDGenDialRequest.data = FALSE; + pendingStopDDGenDialRequest = FALSE; requestNewOperationMode( DD_MODE_STAN ); } // Continuous water inlet pressure check @@ -466,7 +463,7 @@ if ( DD_MODE_GEND == getCurrentOperationMode() ) { - pendingStopDDGenDialRequest.data = TRUE; + pendingStopDDGenDialRequest = TRUE; status = TRUE; } @@ -771,23 +768,6 @@ /*********************************************************************//** * @brief - * The testDDStopGenDialysateOverride function sets the override value - * to stop the gen dialysate operation mode. - * @details Inputs: pendingStopDDGenDialRequest - * @details Outputs: pendingStopDDGenDialRequest - * @param message Override message from Dialin which includes the flag - * to override the operation mode. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDDStopGenDialysateOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &pendingStopDDGenDialRequest, FALSE, TRUE ); - - return result; -} - -/*********************************************************************//** - * @brief * The testGenDExecStateOverride function sets the Gen dialysate execution state * machine to given state. * @details \b Inputs: tester logged in, execStateSet Index: firmware/App/Modes/ModeGenDialysate.h =================================================================== diff -u -r9ff57b5ab7490ee5bbc2c51b25f738ee6c569ec1 -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision 9ff57b5ab7490ee5bbc2c51b25f738ee6c569ec1) +++ firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -32,7 +32,7 @@ // ********** public definitions ********** #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. -#define SPENT_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. +#define SPENT_DIAL_PUMP_INITIAL_RPM 2300 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. /// Generate dialysate mode data structure typedef struct @@ -67,7 +67,6 @@ BOOL testDialGoodToDeliverStatusOverride( MESSAGE_T *message ); // To override the dialysate good to deliver status flag BOOL testGenDHydChamberFluidTempOverride( MESSAGE_T *message ); // Override the hydraulics chamber fluid temperature BOOL testGenDExecStateOverride( MESSAGE_T *message ); // Override the Gen dialysate execution state -BOOL testDDStopGenDialysateOverride( MESSAGE_T *message ); // Override the stop gen dialysate request /**@}*/ Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -r88f86f2dc5107670e32f53e04e256ad8249ba55f -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 88f86f2dc5107670e32f53e04e256ad8249ba55f) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -47,8 +47,8 @@ static DD_WET_SELF_TEST_STATE_T wetSelfTestState; ///< Currently active pre-gen Wet self test state. static U32 hydChamberPressureCheckStartTimeMS; ///< Current time when hydraulics chamber pressure check started in milliseconds. static U32 pressureCheckPersistanceStartTimeMS; ///< Current time for pressure check persistance time started in milliseconds. -static OVERRIDE_U32_T pendingStartDDGenDialRequest; ///< Flag indicating TD has requested DD start the generation dialysate request(Overridable). -static OVERRIDE_U32_T pendingStopDDPreGenDialRequest; ///< Flag indicating TD has requested DD stop the pre generation dialysate (Overridable). +static BOOL pendingStartDDGenDialRequest; ///< Flag indicating TD has requested DD start the generation dialysate request. +static BOOL pendingStopDDPreGenDialRequest; ///< Flag indicating TD has requested DD stop the pre generation dialysate. static U32 preGenDialysatePublishTimerCounter; ///< Pre-Gen Dialysate data broadcast timer counter used to schedule when to transmit data. static OVERRIDE_U32_T preGenDialysateModePublishInterval; ///< Interval (in task intervals) at which to publish pre-gen dialysate mode data to CAN bus. @@ -79,14 +79,8 @@ wetSelfTestState = DD_WET_SELF_TEST_START; hydChamberPressureCheckStartTimeMS = 0; pressureCheckPersistanceStartTimeMS = 0; - pendingStartDDGenDialRequest.data = FALSE; - pendingStartDDGenDialRequest.ovData = FALSE; - pendingStartDDGenDialRequest.ovInitData = FALSE; - pendingStartDDGenDialRequest.override = OVERRIDE_RESET; - pendingStopDDPreGenDialRequest.data = FALSE; - pendingStopDDPreGenDialRequest.ovData = FALSE; - pendingStopDDPreGenDialRequest.ovInitData = FALSE; - pendingStopDDPreGenDialRequest.override = OVERRIDE_RESET; + pendingStartDDGenDialRequest = FALSE; + pendingStopDDPreGenDialRequest = FALSE; preGenDialysateModePublishInterval.data = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovData = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovInitData = 0; @@ -127,15 +121,15 @@ hydChamberWaterInletControl(); //TODO: To be placed in correct states once states defined. - if ( TRUE == getU32OverrideValue( &pendingStartDDGenDialRequest ) ) + if ( TRUE == pendingStartDDGenDialRequest ) { - pendingStartDDGenDialRequest.data = FALSE; + pendingStartDDGenDialRequest = FALSE; requestNewOperationMode( DD_MODE_GEND ); } //TODO: Transition to post gen dialysate if concentrate priming has been started - else if ( TRUE == getU32OverrideValue( &pendingStopDDPreGenDialRequest ) ) + else if ( TRUE == pendingStopDDPreGenDialRequest ) { - pendingStopDDPreGenDialRequest.data = FALSE; + pendingStopDDPreGenDialRequest = FALSE; requestNewOperationMode( DD_MODE_STAN ); } else @@ -194,7 +188,7 @@ if ( DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND == preGenDialysateState ) { result = TRUE; - pendingStartDDGenDialRequest.data = TRUE; + pendingStartDDGenDialRequest = TRUE; } return result; @@ -214,7 +208,7 @@ if ( DD_MODE_PREG == getCurrentOperationMode() ) { - pendingStopDDPreGenDialRequest.data = TRUE; + pendingStopDDPreGenDialRequest = TRUE; status = TRUE; } @@ -477,38 +471,4 @@ return result; } -/*********************************************************************//** - * @brief - * The testDDStartGenDialysateOverride function sets the override value - * to start the gen dialysate operation mode. - * @details Inputs: pendingStartDDGenDialRequest - * @details Outputs: pendingStartDDGenDialRequest - * @param message Override message from Dialin which includes the flag - * to override the operation mode. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDDStartGenDialysateOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &pendingStartDDGenDialRequest, FALSE, TRUE ); - - return result; -} - -/*********************************************************************//** - * @brief - * The testDDStopPreGenDialysateOverride function sets the override value - * to stop the pre gen dialysate operation mode. - * @details Inputs: pendingStopDDPreGenDialRequest - * @details Outputs: pendingStopDDPreGenDialRequest - * @param message Override message from Dialin which includes the flag - * to override the operation mode. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDDStopPreGenDialysateOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &pendingStopDDPreGenDialRequest, FALSE, TRUE ); - - return result; -} - /**@}*/ Index: firmware/App/Modes/ModePreGenDialysate.h =================================================================== diff -u -rf6022e86136c821709ce24b61e11e8e2bdf0b11e -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModePreGenDialysate.h (.../ModePreGenDialysate.h) (revision f6022e86136c821709ce24b61e11e8e2bdf0b11e) +++ firmware/App/Modes/ModePreGenDialysate.h (.../ModePreGenDialysate.h) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -47,8 +47,6 @@ BOOL requestDDPreGenStop( void ); // stop pregenerate dialysate delivery BOOL testDDPreGenDialysateDataPublishIntervalOverride( MESSAGE_T *message ); // pre-gen dialysate publish override request -BOOL testDDStartGenDialysateOverride( MESSAGE_T *message ); // start gen dialysate override request -BOOL testDDStopPreGenDialysateOverride( MESSAGE_T *message ); // stop the pregen dialysate override request /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r6408d79e3a9a543e90b2fa7ab823be348befd391 -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 6408d79e3a9a543e90b2fa7ab823be348befd391) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -43,7 +43,7 @@ static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. -static OVERRIDE_U32_T pendingStartDDPreGenRequest; ///< Flag indicating TD has requested DD start the pre generation dialysate request(Overridable). +static BOOL pendingStartDDPreGenRequest; ///< Flag indicating TD has requested DD start the pre generation dialysate request. static BOOL pendingBalanceChamberSwOnlyRequest; ///< Flag indicating balancing chamber switch only request. //static BOOL pendingStartDDFlushRequest; ///< Flag indicating TD has requested DD start flush. //static BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. @@ -65,10 +65,7 @@ void initStandbyMode( void ) { standbyState = DD_STANDBY_MODE_STATE_IDLE; - pendingStartDDPreGenRequest.data = FALSE; - pendingStartDDPreGenRequest.ovData = FALSE; - pendingStartDDPreGenRequest.ovInitData = FALSE; - pendingStartDDPreGenRequest.override = OVERRIDE_RESET; + pendingStartDDPreGenRequest = FALSE; pendingBalanceChamberSwOnlyRequest = FALSE; // pendingStartDDFlushRequest = FALSE; // pendingStartDDHeatDisinfectRequest = FALSE; @@ -192,9 +189,9 @@ // { // define the alarm // } - if ( TRUE == getU32OverrideValue( &pendingStartDDPreGenRequest ) ) + if ( TRUE == pendingStartDDPreGenRequest ) { - pendingStartDDPreGenRequest.data = FALSE; + pendingStartDDPreGenRequest = FALSE; requestNewOperationMode( DD_MODE_PREG ); } //Test request to handle only balancing chamber switching @@ -261,7 +258,7 @@ if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) { result = TRUE; - pendingStartDDPreGenRequest.data = TRUE; + pendingStartDDPreGenRequest = TRUE; } return result; @@ -502,21 +499,4 @@ *************************************************************************/ -/*********************************************************************//** - * @brief - * The testDDStartPreGenDialysateOverride function sets the override value - * to start the pre-gen dialysate operation mode. - * @details Inputs: pendingStartDDPreGenRequest - * @details Outputs: pendingStartDDPreGenRequest - * @param message Override message from Dialin which includes the flag - * to override the operation mode. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDDStartPreGenDialysateOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &pendingStartDDPreGenRequest, FALSE, TRUE ); - - return result; -} - /**@}*/ Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r6408d79e3a9a543e90b2fa7ab823be348befd391 -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 6408d79e3a9a543e90b2fa7ab823be348befd391) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -54,8 +54,6 @@ BOOL startDDHeatDisinfectActiveCool( void ); DD_STANDBY_MODE_STATE_T getCurrentStandbyState( void ); // get the current state of the standby mode. -BOOL testDDStartPreGenDialysateOverride( MESSAGE_T *message ); // Overide start pre-gen dialysate mode - /**@}*/ #endif Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -34,7 +34,8 @@ #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 D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< D4 temperature sensor moving average number of samples ( 1sec filter ). +#define D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES 25 ///< D50 temperature sensor moving average number of samples ( 250ms filter ). #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. /// Temperature sensor exec states. @@ -48,8 +49,20 @@ // ********** private data ********** static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState; ///< TemperatureSensor exec state. -static U32 startTime; ///< star time to read FPGA values. +static U32 startTime; ///< start time to read FPGA values. +static F32 d4TempAvgC; ///< D4 temperature average in C. +static F32 d4TempRunningSumC; ///< D4 temperature running sum in C. +static F32 d4TempSamplesC[ D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D4 temperature samples array in C. +static U32 d4TempSamplesNextIndex; ///< D4 temperature sample next index number. +static U32 d4TempCount; ///< D4 Number of samples in average buffer. + +static F32 d50TempAvgC; ///< D50 temperature average in C. +static F32 d50TempRunningSumC; ///< D50 temperature running sum in C. +static F32 d50TempSamplesC[ D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D50 temperature samples array in C. +static U32 d50TempSamplesNextIndex; ///< D50 temperature sample next index number. +static U32 d50TempCount; ///< D50 Number of samples in average buffer. + static U32 dataPublicationTimerCounter; ///< Temperature sensors data publish timer counter. static OVERRIDE_U32_T tempSensorsPublishInterval = { TEMP_SENSORS_DATA_PUBLISH_INTERVAL, TEMP_SENSORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Temperature sensors publish time interval override. @@ -58,6 +71,7 @@ static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ); static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ); +static void filterTemperatureReadings( void ); static void publishTemperatureSensorsData( void ); /*********************************************************************//** @@ -69,9 +83,17 @@ *************************************************************************/ void initTemperature( void ) { - startTime = 0; - tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; - dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + startTime = 0; + tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; + dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + d4TempRunningSumC = 0.0F; + d4TempAvgC = 0.0F; + d4TempSamplesNextIndex = 0; + d4TempCount = 0; + d50TempRunningSumC = 0.0F; + d50TempAvgC = 0.0F; + d50TempSamplesNextIndex = 0; + d50TempCount = 0; // Initialize the temperature sensors initTemperatureSensors(); @@ -144,6 +166,9 @@ // Monitor the temperature values monitorTemperatureSenors(); + // Filter D4/D50 temperature readings + filterTemperatureReadings(); + // Publish the data publishTemperatureSensorsData(); } @@ -194,6 +219,69 @@ /*********************************************************************//** * @brief + * The filterTemperatureReadings function adds a new temperature sensor + * sample to the filters. + * @details \b Inputs: D4 and D50 Temperature + * @details \b Outputs: d4TempSamplesC[], d4TempSamplesNextIndex, d4TempRunningSumC, + * d4TempCount, d4TempAvgC, d50TempSamplesC, d50TempRunningSumC, d50TempSamplesNextIndex, + * d50TempCount, d50TempAvgC + * @return none + *************************************************************************/ +static void filterTemperatureReadings( void ) +{ + // Filter D4 Temperature ( 1sec filter) + if ( d4TempCount >= D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) + { + d4TempRunningSumC -= d4TempSamplesC[ d4TempSamplesNextIndex ]; + } + F32 d4Temp = getTemperatureValue( D4_TEMP ); + d4TempSamplesC[ d4TempSamplesNextIndex ] = d4Temp; + d4TempRunningSumC += d4Temp; + d4TempSamplesNextIndex = INC_WRAP( d4TempSamplesNextIndex, 0, D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); + d4TempCount = INC_CAP( d4TempCount, D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); + d4TempAvgC = d4TempRunningSumC / (F32)d4TempCount; + + // Filter D50 Temperature ( 250 ms filter ) + if ( d50TempCount >= D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) + { + d50TempRunningSumC -= d50TempSamplesC[ d50TempSamplesNextIndex ]; + } + F32 d50Temp = getTemperatureValue( D50_TEMP ); + d50TempSamplesC[ d50TempSamplesNextIndex ] = d50Temp; + d50TempRunningSumC += d50Temp; + d50TempSamplesNextIndex = INC_WRAP( d50TempSamplesNextIndex, 0, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); + d50TempCount = INC_CAP( d50TempCount, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); + d50TempAvgC = d50TempRunningSumC / (F32)d50TempCount; +} + +/*********************************************************************//** + * @brief + * The getD4AverageTemperature function returns the average temperature + * for D4 temp sensor. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the D4 average temperature + *************************************************************************/ +F32 getD4AverageTemperature( void ) +{ + return d4TempAvgC; +} + +/*********************************************************************//** + * @brief + * The getD50AverageTemperature function returns the average temperature + * for D50 temp sensor. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the D50 average temperature + *************************************************************************/ +F32 getD50AverageTemperature( void ) +{ + return d50TempAvgC; +} + +/*********************************************************************//** + * @brief * The publishTemperatureSensorsData function broadcasts the temperature * sensors data at the publication interval. * @details \b Inputs: dataPublicationTimerCounter and publish interval time. @@ -219,6 +307,8 @@ data.d30CondTemp = getConductivityTemperatureValue( D29_COND ); data.d44CondTemp = getConductivityTemperatureValue( D43_COND ); data.d75CondTemp = getConductivityTemperatureValue( D74_COND ); + data.d4AvgTemp = getD4AverageTemperature(); + data.d50AvgTemp = getD50AverageTemperature(); broadcastData( MSG_ID_DD_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); dataPublicationTimerCounter = 0; Index: firmware/App/Monitors/Temperature.h =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -45,6 +45,8 @@ F32 d30CondTemp; ///< D30 temperature value F32 d44CondTemp; ///< D44 temperature value F32 d75CondTemp; ///< D75 temperature value + F32 d4AvgTemp; ///< D4 moving average temperature value + F32 d50AvgTemp; ///< D50 moving average temperature value } TEMPERATURE_SENSORS_DATA_T; @@ -53,6 +55,8 @@ void initTemperature( void ); SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ); void execTemperatureSensors( void ); +F32 getD4AverageTemperature( void ); +F32 getD50AverageTemperature( void ); BOOL testTemperatureSensorsDataPublishIntervalOverride( MESSAGE_T *message ); Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r3cc784af591b14e5d292f92c796db70bcbd5a40b -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 3cc784af591b14e5d292f92c796db70bcbd5a40b) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -239,13 +239,20 @@ U16 fpgaD11PumpStepCountStatus; ///< Reg 428. Acid concentrate pump revolution down count status U16 fpgaD10PumpStepCountStatus; ///< Reg 430. Bicarb concentrate pump revolution down count status - U32 fpgaD74CondDataOut; ///< Reg 432. Data read from Conductivity Sensor D74 register - U16 fpgaD74CondCond; ///< Reg 436. D74 conductivity - U16 fpgaD74CondTemp; ///< Reg 438. D74 Temperature - U08 fpgaD74CondReadCnt; ///< Reg 440. D74 successful read count - U08 fpgaD74CondErrorCnt; ///< Reg 441. D74 error read count - U16 fpgaD76PumpHallSense; ///< Reg 442. UF D76_Pump hall sensor pulse width - U16 fpgaD76PumpStepCountStatus; ///< Reg 444. UF pump revolution down count status + U16 fpgaAdcTemp; ///< Reg 432. TBD + U16 fpgaAdcVccInt; ///< Reg 434. TBD + U16 fpgaAdcVccAux; ///< Reg 436. TBD + U16 fpgaAdcVpVn; ///< Reg 438. TBD + U16 fpgaD12PumpSpeedFeedback; ///< Reg 440. D12 Pump speed feedback + U16 fpgaD48PumpSpeedFeedback; ///< Reg 442. D48 Pump Speed feedback + U16 fpgaD76PumpHallSense; ///< Reg 444. UF D76_Pump hall sensor pulse width + U16 fpgaD76PumpStepCountStatus; ///< Reg 446. UF pump revolution down count status + + U32 fpgaD74CondDataOut; ///< Reg 448. Data read from Conductivity Sensor D74 register + U16 fpgaD74CondCond; ///< Reg 452. D74 conductivity + U16 fpgaD74CondTemp; ///< Reg 454. D74 Temperature + U08 fpgaD74CondReadCnt; ///< Reg 456. D74 successful read count + U08 fpgaD74CondErrorCnt; ///< Reg 457. D74 error read count } DD_FPGA_SENSORS_T; typedef struct @@ -341,12 +348,12 @@ U16 fpgaACRelayPWMLow; ///< Reg 148. Length of time in 10us resoultion that PWM output stays low. U16 fpgaACRelayPWMPeriod; ///< Reg 150. PWM period for AC relay/heater. - U08 fpgaConSensD74Control; ///< Reg 152. Conductivity/Temperature Sensors D74 Control registers - U16 fpgaConSensD74_Addrs; ///< Reg 153. D74 Initialization Address register - U32 fpgaConSensD74_Data_In; ///< Reg 155. D74 Initialization data register - U16 fpgaD76PumpSpeed; ///< Reg 159. UF Pump Speed/RPM Control - U08 fpgaD76PumpControl; ///< Reg 161. UF Pump Control - U16 fpgaD76PumpRevCount; ///< Reg 162. UF pump revolution count + U16 fpgaD76PumpSpeed; ///< Reg 152. UF Pump Speed/RPM Control + U16 fpgaD76PumpRevCount; ///< Reg 154. UF pump revolution count + U08 fpgaD76PumpControl; ///< Reg 156. UF Pump Control + U08 fpgaConSensD74Control; ///< Reg 157. Conductivity/Temperature Sensors D74 Control registers + U16 fpgaConSensD74_Addrs; ///< Reg 158. D74 Initialization Address register + U32 fpgaConSensD74_Data_In; ///< Reg 160. D74 Initialization data register } FPGA_ACTUATORS_T; #pragma pack(pop) Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r0687e1ce03e73a64c51cde7a6c8216bec7187fc7 -rf6fb03f1e20395a61a5d5996f11f802ab8eacb2f --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 0687e1ce03e73a64c51cde7a6c8216bec7187fc7) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision f6fb03f1e20395a61a5d5996f11f802ab8eacb2f) @@ -136,7 +136,6 @@ { MSD_ID_DD_TD_COMMUNICATION_STATUS_OVERRIDE_REQUEST, &testTDCommunicationStatusOverride }, { MSG_ID_DD_OP_MODE_STATUS_OVERRIDE_REQUEST, &testDDOpModePublishIntervalOverride }, { MSG_ID_DD_SET_OPERATION_MODE_OVERRIDE_REQUEST, &testSetOperationMode }, - { MSG_ID_DD_START_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST, &testDDStartGenDialysateOverride }, { MSG_ID_DD_DIALYSATE_PUMPS_START_STOP_OVERRIDE_REQUEST, &testDialysatePumpStartStopOverride }, { MSG_ID_DD_GEND_MODE_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDGenDialysateDataPublishIntervalOverride }, { MSG_ID_DD_CONCENTRATE_PUMPS_START_STOP_OVERRIDE_REQUEST, &testConcentratePumpStartStopOverride }, @@ -158,10 +157,7 @@ { MSG_ID_DD_HEATERS_PWM_PERIOD_OVERIDE_REQUEST, &testHeaterPWMPeriodOverride }, { MSG_ID_DD_PRE_GEND_MODE_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDPreGenDialysateDataPublishIntervalOverride }, { MSG_ID_DD_POST_GEND_MODE_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDPostGenDialysateDataPublishIntervalOverride }, - { MSG_ID_DD_START_PRE_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST, &testDDStartPreGenDialysateOverride }, { MSG_ID_DD_PRE_GEN_DIALYSATE_REQUEST_DATA, &handlePreGenDialysateRequestMsg }, - { MSG_ID_DD_STOP_PRE_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST, &testDDStopPreGenDialysateOverride }, - { MSG_ID_DD_STOP_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST, &testDDStopGenDialysateOverride }, { MSG_ID_FW_VERSIONS_REQUEST, &handleVersionRequestMessage }, #ifdef __PUMPTEST__ { MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDPistonPumpControlDataPublishIntervalOverride },