Index: firmware/App/Services/PIControllers.h =================================================================== diff -u -r5e0cd9b5be11ff4b2acaadbdcafc4ffe05172aa1 -r6330949b9dd72e81c3a8405617f27df98acfc3e6 --- firmware/App/Services/PIControllers.h (.../PIControllers.h) (revision 5e0cd9b5be11ff4b2acaadbdcafc4ffe05172aa1) +++ firmware/App/Services/PIControllers.h (.../PIControllers.h) (revision 6330949b9dd72e81c3a8405617f27df98acfc3e6) @@ -1,66 +1,79 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file PIControllers.h +* @file PIControllers.h * -* @author (last) Sean -* @date (last) 22-Apr-2020 +* @author (last) Dara Navaei +* @date (last) 23-Jan-2024 * -* @author (original) Sean -* @date (original) 04-Feb-2020 +* @author (original) Sean +* @date (original) 04-Feb-2020 * ***************************************************************************/ - -#ifndef __PICONTROLLERS_H__ -#define __PICONTROLLERS_H__ - -#include "DGCommon.h" - -/** - * @defgroup PIControllers PIControllers - * @brief PIControllers service module. Provides PI controllers for various actuators. - * - * @addtogroup PIControllers - * @{ - */ - -// ********** public definitions ********** - -/// Enumeration of PI controllers. -typedef enum ControllerList -{ - PI_CONTROLLER_ID_RO_PUMP = 0, ///< RO Pump controller - PI_CONTROLLER_ID_PRIMARY_HEATER, ///< Primary Heater controller - PI_CONTROLLER_ID_TRIMMER_HEATER, ///< Trimmer Heater controller - NUM_OF_PI_CONTROLLERS_IDS ///< Number of PI controllers -} PI_CONTROLLER_ID_T; - -/// Enumeration of PI controller signals. -typedef enum ControllerSignals -{ - CONTROLLER_SIGNAL_REFERENCE = 0, ///< Reference value - CONTROLLER_SIGNAL_MEASURED, ///< Measured value - CONTROLLER_SIGNAL_ERROR, ///< Error value - CONTROLLER_SIGNAL_ERROR_SUM, ///< Error sum before anti-windup - CONTROLLER_SIGNAL_ERROR_SUM_AFTER_WINDUP, ///< Error sum after anti-windup - CONTROLLER_SIGNAL_PROPORTIONAL_OUTPUT, ///< P portion of controller output signal - CONTROLLER_SIGNAL_INTEGRAL_OUTPUT, ///< I portion of controller output signal - CONTROLLER_SIGNAL_CONTROL, ///< Controller output signal - NUM_OF_CONTROLLER_SIGNAL ///< Number of PI controller signals -} PI_CONTROLLER_SIGNALS_ID; - -// ********** public function prototypes ********** - -void initializePIController( PI_CONTROLLER_ID_T controllerID, F32 initialControlSignal, - F32 kP, F32 kI, F32 controlMin, F32 controlMax ); -void resetPIController( PI_CONTROLLER_ID_T controllerID, F32 initialControlSignal ); -F32 runPIController( PI_CONTROLLER_ID_T controllerID, F32 referenceSignal, F32 measuredSignal ); -F32 getPIControllerSignals( PI_CONTROLLER_ID_T controllerID, PI_CONTROLLER_SIGNALS_ID signalID ); - -/**@}*/ - -#endif + +#ifndef __PICONTROLLERS_H__ +#define __PICONTROLLERS_H__ + +#include "DGCommon.h" + +/** + * @defgroup PIControllers PIControllers + * @brief PIControllers service module. Provides PI controllers for various actuators. + * + * @addtogroup PIControllers + * @{ + */ + +// ********** public definitions ********** + +/// Enumeration of PI controllers. +typedef enum ControllerList +{ + PI_CONTROLLER_ID_RO_PUMP_FLOW = 0, ///< RO Pump controller to flow + PI_CONTROLLER_ID_DRAIN_PUMP, ///< Drain Pump controller + PI_CONTROLLER_ID_RO_PUMP_MAX_PRES, ///< RO pump controller to maximum pressure + PI_CONTROLLER_ID_DRAIN_PUMP_VOLUME, ///< Drain pump controller using reservoir volume + NUM_OF_PI_CONTROLLERS_IDS ///< Number of PI controllers +} PI_CONTROLLER_ID_T; + +/// Enumeration of PI controller signals. +typedef enum ControllerSignals +{ + CONTROLLER_SIGNAL_REFERENCE = 0, ///< Reference value + CONTROLLER_SIGNAL_MEASURED, ///< Measured value + CONTROLLER_SIGNAL_ERROR, ///< Error value + CONTROLLER_SIGNAL_ERROR_SUM, ///< Error sum before anti-windup + CONTROLLER_SIGNAL_ERROR_SUM_AFTER_WINDUP, ///< Error sum after anti-windup + CONTROLLER_SIGNAL_PROPORTIONAL_OUTPUT, ///< P portion of controller output signal + CONTROLLER_SIGNAL_INTEGRAL_OUTPUT, ///< I portion of controller output signal + CONTROLLER_SIGNAL_CONTROL, ///< Controller output signal + NUM_OF_CONTROLLER_SIGNAL ///< Number of PI controller signals +} PI_CONTROLLER_SIGNALS_ID; + +/// Data structure for PI control profiles. +typedef struct +{ + F32 Kp; ///< Proportional Value + F32 Ki; ///< Integral Value + F32 uMin; ///< Minimum control signal + F32 uMax; ///< Maximum control signal + F32 maxErrorSumStep; ///< Maximum change in I (error sum) for a single control interval. + U32 controlInterval; ///< Control interval value +} PI_CONTROLLER_PROFILE_DATA_T; + +// ********** public function prototypes ********** + +void initializePIController( PI_CONTROLLER_ID_T controllerID, F32 initialControlSignal, + F32 kP, F32 kI, F32 controlMin, F32 controlMax ); +void resetPIController( PI_CONTROLLER_ID_T controllerID, F32 initialControlSignal ); +F32 runPIController( PI_CONTROLLER_ID_T controllerID, F32 referenceSignal, F32 measuredSignal ); +F32 getPIControllerSignals( PI_CONTROLLER_ID_T controllerID, PI_CONTROLLER_SIGNALS_ID signalID ); +void setPIControllerStepLimit( PI_CONTROLLER_ID_T controllerID, F32 stepLimit ); + +/**@}*/ + +#endif