test
Dependencies: ESP8266 HCSR04 PID
Fork of car_test_v1 by
AutomationElement/PT2cc.h@3:9e51de1050a1, 2017-11-25 (annotated)
- Committer:
- tgw
- Date:
- Sat Nov 25 03:36:58 2017 +0000
- Revision:
- 3:9e51de1050a1
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tgw | 3:9e51de1050a1 | 1 | #ifndef PT2cc_H |
tgw | 3:9e51de1050a1 | 2 | #define PT2cc_H |
tgw | 3:9e51de1050a1 | 3 | |
tgw | 3:9e51de1050a1 | 4 | #include "mbed.h" |
tgw | 3:9e51de1050a1 | 5 | |
tgw | 3:9e51de1050a1 | 6 | /** Transfer function of a general PT2 form. cc stands for conjugate-complex. |
tgw | 3:9e51de1050a1 | 7 | * G(s) = Y(s) / U(s) = K w_n^2 / ( s^2 + 2 zeta w_n + w_n^2 ) |
tgw | 3:9e51de1050a1 | 8 | * |
tgw | 3:9e51de1050a1 | 9 | * Author(s): TVZ Mechatronics Team |
tgw | 3:9e51de1050a1 | 10 | * |
tgw | 3:9e51de1050a1 | 11 | */ |
tgw | 3:9e51de1050a1 | 12 | class PT2cc { |
tgw | 3:9e51de1050a1 | 13 | public: |
tgw | 3:9e51de1050a1 | 14 | /** Default constructor. |
tgw | 3:9e51de1050a1 | 15 | * K = 1, zeta = 0.707, w_n = 1 rad/s, sampleTime = 0.1 s. |
tgw | 3:9e51de1050a1 | 16 | */ |
tgw | 3:9e51de1050a1 | 17 | PT2cc(); |
tgw | 3:9e51de1050a1 | 18 | /** PT2cc transfer function parameters K, zeta, w_n and sample time in seconds. */ |
tgw | 3:9e51de1050a1 | 19 | PT2cc(double K, double zeta, double w_n, double sampleTime); |
tgw | 3:9e51de1050a1 | 20 | /** Update PT2cc transfer function parameters and sample time. */ |
tgw | 3:9e51de1050a1 | 21 | void setParameters(double K, double zeta, double w_n, double sampleTime); |
tgw | 3:9e51de1050a1 | 22 | /** Calculate the output y. */ |
tgw | 3:9e51de1050a1 | 23 | double out(); |
tgw | 3:9e51de1050a1 | 24 | /** Set the input u. */ |
tgw | 3:9e51de1050a1 | 25 | void in(double u); |
tgw | 3:9e51de1050a1 | 26 | private: |
tgw | 3:9e51de1050a1 | 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; |
tgw | 3:9e51de1050a1 | 28 | }; |
tgw | 3:9e51de1050a1 | 29 | |
tgw | 3:9e51de1050a1 | 30 | #endif // PT2cc_H |