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
PT1.h@1:b9e11da0f2eb, 2015-01-22 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:3dd7aeceee65 | 1 | #ifndef PT1_H |
tbjazic | 0:3dd7aeceee65 | 2 | #define PT1_H |
tbjazic | 0:3dd7aeceee65 | 3 | |
tbjazic | 0:3dd7aeceee65 | 4 | #include "mbed.h" |
tbjazic | 0:3dd7aeceee65 | 5 | |
tbjazic | 0:3dd7aeceee65 | 6 | /** Transfer function of a PT1 form. |
tbjazic | 0:3dd7aeceee65 | 7 | * G(s) = Y(s) / U(s) = K / (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 PT1 { |
tbjazic | 0:3dd7aeceee65 | 13 | public: |
tbjazic | 0:3dd7aeceee65 | 14 | /** Default constructor. |
tbjazic | 0:3dd7aeceee65 | 15 | * K = 1, T_1 = 1, sampleTime = 0.1 |
tbjazic | 0:3dd7aeceee65 | 16 | */ |
tbjazic | 0:3dd7aeceee65 | 17 | PT1(); |
tbjazic | 0:3dd7aeceee65 | 18 | /** PT1 transfer function parameters and sample time in seconds. */ |
tbjazic | 0:3dd7aeceee65 | 19 | PT1(double K, double T_1, double sampleTime); |
tbjazic | 0:3dd7aeceee65 | 20 | /** Update PT1 transfer function parameters and sample time. */ |
tbjazic | 0:3dd7aeceee65 | 21 | void setParameters(double K, double T_1, 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, T_1, T_d, a_1, b_1, y, y_p1, u, u_p1; |
tbjazic | 0:3dd7aeceee65 | 28 | }; |
tbjazic | 0:3dd7aeceee65 | 29 | |
tbjazic | 0:3dd7aeceee65 | 30 | #endif // PT1_H |