Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r39c83612c7d83075cded8b7e1c8030898cdb5ad9 -r62e9a14081b3c97ea244c3c167098eba8cd409d1 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 39c83612c7d83075cded8b7e1c8030898cdb5ad9) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 62e9a14081b3c97ea244c3c167098eba8cd409d1) @@ -143,6 +143,7 @@ static BOOL stepConcentratePumpToTargetSpeed( CONCENTRATE_PUMPS_T pumpId ); static void calcMeasuredPumpsSpeed( void ); static void monitorPumpSpeed( CONCENTRATE_PUMPS_T pumpId, ALARM_ID_T alarm ); +static void checkConcentratePumpControlSet( CONCENTRATE_PUMPS_T pumpId ); /*********************************************************************//** * @brief @@ -159,7 +160,7 @@ acidConcentratePumpParkPersistenceClear = FALSE; ///< Boolean acid park persistence clearing. bicarbConcentratePumpParkPersistenceClear = FALSE; - for ( pumpId = CONCENTRATEPUMPS_CP1_ACID; pumpId < NUM_OF_CONCENTRATE_PUMPS; ++pumpId ) + for ( pumpId = CONCENTRATEPUMPS_CP1_ACID; pumpId < NUM_OF_CONCENTRATE_PUMPS; pumpId++ ) { concentratePumps[ pumpId ].controlTimerCounter = 0; concentratePumps[ pumpId ].execState = CONCENTRATE_PUMP_OFF_STATE; @@ -308,7 +309,7 @@ { CONCENTRATE_PUMPS_T pumpId; - for ( pumpId = CONCENTRATEPUMPS_CP1_ACID; pumpId < NUM_OF_CONCENTRATE_PUMPS; ++pumpId ) + for ( pumpId = CONCENTRATEPUMPS_CP1_ACID; pumpId < NUM_OF_CONCENTRATE_PUMPS; pumpId++ ) { switch ( concentratePumps[ pumpId ].execState ) { @@ -738,14 +739,15 @@ static CONCENTRATE_PUMP_STATE_T handleConcentratePumpControlTargetSpeedState( CONCENTRATE_PUMPS_T pumpId ) { CONCENTRATE_PUMP_STATE_T state = CONCENTRATE_PUMP_CONTROL_TARGET_SPEED_STATE; + F32 targetToCurreSpeedDiffMLPM = fabs( concentratePumps[ pumpId ].pumpTargetSpeed - concentratePumps[ pumpId ].currentPumpSpeed ); if ( ++concentratePumps[ pumpId ].controlTimerCounter >= CONCENTRATE_PUMP_CONTROL_INTERVAL ) { concentratePumps[ pumpId ].controlTimerCounter = 0; stepConcentratePumpToTargetSpeed( pumpId ); } - if ( concentratePumps[ pumpId ].pumpTargetSpeed >= CONCENTRATE_PUMP_TRANS_TO_RAMP_SPEED_THRESHOLD_MLPM ) + if ( targetToCurreSpeedDiffMLPM >= CONCENTRATE_PUMP_TRANS_TO_RAMP_SPEED_THRESHOLD_MLPM ) { // If the requested target speed is greater than the threshold, transition back to ramp state regardless of the status of the // control interval @@ -816,7 +818,10 @@ concentratePumps[ pumpId ].togglePeriodCount = CONCENTRATE_PUMP_ZERO_FLOW_RATE; } + // Check if the control set bit is set as desired and if not, correct it + checkConcentratePumpControlSet( pumpId ); + if ( CONCENTRATEPUMPS_CP1_ACID == pumpId ) { setFPGAAcidPumpSetStepSpeed( concentratePumps[ pumpId ].togglePeriodCount ); @@ -921,7 +926,47 @@ checkPersistentAlarm( alarm, isCpSpeedOut, cpError, tolerance ); } +/*********************************************************************//** + * @brief + * The checkConcentratePumpControlSet function monitors the status of the + * concentrate pumps control set bit and if they are different from the + * required set bit, they are set again. + * @details Inputs: concentratePumps + * @details Outputs: none + * @param pumpId pump id to check its control set bit + * @return none + *************************************************************************/ +static void checkConcentratePumpControlSet( CONCENTRATE_PUMPS_T pumpId ) +{ + U08 controlSetBits; + switch ( pumpId ) + { + case CONCENTRATEPUMPS_CP1_ACID: + controlSetBits = getFPGAAcidPumpControlStatus(); + + if ( controlSetBits != concentratePumps[ pumpId ].controlSet ) + { + setFPGAAcidPumpControl( concentratePumps[ pumpId ].controlSet ); + } + break; + + case CONCENTRATEPUMPS_CP2_BICARB: + controlSetBits = getFPGABicarbPumpControlStatus(); + + if ( controlSetBits != concentratePumps[ pumpId ].controlSet ) + { + setFPGABicarbPumpControl( concentratePumps[ pumpId ].controlSet ); + } + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID, pumpId ); + break; + } +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/