test

Fork of AutomationElements by TVZ Mechatronics Team

Committer:
tgw
Date:
Sat Nov 25 02:03:00 2017 +0000
Revision:
2:a45cbb512c99
Parent:
PI.h@0:3dd7aeceee65
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tgw 2:a45cbb512c99 1 #ifndef PI1_H
tgw 2:a45cbb512c99 2 #define PI1_H
tbjazic 0:3dd7aeceee65 3
tbjazic 0:3dd7aeceee65 4 #include "mbed.h"
tbjazic 0:3dd7aeceee65 5
tbjazic 0:3dd7aeceee65 6 /** Data type for choosing the operation mode of the controller ("automatic" or "manual"). */
tbjazic 0:3dd7aeceee65 7 enum Mode {automatic, manual};
tbjazic 0:3dd7aeceee65 8
tbjazic 0:3dd7aeceee65 9 /** Transfer function of a PI controller with output limitation, anti-windup and bumpless automatic and manual mode.
tbjazic 0:3dd7aeceee65 10 * G_C(s) = U_C(s) / E(s) = K_C ( 1 + 1 / (T_I s) ) = K_C (1 + T_I s) / (T_I s)
tbjazic 0:3dd7aeceee65 11 *
tbjazic 0:3dd7aeceee65 12 * K_C is the controller gain, and T_I is the controller integral time constant in seconds.
tbjazic 0:3dd7aeceee65 13 *
tbjazic 0:3dd7aeceee65 14 * Author(s): TVZ Mechatronics Team
tbjazic 0:3dd7aeceee65 15 *
tbjazic 0:3dd7aeceee65 16 */
tgw 2:a45cbb512c99 17 class PI1 {
tbjazic 0:3dd7aeceee65 18 public:
tbjazic 0:3dd7aeceee65 19 /** Default constructor.
tbjazic 0:3dd7aeceee65 20 * K_C = 1, T_I = 1 s, sampleTime = 0.1 s.
tbjazic 0:3dd7aeceee65 21 */
tgw 2:a45cbb512c99 22 PI1();
tbjazic 0:3dd7aeceee65 23 /** PI controller gain, integral time constant in seconds and sample time in seconds. */
tgw 2:a45cbb512c99 24 PI1(double K_C, double T_I, double sampleTime);
tbjazic 0:3dd7aeceee65 25 /** Update PI controller gain, integral time constant and sample time. */
tbjazic 0:3dd7aeceee65 26 void setParameters(double K_C, double T_I, double sampleTime);
tbjazic 0:3dd7aeceee65 27 /** Set the controller lower and upper output limit. */
tbjazic 0:3dd7aeceee65 28 void setOutputLimits(double lowerOutputLimit, double upperOutputLimit);
tbjazic 0:3dd7aeceee65 29 /** Set the operation mode to "automatic" or "manual". */
tbjazic 0:3dd7aeceee65 30 void setOperationMode (Mode operationMode);
tbjazic 0:3dd7aeceee65 31 /** Set the controller output manually. */
tbjazic 0:3dd7aeceee65 32 void setOutputManually(double u_C);
tbjazic 0:3dd7aeceee65 33 /** Calculate the controller output u_C. */
tbjazic 0:3dd7aeceee65 34 double out();
tbjazic 0:3dd7aeceee65 35 /** Set the PI controller input e = SP - PV (setpoint - process value). */
tbjazic 0:3dd7aeceee65 36 void in(double e);
tbjazic 0:3dd7aeceee65 37 private:
tbjazic 0:3dd7aeceee65 38 double K_R, T_I, T_d, y, y_p1, u, u_p1, y_max, y_min, y_manual;
tbjazic 0:3dd7aeceee65 39 Mode operationMode;
tbjazic 0:3dd7aeceee65 40 };
tbjazic 0:3dd7aeceee65 41
tgw 2:a45cbb512c99 42 #endif // PI1_H