涂 桂旺 / AutomationElements

Fork of AutomationElements by TVZ Mechatronics Team

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PI1.h Source File

PI1.h

00001 #ifndef PI1_H
00002 #define PI1_H
00003 
00004 #include "mbed.h"
00005 
00006 /** Data type for choosing the operation mode of the controller ("automatic" or "manual"). */
00007 enum Mode {automatic, manual};
00008 
00009 /** Transfer function of a PI controller with output limitation, anti-windup and bumpless automatic and manual mode.
00010  * G_C(s) = U_C(s) / E(s) = K_C ( 1 + 1 / (T_I s) ) = K_C (1 + T_I s) / (T_I s)
00011  *
00012  * K_C is the controller gain, and T_I is the controller integral time constant in seconds.
00013  *
00014  * Author(s): TVZ Mechatronics Team
00015  *
00016  */
00017 class PI1 {
00018     public:
00019         /** Default constructor.
00020          * K_C = 1, T_I = 1 s, sampleTime = 0.1 s.
00021          */
00022         PI1();
00023         /** PI controller gain, integral time constant in seconds and sample time in seconds. */
00024         PI1(double K_C, double T_I, double sampleTime);
00025         /** Update PI controller gain, integral time constant and sample time. */
00026         void setParameters(double K_C, double T_I, double sampleTime);
00027         /** Set the controller lower and upper output limit. */
00028         void setOutputLimits(double lowerOutputLimit, double upperOutputLimit);
00029         /** Set the operation mode to "automatic" or "manual". */
00030         void setOperationMode (Mode operationMode);
00031         /** Set the controller output manually. */
00032         void setOutputManually(double u_C);
00033         /** Calculate the controller output u_C. */
00034         double out();
00035         /** Set the PI controller input e = SP - PV (setpoint - process value). */
00036         void in(double e);
00037     private:
00038         double K_R, T_I, T_d, y, y_p1, u, u_p1, y_max, y_min, y_manual;
00039         Mode operationMode;
00040 };
00041 
00042 #endif // PI1_H