Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -ra8a6babaca9203b780b4b44f9c15f73e3c0bf2a3 -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision a8a6babaca9203b780b4b44f9c15f73e3c0bf2a3) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -15,7 +15,6 @@ * ***************************************************************************/ -//#include "AlarmMgmt.h" #include "Common.h" #include "DDDefs.h" #include "DryBiCart.h" @@ -56,12 +55,14 @@ // ********** private data ********** static DRY_BICART_FILL_EXEC_STATE_T dryBiCartFillExecState; ///< Current state of dry bicart fill executive state machine. +static BICARB_CHAMBER_FILL_EXEC_STATE_T bicarbChamberFillExecState; ///< Current state of bicarb chamber fill executive state machine. static U32 dryBiCartFillStartTime; ///< Dry bicart fill start time. static U32 biCartFillCycleCounter; ///< Number of drybicart fill cycle static OVERRIDE_U32_T biCartMaxFillCycleCount; ///< Maximum number of drybicart fill cycle ( overrideable) static U32 lastFillDurationInMS; ///< Previous time duration to fill the bicart fill. static U32 currentFillDurationInMS; ///< Current time duartion to fill the bicart fill. static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop Dry bicart fill. +static OVERRIDE_U32_T bicarbChamberFillRequested; ///< Start/stop Bicarb chamber fill. static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. @@ -74,6 +75,9 @@ static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillDurationCheckState(void); static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillCompleteState(void); +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberCheckLevelState( void ); +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberFillState( void ); +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberPressureCheckState( void ); static void publishDryBicartData( void ); static U32 getDryBicartFillDataPublishInterval( void ); @@ -87,6 +91,7 @@ void initDryBiCart( void ) { dryBiCartFillExecState = DRY_BICART_START_STATE; + bicarbChamberFillExecState = BICARB_CHAMBER_START_STATE; dryBiCartDataPublishInterval.data = DRY_BICART_DATA_PUBLISH_INTERVAL; dryBiCartDataPublishInterval.ovData = DRY_BICART_DATA_PUBLISH_INTERVAL; dryBiCartDataPublishInterval.ovInitData = 0; @@ -99,6 +104,10 @@ dryBiCartFillRequested.ovData = FALSE; dryBiCartFillRequested.ovInitData = FALSE; dryBiCartFillRequested.override = 0; + bicarbChamberFillRequested.data = FALSE; + bicarbChamberFillRequested.ovData = FALSE; + bicarbChamberFillRequested.ovInitData = FALSE; + bicarbChamberFillRequested.override = 0; dryBiCartFillStartTime = 0; lastFillDurationInMS = 0; currentFillDurationInMS = 0; @@ -122,6 +131,25 @@ /*********************************************************************//** * @brief + * The execDryBicart function executes the set of dry bicart related state machines. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none. + *************************************************************************/ +void execDryBicart( void ) +{ + // Dry bicart fill exec + execDryBicartFillMode(); + + //Fill Bicarb chamber F + execBicarbChamberFillMode(); + + //Publish dry bicart data + publishDryBicartData(); +} + +/*********************************************************************//** + * @brief * The execDryBicartFillMode function executes the dry bicart fill (mixing water * with dry sodium bicarbonate ) state machine. * @details \b Inputs: dryBiCartFillExecState @@ -171,9 +199,6 @@ break; } - //Publish dry bicart data - publishDryBicartData(); - return dryBiCartFillExecState; } @@ -375,6 +400,137 @@ /*********************************************************************//** * @brief + * The execBicarbChamberFillMode function executes the bicarb chamber fill + * (delivering bicarbonate from Bicart assembly to chamber F)state machine. + * @details \b Inputs: bicarbChamberFillExecState + * @details \b Outputs: bicarbChamberFillExecState + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong bicarb chamber + * fill state invoked. + * @return current state. + *************************************************************************/ +U32 execBicarbChamberFillMode( void ) +{ + // execute bicarb chamber fill state machine + switch ( bicarbChamberFillExecState ) + { + case BICARB_CHAMBER_START_STATE: + if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) + { + bicarbChamberFillExecState = BICARB_CHAMBER_CHECK_LEVEL_STATE; + } + break; + + case BICARB_CHAMBER_CHECK_LEVEL_STATE: + bicarbChamberFillExecState = handleBicarbChamberCheckLevelState(); + break; + + case BICARB_CHAMBER_FILL_STATE: + bicarbChamberFillExecState = handleBicarbChamberFillState(); + break; + + case BICARB_CHAMBER_PRESSURE_CHECK_STATE: + bicarbChamberFillExecState = handleBicarbChamberPressureCheckState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_BICARB_CHAMBER_FILL_INVALID_EXEC_STATE, bicarbChamberFillExecState ); + break; + } + + return bicarbChamberFillExecState; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberCheckLevelState function checks the bicarb level(D63) + * in the chamber F and decides to open the bicarb inlet valve (D80). + * @details \b Inputs: D63 level + * @details \b Outputs: valve states + * @return the next bicarb chamber fill state. + *************************************************************************/ +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberCheckLevelState( void ) +{ + BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_CHECK_LEVEL_STATE; + LEVEL_STATE_T bicarbChamberLevel = getLevelStatus( D63_LEVL ); + + // Close vent valves and descaling valve + setValveState( D81_VALV, VALVE_STATE_CLOSED ); + setValveState( D64_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + + // TODO : Confirm D80 open on chamber low or end of balancing chamber switching? + if ( LEVEL_STATE_LOW == bicarbChamberLevel ) + { + // Open the Bicarb chamber inlet valve + setValveState( D80_VALV, VALVE_STATE_OPEN ); + state = BICARB_CHAMBER_FILL_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberFillState function checks the D66 pressure & + * decides to open D65 and Close the inlet valve (D80) once level reached + * @details \b Inputs: D66 pressure sensor reading + * @details \b Outputs: valve states + * @return the next bicarb chamber fill state. + *************************************************************************/ +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberFillState( void ) +{ + BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_FILL_STATE; + F32 d66Pressure = getFilteredPressure( D66_PRES ); + LEVEL_STATE_T bicarbChamberLevel = getLevelStatus( D63_LEVL ); + + // Once level reached, close the valve + if ( LEVEL_STATE_HIGH == bicarbChamberLevel ) + { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + state = BICARB_CHAMBER_START_STATE; + } + // Open water inlet valve to fill the bicart + else if ( d66Pressure <= DRY_BICART_FILL_INITIATE_PRESSURE ) + { + setValveState( D65_VALV, VALVE_STATE_OPEN ); + state = BICARB_CHAMBER_PRESSURE_CHECK_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBicarbChamberPressureCheckStartState function actuates the vent valve + * present in the Bicart assembly. + * @details \b Inputs: none + * @details \b Outputs: valve states + * @return the next bicarb chamber fill state. + *************************************************************************/ +static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberPressureCheckState( void ) +{ + BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_PRESSURE_CHECK_STATE; + F32 d66Pressure = getFilteredPressure( D66_PRES ); + LEVEL_STATE_T bicarbChamberLevel = getLevelStatus( D63_LEVL ); + + // Once level reached, close the valve + if ( LEVEL_STATE_HIGH == bicarbChamberLevel ) + { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + } + + // Close water inlet valve as fill is complete. + if ( d66Pressure >= DRY_BICART_FILL_COMPLETE_PRESSURE ) + { + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + state = BICARB_CHAMBER_START_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter @@ -390,6 +546,7 @@ DRY_BICART_DATA_T data; data.dryBiCartFillExecState = (U32)dryBiCartFillExecState; + data.bicarbChamberFillExecState = (U32)bicarbChamberFillExecState; data.dryBiCartFillCycleCounter = biCartFillCycleCounter; data.dryBiCartMaxFillCycleCount = getU32OverrideValue( &biCartMaxFillCycleCount ); data.dryBiCartFillRequest = getU32OverrideValue( &dryBiCartFillRequested ); @@ -459,4 +616,21 @@ return result; } +/*********************************************************************//** + * @brief + * The testDryBiCartFillRequestOverride function starts/stops the bicarb + * chamber F fill. + * @details \b Inputs: tester logged in + * @details \b Outputs: bicarbChamberFillRequested + * @param message set message from Dialin which includes the bicarb chamber + * fill start/stop. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testBiCarbChamberFillRequestOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &bicarbChamberFillRequested, FALSE, TRUE ); + + return result; +} + /**@}*/ Index: firmware/App/Controllers/DryBiCart.h =================================================================== diff -u -ra8a6babaca9203b780b4b44f9c15f73e3c0bf2a3 -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision a8a6babaca9203b780b4b44f9c15f73e3c0bf2a3) +++ firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -36,6 +36,7 @@ typedef struct { U32 dryBiCartFillExecState; ///< Dry bicart execution state + U32 bicarbChamberFillExecState; ///< Bicarb chamber Fill execution state U32 dryBiCartFillCycleCounter; ///< Dry bicart fill cycle counter U32 dryBiCartMaxFillCycleCount; ///< Dry bicart fill cycle max count U32 dryBiCartFillRequest; ///< Dry bicart fill request @@ -47,13 +48,16 @@ void initDryBiCart( void ); // Initialize dry bicart unit void transitionToDryBicart( void ); // Prepares for transition to dry bicart execution -U32 execDryBicartFillMode( void ); // Execute the dry bicart state machine +U32 execDryBicartFillMode( void ); // Execute the dry bicart state machine +U32 execBicarbChamberFillMode( void ); // Execute the bicarb chamber fill state machine +void execDryBicart( void ); // Execute the list of drybicart state machines DRY_BICART_FILL_EXEC_STATE_T getCurrentDryBiCartFillExecState( void ); // Get the current state of the dry bicart fill execution BOOL testDryBiCartDataPublishIntervalOverride( MESSAGE_T *message ); // To override the dry bicart data publish interval BOOL testDryBiCartFillCycleMaxCountOverride( MESSAGE_T *message ); // To override the dry bicart max fill cycle BOOL testDryBiCartFillRequestOverride( MESSAGE_T *message ); // To override the dry bicart fill start/stop request +BOOL testBiCarbChamberFillRequestOverride( MESSAGE_T *message ); // To override the bicarb chamber fill start/stop request /**@}*/ Index: firmware/App/DDCommon.h =================================================================== diff -u -r58ab39a642ac876eb735c98db5186bf0de0e9066 -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 58ab39a642ac876eb735c98db5186bf0de0e9066) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -54,6 +54,9 @@ //Uncomment below for Maxon controller speed change //#define __MAXON_SPEED_UPDATE__ 1 +//UnComment below for DryBicarb testing +//#define __DRY_BICARB__ 1 + //Uncomment below to disable heaters debug message #define __HEATERS_DEBUG__ 1 Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r1cd9bf024ebcb865fbab3eeb8dc987b8a3c89f6a -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 1cd9bf024ebcb865fbab3eeb8dc987b8a3c89f6a) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -218,7 +218,9 @@ setValveState( D47_VALV, VALVE_STATE_CLOSED ); // spent chamber purge valve setValveState( D64_VALV, VALVE_STATE_CLOSED ); setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve +#ifndef __DRY_BICARB__ setValveState( D80_VALV, VALVE_STATE_OPEN ); // Bicarb valve +#endif // Turn on the primary heater calculateTargetDialysateTemp(); @@ -267,7 +269,9 @@ setValveState( D34_VALV, VALVE_STATE_CLOSED ); // Bypass valve setValveState( D35_VALV, VALVE_STATE_OPEN ); // VDI setValveState( D40_VALV, VALVE_STATE_OPEN ); // VDO +#ifndef __DRY_BICARB__ setValveState( D80_VALV, VALVE_STATE_OPEN ); // Bicarb valve +#endif break; case DD_GEND_SPENT_CHAMBER_FILL_STATE: @@ -277,7 +281,9 @@ setValveState( D14_VALV, VALVE_STATE_OPEN ); setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve +#ifndef __DRY_BICARB__ setValveState( D80_VALV, VALVE_STATE_OPEN ); // Bicarb valve +#endif setValveState( D47_VALV, VALVE_STATE_OPEN ); // Spent chamber purge valve requestConcentratePumpOff( D76_PUMP, FALSE ); @@ -314,7 +320,9 @@ setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve setValveState( D64_VALV, VALVE_STATE_OPEN ); // Bicarb chamber purge valve +#ifndef __DRY_BICARB__ setValveState( D80_VALV, VALVE_STATE_OPEN ); // Bicarb valve +#endif bicarbFillStartTimeMS = getMSTimerCount(); // Turn on the primary heater @@ -365,7 +373,9 @@ setValveState( D34_VALV, VALVE_STATE_OPEN ); setValveState( D53_VALV, VALVE_STATE_OPEN ); +#ifndef __DRY_BICARB__ setValveState( D80_VALV, VALVE_STATE_OPEN ); +#endif break; case DD_GEND_ISOLATED_UF_STATE: Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -ra521fb80a785babd99f0413dc6223d47375a43bc -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision a521fb80a785babd99f0413dc6223d47375a43bc) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -149,6 +149,7 @@ SW_FAULT_ID_RINSE_PUMP_INVALID_EXEC_STATE = 118, SW_FAULT_ID_RINSE_PUMP_INVALID_STATE1 = 119, SW_FAULT_ID_DRY_BICART_FILL_INVALID_EXEC_STATE = 120, + SW_FAULT_ID_BICARB_CHAMBER_FILL_INVALID_EXEC_STATE = 121, NUM_OF_SW_FAULT_IDS } DD_SW_FAULT_ID_T; Index: firmware/App/Services/Messaging.c =================================================================== diff -u -ra521fb80a785babd99f0413dc6223d47375a43bc -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision a521fb80a785babd99f0413dc6223d47375a43bc) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -243,6 +243,7 @@ { MSG_ID_DD_DRY_BICART_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testDryBiCartDataPublishIntervalOverride }, { MSG_ID_DD_DRY_BICART_FILL_CYCLE_MAX_OVERRIDE_REQUEST, &testDryBiCartFillCycleMaxCountOverride }, { MSG_ID_DD_DRY_BICART_FILL_REQUEST_OVERRIDE_REQUEST, &testDryBiCartFillRequestOverride }, + { MSG_ID_DD_BICARB_CHAMBER_FILL_REQUEST_OVERRIDE_REQUEST, &testBiCarbChamberFillRequestOverride }, }; /// Calculation for number of entries in the incoming message function handler look-up table. Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -ra521fb80a785babd99f0413dc6223d47375a43bc -r65292e443646d135d8fcad0a2eda19d844b06dff --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision a521fb80a785babd99f0413dc6223d47375a43bc) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 65292e443646d135d8fcad0a2eda19d844b06dff) @@ -94,8 +94,8 @@ // manage concentrate pumps execConcentratePumpController(); - // manage drybicart fill - execDryBicartFillMode(); + // manage drybicart state machines + execDryBicart(); // Control RO pump execROPumpController();