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
DT1.h@0:3dd7aeceee65, 2015-01-22 (annotated)
- Committer:
- tbjazic
- Date:
- Thu Jan 22 11:41:02 2015 +0000
- Revision:
- 0:3dd7aeceee65
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:3dd7aeceee65 | 1 | #ifndef DT1_H |
tbjazic | 0:3dd7aeceee65 | 2 | #define DT1_H |
tbjazic | 0:3dd7aeceee65 | 3 | |
tbjazic | 0:3dd7aeceee65 | 4 | #include "mbed.h" |
tbjazic | 0:3dd7aeceee65 | 5 | |
tbjazic | 0:3dd7aeceee65 | 6 | /** Transfer function of a DT1 form. |
tbjazic | 0:3dd7aeceee65 | 7 | * G(s) = Y(s) / U(s) = T_D s / (1 + T_1 s) |
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 DT1 { |
tbjazic | 0:3dd7aeceee65 | 13 | public: |
tbjazic | 0:3dd7aeceee65 | 14 | /** Default constructor. |
tbjazic | 0:3dd7aeceee65 | 15 | * T_1 = 1, T_D = 0.5, sampleTime = 0.1 |
tbjazic | 0:3dd7aeceee65 | 16 | */ |
tbjazic | 0:3dd7aeceee65 | 17 | DT1(); |
tbjazic | 0:3dd7aeceee65 | 18 | /** DT1 transfer function parameters and sample time in seconds. */ |
tbjazic | 0:3dd7aeceee65 | 19 | DT1(double T_1, double T_D, double sampleTime); |
tbjazic | 0:3dd7aeceee65 | 20 | /** Update DT1 transfer function parameters and sample time. */ |
tbjazic | 0:3dd7aeceee65 | 21 | void setParameters(double T_1, double T_D, 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 y, y_p1; |
tbjazic | 0:3dd7aeceee65 | 28 | double u, u_p1; |
tbjazic | 0:3dd7aeceee65 | 29 | double T_1, T_D, T_d, a_1, b_0, b_1; |
tbjazic | 0:3dd7aeceee65 | 30 | }; |
tbjazic | 0:3dd7aeceee65 | 31 | |
tbjazic | 0:3dd7aeceee65 | 32 | #endif // DT1_H |