|
rllib
1
|
#include <rlcontroller.h>


Public Types | |
| enum | ControllerType { P = 1, I = 2, D_T1 = 3, PI = 4, PD_T1 = 5, PID_T1 = 6, PI_SUM = 7, PD_T1_SUM = 8, PID_T1_SUM = 9 } |
Public Member Functions | |
| rlController (double(*_getMeasurement)(), void(_writeOutput)(double output)) | |
| ~rlController () | |
| void | start () |
| void | stop () |
| void | setReference (double _reference) |
| void | setP (double _T, double _Kp) |
| void | setI (double _T, double _T1) |
| void | setD_T1 (double _T, double _TD, double _Td) |
| void | setPI (double _T, double _Kp, double _Tn) |
| void | setPD_T1 (double _T, double _Kp, double _TvP, double _Td) |
| void | setPID_T1 (double _T, double _Kpp, double _TnP, double _TvP, double _Td) |
| void | setPI_SUM (double _T, double _Kp, double _Tn) |
| void | setPD_T1_SUM (double _T, double _Kp, double _Tv, double _Td) |
| void | setPID_T1_SUM (double _T, double _Kp, double _Tn, double _Tv, double _Td) |
Public Attributes | |
| double | Kp |
| double | Kpp |
| double | T |
| double | T1 |
| double | Td |
| double | TD |
| double | Tn |
| double | TnP |
| double | TvP |
| double | Tv |
| double | reference |
| int | type |
| int | running |
| double | d0 |
| double | d1 |
| double | d2 |
| double | dD |
| double | c1 |
| double | c2 |
| double | cD |
| double | yk |
| double | yk_1 |
| double | yk_2 |
| double | ek |
| double | ek_1 |
| double | ek_2 |
| double | y1k |
| double | y1k_1 |
| double | ydk |
| double | ydk_1 |
| int | dt |
| double(* | getMeasurement )() |
| void(* | writeOutput )(double output) |
| int | sleepLocally |
| double | measurement |
class for closed loop control According to: F. Doerrscheid/W. Latzel, Grundlagen der Regelungstechnik, B.G. Teubner Stuttgart Page 436-437, Regelalgorithmen mit der Trapezregel
Definition at line 27 of file rlcontroller.h.
| rlController::rlController | ( | double(*)() | _getMeasurement, |
| void(_writeOutput)(double output) | |||
| ) |
Definition at line 70 of file rlcontroller.cpp.
:rlThread() { type = -1; running = 0; getMeasurement = _getMeasurement; writeOutput = _writeOutput; ydk_1 = 0.0f; ydk = 0.0f; y1k_1 = 0.0f; y1k = 0.0f; yk_2 = 0.0f; yk_1 = 0.0f; yk = 0.0f; ek_2 = 0.0f; ek_1 = 0.0f; ek = 0.0f; reference = measurement = 0.0; sleepLocally = 1; }
| rlController::~rlController | ( | ) |
Definition at line 91 of file rlcontroller.cpp.
{
stop();
}
| void rlController::setD_T1 | ( | double | _T, |
| double | _TD, | ||
| double | _Td | ||
| ) |
TD * s
Transfer function: Gr(s) = ---------
1 + Td*s
T = cycle time in seconds
Definition at line 147 of file rlcontroller.cpp.
| void rlController::setI | ( | double | _T, |
| double | _T1 | ||
| ) |
| void rlController::setP | ( | double | _T, |
| double | _Kp | ||
| ) |
Transfer function: Gr(s) = Kp
Definition at line 123 of file rlcontroller.cpp.
{
rlThread::lock();
type = P;
T = _T;
Kp = _Kp;
dt = (int) (1000.0 * T);
d0 = Kp;
rlThread::unlock();
}
| void rlController::setPD_T1 | ( | double | _T, |
| double | _Kp, | ||
| double | _TvP, | ||
| double | _Td | ||
| ) |
1 + TvP*s
Transfer function: Gr(s) = Kp * ---------
1 + Td*s
T = cycle time in seconds
Definition at line 175 of file rlcontroller.cpp.
| void rlController::setPD_T1_SUM | ( | double | _T, |
| double | _Kp, | ||
| double | _Tv, | ||
| double | _Td | ||
| ) |
Tv*s
Transfer function: Gr(s) = Kp * ( 1 + -------- )
1 + Td*s
T = cycle time in seconds
Definition at line 220 of file rlcontroller.cpp.
| void rlController::setPI | ( | double | _T, |
| double | _Kp, | ||
| double | _Tn | ||
| ) |
1 + Tn*s
Transfer function: Gr(s) = Kp * --------
Tn*s
T = cycle time in seconds
Definition at line 161 of file rlcontroller.cpp.
| void rlController::setPI_SUM | ( | double | _T, |
| double | _Kp, | ||
| double | _Tn | ||
| ) |
1
Transfer function: Gr(s) = Kp * ( 1 + ---- )
Tn*s
T = cycle time in seconds
Definition at line 208 of file rlcontroller.cpp.
| void rlController::setPID_T1 | ( | double | _T, |
| double | _Kpp, | ||
| double | _TnP, | ||
| double | _TvP, | ||
| double | _Td | ||
| ) |
1 + TnP*s 1 + TvP*s
Transfer function: Gr(s) = Kpp * --------- * ---------
TnP*s 1 + Td*s
T = cycle time in seconds
Definition at line 190 of file rlcontroller.cpp.
{
rlThread::lock();
type = PID_T1;
T = _T;
Kpp = _Kpp;
TnP = _TnP;
TvP = _TvP;
Td = _Td;
dt = (int) (1000.0 * T);
d0 = Kpp * ((TnP+T/2.0) / TnP) * ((TvP+T/2.0))/(Td+T/2.0);
d1 = -2.0*Kpp * (TnP*TvP - (T/2.0)*(T/2.0)) / (TnP*(Td+T/2.0));
d2 = Kpp*((TnP-T/2.0)/TnP)*((TvP-T/2.0)/(Td+T/2.0));
c1 = 2*Td/(Td+T/2.0);
c2 = -(Td-T/2.0)/(Td+T/2.0);
rlThread::unlock();
}
| void rlController::setPID_T1_SUM | ( | double | _T, |
| double | _Kp, | ||
| double | _Tn, | ||
| double | _Tv, | ||
| double | _Td | ||
| ) |
1 Tv*s
Transfer function: Gr(s) = Kp * ( 1 + ---- + -------- )
Tn*s 1 + Td*s
T = cycle time in seconds
Definition at line 234 of file rlcontroller.cpp.
| void rlController::setReference | ( | double | _reference | ) |
Set the reference value for the controller
Definition at line 118 of file rlcontroller.cpp.
{
reference = _reference;
}
| void rlController::start | ( | ) |
| void rlController::stop | ( | ) |
Definition at line 112 of file rlcontroller.cpp.
{
if(running) rlThread::cancel();
running = 0;
}
| double rlController::c1 |
Definition at line 119 of file rlcontroller.h.
| double rlController::c2 |
Definition at line 119 of file rlcontroller.h.
| double rlController::cD |
Definition at line 119 of file rlcontroller.h.
| double rlController::d0 |
Definition at line 118 of file rlcontroller.h.
| double rlController::d1 |
Definition at line 118 of file rlcontroller.h.
| double rlController::d2 |
Definition at line 118 of file rlcontroller.h.
| double rlController::dD |
Definition at line 118 of file rlcontroller.h.
| int rlController::dt |
Definition at line 123 of file rlcontroller.h.
| double rlController::ek |
Definition at line 121 of file rlcontroller.h.
| double rlController::ek_1 |
Definition at line 121 of file rlcontroller.h.
| double rlController::ek_2 |
Definition at line 121 of file rlcontroller.h.
| double(* rlController::getMeasurement)() |
You have to supply this function for getting the measurement
Definition at line 128 of file rlcontroller.h.
| double rlController::Kp |
Don't set the controller parameters directly Use the set methods, because they will also set the coefficients Controller parameters are for reading only
Definition at line 115 of file rlcontroller.h.
| double rlController::Kpp |
Definition at line 115 of file rlcontroller.h.
| double rlController::measurement |
last measurement
Definition at line 146 of file rlcontroller.h.
| double rlController::reference |
Definition at line 115 of file rlcontroller.h.
Definition at line 117 of file rlcontroller.h.
Default sleepLocally = 1 But: Sleeping locally might me inaccurate. It might be better to have a central timer and wait for it in double (*_getMeasurement)(); T = cycle time in seconds
Definition at line 142 of file rlcontroller.h.
| double rlController::T |
Definition at line 115 of file rlcontroller.h.
| double rlController::T1 |
Definition at line 115 of file rlcontroller.h.
| double rlController::Td |
Definition at line 115 of file rlcontroller.h.
| double rlController::TD |
Definition at line 115 of file rlcontroller.h.
| double rlController::Tn |
Definition at line 115 of file rlcontroller.h.
| double rlController::TnP |
Definition at line 115 of file rlcontroller.h.
| double rlController::Tv |
Definition at line 115 of file rlcontroller.h.
| double rlController::TvP |
Definition at line 115 of file rlcontroller.h.
Definition at line 116 of file rlcontroller.h.
| void(* rlController::writeOutput)(double output) |
You have to supply this function for writing the output
Definition at line 132 of file rlcontroller.h.
| double rlController::y1k |
Definition at line 122 of file rlcontroller.h.
| double rlController::y1k_1 |
Definition at line 122 of file rlcontroller.h.
| double rlController::ydk |
Definition at line 122 of file rlcontroller.h.
| double rlController::ydk_1 |
Definition at line 122 of file rlcontroller.h.
| double rlController::yk |
Definition at line 120 of file rlcontroller.h.
| double rlController::yk_1 |
Definition at line 120 of file rlcontroller.h.
| double rlController::yk_2 |
Definition at line 120 of file rlcontroller.h.
1.7.5.1