Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r5aee05d242962c2f9294577c3ba5015f9342fb83 -r2ac3479b027dd1dab8673b9959ab13234a68d842 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 5aee05d242962c2f9294577c3ba5015f9342fb83) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 2ac3479b027dd1dab8673b9959ab13234a68d842) @@ -53,8 +53,8 @@ #define DRP_CONTROL_INTERVAL ( 200 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the Drain pump is controlled. #define DRP_CONTROL_MAX_ALLOWED_PPO_PSI 30.0F ///< Drain pump maximum allowed PPo pressure in psi. #define DRP_CONTROL_MAX_ALLOWED_PDR_PSI 40.0F ///< Drain pump maximum allowed PDr pressure in psi. -#define DRP_CONTROL_PSI_TO_DAC_P_TERM 0.2F ///< Drain pump psi to DAC conversion. -#define DRP_CONTROL_FLOW_TO_DAC_P_TERM 100.0F ///< Drain pump flow (L/min) to DAC conversion. +#define DRP_CONTROL_PSI_TO_DAC_P_ONLY_TERM 0.2F ///< Drain pump psi to DAC conversion. +#define DRP_CONTROL_FLOW_TO_DAC_P_ONLY_TERM 100.0F ///< Drain pump flow (L/min) to DAC conversion. #define DRP_CONTROL_PRES_TO_MAX_THRESHOLD_PSI 1.0F ///< Drain pump pressure to maximum pressure threshold in psi. #define DRP_CONTROL_MIN_DAC_CHANGE 1 ///< Drain pump minimum DAC change @@ -66,8 +66,8 @@ #define TOGGLE_PERIOD_RESOLUTION_SECONDS 0.000005F ///< Toggle period to resolution in seconds. #define ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION 4.0F ///< Rotational to toggle period conversion coefficient. -#define DRAIN_PUMP_P_COEFFICIENT 100.0F //0.5F ///< P term for drain pump delta pressure control. -#define DRAIN_PUMP_I_COEFFICIENT 1.0F ///< I term for drain pump delta pressure control. +#define DRAIN_PUMP_P_COEFFICIENT 20.0F ///< P term for drain pump delta pressure control. +#define DRAIN_PUMP_I_COEFFICIENT 80.0F ///< I term for drain pump delta pressure control. #define MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE 100 ///< Maximum allowed RPM out of range from target RPM in open loop. #define OPEN_LOOP_RPM_OUT_OF_RANGE_TIME_OUT ( 10 * MS_PER_SECOND ) ///< Open loop RPM out of range time out in ms. @@ -297,7 +297,9 @@ * The signalDrainPumpHardStop function stops the Drain pump immediately. * @details Inputs: none * @details Outputs: targetDrainPumpRPM, drainPumpState, drainPumpControlMode, - * hasClosedLoopBeenRequested, drainControlTimerCounter, drainPumpControlModeSet + * hasClosedLoopBeenRequested, drainControlTimerCounter, drainPumpControlModeSet, + * drainControlTimerCtr, pendingDrainPumpCmd, pendingDrainPumpCmdTarget, + * pendingDrainPumpCmdCountDown * @return none *************************************************************************/ void signalDrainPumpHardStop( void ) @@ -310,9 +312,9 @@ hasClosedLoopBeenRequested = FALSE; drainPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; drainPumpControlModeSet = drainPumpControlMode; - drainControlTimerCtr = 0; + drainControlTimerCtr = 0; pendingDrainPumpCmd = DRAIN_PUMP_OFF_STATE; - pendingDrainPumpCmdTarget = 0.0; + pendingDrainPumpCmdTarget = 0.0F; pendingDrainPumpCmdCountDown = 0; } @@ -434,8 +436,11 @@ /*********************************************************************//** * @brief * The execDrainPumpController function executes the drain pump controller. - * @details Inputs: drainPumpState - * @details Outputs: drainPumpState + * @details Inputs: drainPumpState, pendingDrainPumpCmdCountDown, + * pendingDrainPumpCmd + * @details Outputs: drainPumpState, pendingDrainPumpCmdCountDown, + * pendingDrainPumpCmd, targetDrainPumpOutletFlowLPM, drainPumpDAC, + * hasClosedLoopBeenRequested, drainPumpControlMode, drainPumpControlModeSet * @return none *************************************************************************/ void execDrainPumpController( void ) @@ -675,7 +680,7 @@ else if ( flowSubLPM > NEARLY_ZERO ) { // If measured flow if greater than the target flow, adjust the DAC to lower the flow rate - tempDACSet = (U32)( ( flowSubLPM * DRP_CONTROL_FLOW_TO_DAC_P_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); + tempDACSet = (U32)( ( flowSubLPM * DRP_CONTROL_FLOW_TO_DAC_P_ONLY_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); drainPumpDACSet -= ( tempDACSet > 0.0F ? tempDACSet : DRP_CONTROL_MIN_DAC_CHANGE ); } else @@ -690,15 +695,15 @@ { // If either of the pressure values are greater than the maximum pressure, recalculate the DAC by the maximum pressure difference // If the calculated DAC value turned out to be 0, set it to 1 so it changes at least by 1 DAC - tempDACSet = (U32)( ( maxPresPSI * DRP_CONTROL_PSI_TO_DAC_P_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); + tempDACSet = (U32)( ( maxPresPSI * DRP_CONTROL_PSI_TO_DAC_P_ONLY_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); drainPumpDACSet -= ( tempDACSet > 0.0F ? tempDACSet : DRP_CONTROL_MIN_DAC_CHANGE ); } else if ( ( fabs(pdrSubPSI) > DRP_CONTROL_PRES_TO_MAX_THRESHOLD_PSI ) && ( fabs(ppoSubPSI) > DRP_CONTROL_PRES_TO_MAX_THRESHOLD_PSI ) ) { // If both of the DACs turned out to be less than their maximum pressure limits by more than the specified value, recalculate the // DAC. Using fabs for the subtraction means both pressure subtractions are negative so they are below their limits. // In the calculations use fabs for max pressure because it is negative so it will end of subtracting DAC but it should be adding - tempDACSet = (U32)( ( fabs(maxPresPSI) * DRP_CONTROL_PSI_TO_DAC_P_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); + tempDACSet = (U32)( ( fabs(maxPresPSI) * DRP_CONTROL_PSI_TO_DAC_P_ONLY_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); drainPumpDACSet += ( tempDACSet > 0.0F ? tempDACSet : DRP_CONTROL_MIN_DAC_CHANGE ); } }