Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r6e57ef369518a71692b8631dda5204efce51676c -r4cd896f8bdce0ca7cea88e99ed344ca7ec5a6abe --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 6e57ef369518a71692b8631dda5204efce51676c) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 4cd896f8bdce0ca7cea88e99ed344ca7ec5a6abe) @@ -8,7 +8,7 @@ * @file ConcentratePumps.c * * @author (last) Dara Navaei -* @date (last) 12-Jul-2023 +* @date (last) 20-Jul-2023 * * @author (original) Quang Nguyen * @date (original) 22-Oct-2020 @@ -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,6 +818,8 @@ 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 ) { @@ -921,7 +925,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 *************************************************************************/