Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r5531ef9081711c5d57cceba2d51ff9bb24b7c254 -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 5531ef9081711c5d57cceba2d51ff9bb24b7c254) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -764,7 +764,7 @@ } // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( FALSE == getBicarbChamberFillRequested() ) ) + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) { isPressureStabilizedDuringFill = TRUE; } @@ -1016,7 +1016,7 @@ spentDialPressure = getFilteredPressure( D51_PRES ); // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( FALSE == getBicarbChamberFillRequested() ) ) + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) { isPressureStabilizedDuringFill = TRUE; } Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -ra6737c3bcc8286c153b778c2c395f465e76aaafb -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision a6737c3bcc8286c153b778c2c395f465e76aaafb) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -870,7 +870,7 @@ { setFPGAD76PumpSetStepSpeed( CONCENTRATE_PUMP_ZERO_FLOW_RATE ); } - +#if 0 // Park concentrate pump too if requested if ( TRUE == parkPump ) { @@ -891,6 +891,7 @@ } concentratePumps[ pumpId ].isConcPumpParkInProgress = TRUE; } +#endif } /*********************************************************************//** Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -rcd1161514dbaff9e5b222931fff99618e39fd7ec -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision cd1161514dbaff9e5b222931fff99618e39fd7ec) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -44,13 +44,17 @@ // ********** private definitions ********** #define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the drybicart data published. -#define PRESSURE_OFFSET_PSI 7.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor +#define WCDI2_PRESSURE_OFFSET_PSI 7.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID1 +#define WCID1_PRESSURE_OFFSET_PSI 1.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID2 #define DRY_BICART_PERSISTENCE_DURATION_MS 200 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. // Dry Bicart Fill #define DRY_BICART_FILL_COMPLETE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to reset the request flag after fill complete -#define DRY_BICART_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed. +#define DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCDI2_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID2 +#define DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCID1_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID1 +#define GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) \ + != TRUE ? DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) #define DRY_BICART_FILL_INITIATE_PRESSURE_PSI 1.5F ///< Minimum pressure required to initiate the dry bicart fill process. #define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state #define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 3.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state @@ -267,19 +271,8 @@ void execDryBicart( void ) { - //DRY_BICART_SUPPLY ; - //DRY_BICART_INITIAL_FILL; - //DRY_BICART_DRAIN; - //default DRY_BICART_IDLE; - // the below function select any one of the above request - //updateDrybicartOperation(); + execMixingControl(); - if( getCurrentBalancingChamberExecState() > BAL_CHAMBER_STATE_IDLE ) - { - // closed loop bicarb and acid mixing controller - execDialysateCompositionMixingController(); - } - // top level state machine selection DRY_BICART_OPERATION_T dryBicartState = dryBicartStartRequest; @@ -738,9 +731,10 @@ { DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); + F32 fillCompletePressure = GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI; // Close dry bicart inlet water if D66 pressure is 17 PSI - if ( d66Pressure >= DRY_BICART_FILL_COMPLETE_PRESSURE_PSI ) + if ( d66Pressure >= fillCompletePressure ) { // start the persistence timer once d66 reaches 17 PSI if ( 0 == dryBiCartPersistenceStartTime ) @@ -1004,9 +998,10 @@ { BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); + F32 fillCompletePressure = GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI; // check D66 pressure greater than or equal to 17 PSI - if ( d66Pressure >= DRY_BICART_FILL_COMPLETE_PRESSURE_PSI ) + if ( d66Pressure >= fillCompletePressure ) { // start the persistence timer once d66 reaches 17 PSI if ( 0 == dryBiCartPersistenceStartTime ) Index: firmware/App/Controllers/MixingControl.c =================================================================== diff -u -rcd1161514dbaff9e5b222931fff99618e39fd7ec -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision cd1161514dbaff9e5b222931fff99618e39fd7ec) +++ firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -19,7 +19,6 @@ #include "Common.h" #include "ConcentratePumps.h" #include "Conductivity.h" -#include "DialysatePumps.h" #include "DDDefs.h" #include "DryBiCart.h" #include "Level.h" @@ -55,7 +54,7 @@ #define ACID_VOL_CONTROL_P_COEFFICIENT ( 0.00000997F / 2 ) ///< Acid proportional gain (kp) #define ACID_VOL_CONTROL_I_COEFFICIENT ( 0.00003988F / 5 ) ///< Acid integral gain. (ki) #define MIN_ACID_VOLUME_ML 0.3F ///< Minimum acid volume in mL -#define MAX_ACID_VOLUME_ML 1.0F ///< Maximum acid volume in mL/min. +#define MAX_ACID_VOLUME_ML 1.0F ///< Maximum acid volume in mL. #define BICARB_TARGET_CONDUCTIVITY 2714.0F ///< Target bicarb conductivity #define BICARB_DELTA_CONDUCTIVITY 500.0F ///< Delta bicarb conductivity @@ -195,6 +194,7 @@ static DIALYSATE_MIXING_STATE_T handleDialysateMixOpenLoopState( DIALYSATE_MIXING_ID_T mixId ); static DIALYSATE_MIXING_STATE_T handleDialysateMixRampToTargetState( DIALYSATE_MIXING_ID_T mixId ); static DIALYSATE_MIXING_STATE_T handleDialysateMixControlToTargetState( DIALYSATE_MIXING_ID_T mixId ); +static void handleDialysateCompositionMixing( void ); static void setBicarbMixVol( F32 targetValue ); static void setAcidMixVol( F32 targetValue ); @@ -215,8 +215,8 @@ static F32 getAcidKpGainCoefficient( void ); static F32 getAcidKiGainCoefficient( void ); -static U32 getMixingControlBicarbControlInterval( void ); -static U32 getMixingControlAcidControlInterval( void ); +static U32 getBicarbMixControlInterval( void ); +static U32 getAcidMixControlInterval( void ); // publish the status static void publishMixingControlData( void ); static U32 getMixingControlDataPublishInterval( void ); @@ -346,7 +346,7 @@ * state machine found. * @return none *************************************************************************/ -void execDialysateCompositionMixingController( void ) +static void handleDialysateCompositionMixing( void ) { DIALYSATE_MIXING_ID_T mixId; @@ -378,7 +378,7 @@ * @brief * The execMixingControl function executes the dialysate and bicarb open loop /closed loop * related state machines - * @details \b Inputs: none + * @details \b Inputs: Balancing chamber state * @details \b Outputs: none * @return none. *************************************************************************/ @@ -387,7 +387,7 @@ if( getCurrentBalancingChamberExecState() > BAL_CHAMBER_STATE_IDLE ) { // closed loop bicarb and acid mixing controller - execDialysateCompositionMixingController(); + handleDialysateCompositionMixing(); } // Publish mixing control data @@ -551,7 +551,6 @@ return result; } - /*********************************************************************//** * @brief * The getAcidKiGainCoefficient function gets the Ki Gain for closed loop @@ -569,12 +568,12 @@ /*********************************************************************//** * @brief - * The getmixingControlBicarbMixControlInterval function gets the bicart mix control interval + * The getBicarbMixControlInterval function gets the bicart mix control interval * @details \b Inputs: mixingControlBicarbMixControlInterval * @details \b Outputs: none * @return TRUE if successful, FALSE if not. *************************************************************************/ -static U32 getMixingControlBicarbControlInterval( void ) +static U32 getBicarbMixControlInterval( void ) { U32 result = getU32OverrideValue( &mixingControlBicarbControlInterval ); @@ -583,40 +582,66 @@ /*********************************************************************//** * @brief - * The getMixingControlAcidControlInterval function gets the acid mix control interval + * The getAcidMixControlInterval function gets the acid mix control interval * @details \b Inputs: mixingControlAcidControlInterval * @details \b Outputs: none * @return TRUE if successful, FALSE if not. *************************************************************************/ -static U32 getMixingControlAcidControlInterval( void ) +static U32 getAcidMixControlInterval( void ) { U32 result = getU32OverrideValue( &mixingControlAcidControlInterval ); return result; } +/*********************************************************************//** + * @brief + * The getTotalConductivity function gets the total conductivity of bicarb and acid + * @details \b Inputs: none + * @details \b Outputs: none + * @return conductivity + *************************************************************************/ static F32 getTotalConductivity( void ) { return TOTAL_CONDUCTIVITY; } +/*********************************************************************//** + * @brief + * The getAcidConducivityPost function gets the acid conductivity post + * @details \b Inputs: none + * @details \b Outputs: none + * @return conductivity + *************************************************************************/ static F32 getAcidConducivityPost( void ) { return ACID_CONDUCTIVITY_POST; } +/*********************************************************************//** + * @brief + * The getBicarbConductivityPost function gets the bicarb conductivity post + * @details \b Inputs: none + * @details \b Outputs: none + * @return conductivity + *************************************************************************/ static F32 getBicarbConductivityPost( void ) { return BICARB_CONDUCTIVITY_PRE; } +/*********************************************************************//** + * @brief + * The getBicarbConductivityPre function gets the bicarb conductivity pre + * @details \b Inputs: none + * @details \b Outputs: none + * @return conductivity + *************************************************************************/ static F32 getBicarbConductivityPre( void ) { return BICARB_CONDUCTIVITY_PRE; } - - /*********************************************************************//** * @brief * The getmixingControlFillDataPublishInterval function gets the mix controller @@ -643,16 +668,15 @@ *************************************************************************/ static DIALYSATE_MIXING_STATE_T handleDialysateMixOpenLoopState( DIALYSATE_MIXING_ID_T mixId ) { - DIALYSATE_MIXING_STATE_T result; + DIALYSATE_MIXING_STATE_T result = DIALYSATE_MIXING_OPEN_LOOP_STATE; if ( BICARB_MIX_ID == mixId ) { + //TODO: right now using the fixed conductivity , later use the calculated version API F32 measuredBicarbConductivity = getFilteredConductivity( D17_COND ); F32 bicarbConductivity = getBicarbTargetConductivity(); F32 bicarbDeltaConductivity = getBicarbDeltaConductivity(); - result = DIALYSATE_MIXING_OPEN_LOOP_STATE; - if ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DOSING_OPEN_LOOP_CONTROL ) ) { // if measured conductivity crossed (targetConductivity- deltaConuctivity) , switch to closed loop @@ -664,12 +688,11 @@ } else if ( ACID_MIX_ID == mixId ) { + //TODO: right now using the fixed conductivity , later use the calculated version API F32 measuredAcidBicarbMixConductivity = getFilteredConductivity( D27_COND ); F32 DialysateConductivity = getDialysateTargetConductivity(); F32 DialysateDeltaConductivity = getDialysateTargetConductivity(); - result = DIALYSATE_MIXING_OPEN_LOOP_STATE; - if ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DOSING_OPEN_LOOP_CONTROL ) ) { // if measured conductivity crossed (targetConductivity- deltaConuctivity) , switch to closed loop @@ -727,7 +750,7 @@ if ( BICARB_MIX_ID == mixId ) { // control interval for bicarb - if ( ( ++dialysateMix[ mixId ].controlTimerCounter >= getMixingControlBicarbControlInterval() ) ) + if ( ( ++dialysateMix[ mixId ].controlTimerCounter >= getBicarbMixControlInterval() ) ) { F32 bicarbMixVol; @@ -758,19 +781,20 @@ if ( ACID_MIX_ID == mixId ) { // control interval for acid - if ( ( ++dialysateMix[ mixId ].controlTimerCounter >= getMixingControlAcidControlInterval( ) ) ) + if ( ( ++dialysateMix[ mixId ].controlTimerCounter >= getAcidMixControlInterval( ) ) ) { F32 acidMixVol; dialysateMix[ mixId ].controlTimerCounter = 0; + // TODO: use the calculated API F32 measuredDialysateConductivity = getFilteredConductivity( D27_COND ); F32 DialysateConductivity = getTotalConductivity();//getDialysateTargetConductivity(); PI_CONTROLLER_SIGNALS_DATA debugAcidControl; if ( fabs ( DialysateConductivity - measuredDialysateConductivity ) > ACID_DEADBAND_CONTROL ) { - acidMixVol = runPIController( PI_CONTROLLER_ID_ACID_VOL, getTotalConductivity() /*DialysateConductivity*/, measuredDialysateConductivity ); + acidMixVol = runPIController( PI_CONTROLLER_ID_ACID_VOL, DialysateConductivity, measuredDialysateConductivity ); // set acid mix volume if its above dead band threshold , else use previous set value setAcidMixVol( acidMixVol ); } @@ -861,7 +885,6 @@ return result; } - /*********************************************************************//** * @brief * The testmixingControlAcidMixVolumeOverride function sets the override value Index: firmware/App/Controllers/MixingControl.h =================================================================== diff -u -r5531ef9081711c5d57cceba2d51ff9bb24b7c254 -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Controllers/MixingControl.h (.../MixingControl.h) (revision 5531ef9081711c5d57cceba2d51ff9bb24b7c254) +++ firmware/App/Controllers/MixingControl.h (.../MixingControl.h) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -56,7 +56,7 @@ // ********** public function prototypes ********** -void execDialysateCompositionMixingController( void ); + void execMixingControl( void ); F32 getBicarbMixVol( void ); F32 getAcidMixVol( void ); @@ -69,7 +69,6 @@ BOOL testMixingControlBicarbVolControlKpGainOverride( MESSAGE_T *message ); BOOL testMixingControlBicarbVolControlKiGainOverride( MESSAGE_T *message ); - BOOL testMixingControlAcidVolControlKpGainOverride( MESSAGE_T *message ); BOOL testMixingControlAcidVolControlKiGainOverride( MESSAGE_T *message ); Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -r0bcac6885c8461b05da276fd245b580b7339ddfd -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 0bcac6885c8461b05da276fd245b580b7339ddfd) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -378,7 +378,7 @@ } } - checkPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, sensorInAlarm, alarmTemperature ); + //checkPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, sensorInAlarm, alarmTemperature ); //check freshness of temperature read checkTemperatureSensors(); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r9eae2f683887bededd2240f51ddfc667d8c1d566 -rf364406cd1f672078ca38ae8aad5bc508e9b64dd --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 9eae2f683887bededd2240f51ddfc667d8c1d566) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision f364406cd1f672078ca38ae8aad5bc508e9b64dd) @@ -108,7 +108,7 @@ execRinsePumpMonitor(); // Monitor Substituion pump - execSubstitutionPumpMonitor(); + //execSubstitutionPumpMonitor(); // Second pass for FPGA execFPGA( FALSE );