rllib  1
Public Types | Public Member Functions | Public Attributes
rlController Class Reference

#include <rlcontroller.h>

Inheritance diagram for rlController:
Inheritance graph
[legend]
Collaboration diagram for rlController:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
P 
I 
D_T1 
PI 
PD_T1 
PID_T1 
PI_SUM 
PD_T1_SUM 
PID_T1_SUM 

Definition at line 30 of file rlcontroller.h.

  {
    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
  };

Constructor & Destructor Documentation

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();
}

Member Function Documentation

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.

{
  rlThread::lock();
  type = D_T1;
  T  = _T;
  TD = _TD;
  Td = _Td;
  dt = (int) (1000.0 * T);
  d0 = TD / (Td + T/2.0);
  d1 = -TD / (Td + T/2.0);
  c1 = (Td-T/2.0)/(Td+T/2.0);
  rlThread::unlock();
}
void rlController::setI ( double  _T,
double  _T1 
)
                               1
  Transfer function: Gr(s) = ------
                             T1 * s
  T = cycle time in seconds
  

Definition at line 134 of file rlcontroller.cpp.

{
  rlThread::lock();
  type = I;
  T  = _T;
  T1 = _T1;
  dt = (int) (1000.0 * T);
  d0 = T/(2.0*T1);
  d1 = T/(2.0*T1);
  c1 = 1.0;
  rlThread::unlock();
}
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.

{
  rlThread::lock();
  type = PD_T1;
  T   = _T;
  Kp  = _Kp;
  TvP = _TvP;
  Td  = _Td;
  dt = (int) (1000.0 * T);
  d0 = Kp * (TvP+T/2.0) / (Td + T/2.0);
  d1 = -Kp * (TvP - T/2.0) / (Td + T/2.0);
  c1 = (Td - T/2.0)/(Td + T/2.0);
  rlThread::unlock();
}
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.

{
  rlThread::lock();
  type = PD_T1_SUM;
  T   = _T;
  Kp  = _Kp;
  Tv  = _Tv;
  Td  = _Td;
  dt = (int) (1000.0 * T);
  dD = Kp * (Tv/(Td+T/2.0));
  cD = (Td-T/2.0)/(Td+T/2.0);
  rlThread::unlock();
}
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.

{
  rlThread::lock();
  type = PI;
  T  = _T;
  Kp = _Kp;
  Tn = _Tn;
  dt = (int) (1000.0 * T);
  d0 = Kp * (Tn+T/2.0) / Tn;
  d1 = -Kp * (Tn - T/2.0) / Tn;
  c1 = 1.0;
  rlThread::unlock();
}
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.

{
  rlThread::lock();
  type = PI_SUM;
  T   = _T;
  Kp  = _Kp;
  Tn  = _Tn;
  dt = (int) (1000.0 * T);
  d1 = Kp * (T/2.0)/Tn;
  rlThread::unlock();
}
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.

{
  rlThread::lock();
  type = PID_T1_SUM;
  T   = _T;
  Kp  = _Kp;
  Tn  = _Tn;
  Tv  = _Tv;
  Td  = _Td;
  dt = (int) (1000.0 * T);
  d1 = Kp*T/(2.0*Tn);
  dD = Kp * (Tv/(Td+T/2.0));
  cD = (Td-T/2.0)/(Td+T/2.0);
  rlThread::unlock();
}
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 ( )

Definition at line 96 of file rlcontroller.cpp.

{
  running = 1;
  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;
  rlThread::create(control,this);
}
void rlController::stop ( )

Definition at line 112 of file rlcontroller.cpp.


Member Data Documentation

Definition at line 119 of file rlcontroller.h.

Definition at line 119 of file rlcontroller.h.

Definition at line 119 of file rlcontroller.h.

Definition at line 118 of file rlcontroller.h.

Definition at line 118 of file rlcontroller.h.

Definition at line 118 of file rlcontroller.h.

Definition at line 118 of file rlcontroller.h.

Definition at line 123 of file rlcontroller.h.

Definition at line 121 of file rlcontroller.h.

Definition at line 121 of file rlcontroller.h.

Definition at line 121 of file rlcontroller.h.

  You have to supply this function for getting the measurement
  

Definition at line 128 of file rlcontroller.h.

  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.

Definition at line 115 of file rlcontroller.h.

  last measurement 
  

Definition at line 146 of file rlcontroller.h.

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.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

Definition at line 115 of file rlcontroller.h.

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.

Definition at line 122 of file rlcontroller.h.

Definition at line 122 of file rlcontroller.h.

Definition at line 122 of file rlcontroller.h.

Definition at line 122 of file rlcontroller.h.

Definition at line 120 of file rlcontroller.h.

Definition at line 120 of file rlcontroller.h.

Definition at line 120 of file rlcontroller.h.


The documentation for this class was generated from the following files: