Library containing essential automation elements with parameters in continuous Laplace domain, and implemented with fixed sample time. This means that "out" member functions should be called using Ticker object.

Dependents:   CurrentMeasurement Zavrsni_rad_NXP_cup HC-SR04 Nucleo_SSD1306_DS1302_ESP8266_AM2320_BME280 ... more

Committer:
tbjazic
Date:
Thu Jan 22 12:44:37 2015 +0000
Revision:
1:b9e11da0f2eb
Parent:
0:3dd7aeceee65
Added header file "AutomationElements.h".

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:3dd7aeceee65 1 #ifndef PT2cc_H
tbjazic 0:3dd7aeceee65 2 #define PT2cc_H
tbjazic 0:3dd7aeceee65 3
tbjazic 0:3dd7aeceee65 4 #include "mbed.h"
tbjazic 0:3dd7aeceee65 5
tbjazic 0:3dd7aeceee65 6 /** Transfer function of a general PT2 form. cc stands for conjugate-complex.
tbjazic 0:3dd7aeceee65 7 * G(s) = Y(s) / U(s) = K w_n^2 / ( s^2 + 2 zeta w_n + w_n^2 )
tbjazic 0:3dd7aeceee65 8 *
tbjazic 0:3dd7aeceee65 9 * Author(s): TVZ Mechatronics Team
tbjazic 0:3dd7aeceee65 10 *
tbjazic 0:3dd7aeceee65 11 */
tbjazic 0:3dd7aeceee65 12 class PT2cc {
tbjazic 0:3dd7aeceee65 13 public:
tbjazic 0:3dd7aeceee65 14 /** Default constructor.
tbjazic 0:3dd7aeceee65 15 * K = 1, zeta = 0.707, w_n = 1 rad/s, sampleTime = 0.1 s.
tbjazic 0:3dd7aeceee65 16 */
tbjazic 0:3dd7aeceee65 17 PT2cc();
tbjazic 0:3dd7aeceee65 18 /** PT2cc transfer function parameters K, zeta, w_n and sample time in seconds. */
tbjazic 0:3dd7aeceee65 19 PT2cc(double K, double zeta, double w_n, double sampleTime);
tbjazic 0:3dd7aeceee65 20 /** Update PT2cc transfer function parameters and sample time. */
tbjazic 0:3dd7aeceee65 21 void setParameters(double K, double zeta, double w_n, double sampleTime);
tbjazic 0:3dd7aeceee65 22 /** Calculate the output y. */
tbjazic 0:3dd7aeceee65 23 double out();
tbjazic 0:3dd7aeceee65 24 /** Set the input u. */
tbjazic 0:3dd7aeceee65 25 void in(double u);
tbjazic 0:3dd7aeceee65 26 private:
tbjazic 0:3dd7aeceee65 27 double K, zeta, w_n, T_d, a, b, c, d, e, a_1, a_2, b_1, b_2, y, y_p1, y_p2, u, u_p1, u_p2;
tbjazic 0:3dd7aeceee65 28 };
tbjazic 0:3dd7aeceee65 29
tbjazic 0:3dd7aeceee65 30 #endif // PT2cc_H