Index: PIControllers.c =================================================================== diff -u -rc6962f9353afede1a8c731490a105269dd88b7f8 -r742ee2add33924e4b6750bc88622f09e0791feb4 --- PIControllers.c (.../PIControllers.c) (revision c6962f9353afede1a8c731490a105269dd88b7f8) +++ PIControllers.c (.../PIControllers.c) (revision 742ee2add33924e4b6750bc88622f09e0791feb4) @@ -77,6 +77,8 @@ { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, CONTROLLER_UNIDIRECTIONAL, FALSE, 0.0 }, // PI_CONTROLLER_ID_RO_PUMP_MAX_PRES { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, CONTROLLER_UNIDIRECTIONAL, FALSE, 0.0 }, // PI_CONTROLLER_ID_BOOST_PUMP_FLOW { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, CONTROLLER_UNIDIRECTIONAL, FALSE, 0.0 }, // PI_CONTROLLER_ID_BOOST_PUMP_PRES + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 75, CONTROLLER_UNIDIRECTIONAL, FALSE, 0.0 }, // PI_CONTROLLER_ID_BICARB_VOL + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300, CONTROLLER_UNIDIRECTIONAL, FALSE, 0.0 }, // PI_CONTROLLER_ID_ACID_VOL #endif }; @@ -344,6 +346,48 @@ /*********************************************************************//** * @brief + * The getPIControllerSignals function returns the latest requested signal sample. + * @details \b Inputs: none + * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_XX_SOFTWARE_FAULT when invalid PI controller + * Id is passed. + * @details \b Alarms: ALARM_ID_XX_SOFTWARE_FAULT when invalid PI controller + * signal is passed. + * @param controllerID ID filter number + * @param signalID signal sample ID request + * @return latest sample requested + *************************************************************************/ +PI_CONTROLLER_SIGNALS_DATA getDebugPIControllerSignals( PI_CONTROLLER_ID_T controllerID ) +{ + PI_CONTROLLER_T *controller; + PI_CONTROLLER_SIGNALS_DATA signals; + + if ( controllerID < NUM_OF_PI_CONTROLLERS_IDS ) + { + SET_CONTROLLER( controller, controllerID ); + + signals.controlSignalReference = controller->referenceSignal; + signals.controlSignalMeasured = controller->measuredSignal; + signals.controlSignalError = controller->errorSignal; + signals.controlSignalErrorSum = controller->errorSumBeforeWindUp; + signals.controlSignalErrorSumAfterWindup = controller->errorSum; + signals.controlSignalProportionalOutput = controller->Kp * controller->errorSignal; + signals.controlSignalIntegralOutput = controller->Ki * controller->errorSum; + signals.controlSignalFeedDorwardOutput = controller->feedForward; + signals.controlSingalControl = controller->controlSignal; + } + else + { // Invalid controller given +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PI_CTRL_INVALID_CONTROLLER, (U32)controllerID ) +#endif + } + + return signals; +} + +/*********************************************************************//** + * @brief * The setPIControllerStepLimit function sets the step limit value. * @details \b Inputs: none * @details \b Outputs: maxErrorSumStep of controller ID Index: PIControllers.h =================================================================== diff -u -r5b4db16e34780cbbe85fbc3b994acbe0e68108e8 -r742ee2add33924e4b6750bc88622f09e0791feb4 --- PIControllers.h (.../PIControllers.h) (revision 5b4db16e34780cbbe85fbc3b994acbe0e68108e8) +++ PIControllers.h (.../PIControllers.h) (revision 742ee2add33924e4b6750bc88622f09e0791feb4) @@ -51,6 +51,8 @@ PI_CONTROLLER_ID_RO_PUMP_PRES, ///< RO pump controller to maximum pressure PI_CONTROLLER_ID_BOOST_PUMP_FLOW, ///< Boost pump controller to flow PI_CONTROLLER_ID_BOOST_PUMP_PRES, ///< Boost pump controller to maximum pressure + PI_CONTROLLER_ID_BICARB_VOL, ///< Bicarb dose volume + PI_CONTROLLER_ID_ACID_VOL, ///< Acid dose volume #endif NUM_OF_PI_CONTROLLERS_IDS ///< Number of PI controllers } PI_CONTROLLER_ID_T; @@ -70,6 +72,20 @@ NUM_OF_CONTROLLER_SIGNAL ///< Number of PI controller signals } PI_CONTROLLER_SIGNALS_ID; +/// Data structure for debugging PI controller signals. +typedef struct DebugControllerSignals +{ + F32 controlSignalReference; ///< Reference value + F32 controlSignalMeasured; ///< Measured value + F32 controlSignalError; ///< Error value + F32 controlSignalErrorSum; ///< Error sum before anti-windup + F32 controlSignalErrorSumAfterWindup; ///< Error sum after anti-windup + F32 controlSignalProportionalOutput; ///< P portion of controller output signal + F32 controlSignalIntegralOutput; ///< I portion of controller output signal + F32 controlSignalFeedDorwardOutput; ///< Feed forward portion of controller output signal + F32 controlSingalControl; ///< Controller output signal + } PI_CONTROLLER_SIGNALS_DATA; + /// Data structure for PI control profiles. typedef struct { @@ -91,6 +107,7 @@ F32 getPIControllerSignals( PI_CONTROLLER_ID_T controllerID, PI_CONTROLLER_SIGNALS_ID signalID ); void setPIControllerStepLimit( PI_CONTROLLER_ID_T controllerID, F32 stepLimit ); void setPIControllerFeedForward( PI_CONTROLLER_ID_T controllerID, F32 feedforward ); +PI_CONTROLLER_SIGNALS_DATA getDebugPIControllerSignals( PI_CONTROLLER_ID_T controllerID ); /**@}*/