#include <TPIDController.h>
This object represents a PID controller
Definition at line 35 of file TPIDController.h.
◆ TPIDController()
| TPIDController::TPIDController |
( |
int |
i | ) |
|
PID controller contructor
- Parameters
-
Definition at line 35 of file TPIDController.cpp.
TController(nmControlMethod meth, int i)
◆ ~TPIDController()
| TPIDController::~TPIDController |
( |
| ) |
|
◆ AcumulaResultadosMediosController()
| void TPIDController::AcumulaResultadosMediosController |
( |
double |
Actual | ) |
|
|
virtual |
Acumulate average results
- Parameters
-
Implements TController.
Definition at line 444 of file TPIDController.cpp.
471 }
catch(exception & N) {
472 std::cout <<
"ERROR: TPIDController::AcumulaResultadosMediosController en el eje: " << fID << std::endl;
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl.
◆ AsignaObjetos()
Asign the sensor input and the setpoint controller
- Parameters
-
| Sensor | Array with sensor objects |
| Controller | Array with controller objects |
Implements TController.
Definition at line 165 of file TPIDController.cpp.
169 if(fSetPointControlled)
170 fSetPointController = Controller[fSetPointControllerID - 1];
std::vector< TSensor * > FSensor
Array with the pointers of the sensor inputs.
iVector FSensorID
Array with the ID of the sensor inputs.
References TController::FSensor, and TController::FSensorID.
◆ CabeceraResultadosInsControlador()
| void TPIDController::CabeceraResultadosInsControlador |
( |
stringstream & |
insoutput | ) |
|
|
virtual |
Generate instantaneous results header
- Parameters
-
| insoutput | StringStream where the instantaneous results are stored |
Implements TController.
Definition at line 296 of file TPIDController.cpp.
302 insoutput << Label.c_str();
306 insoutput << Label.c_str();
310 insoutput << Label.c_str();
314 insoutput << Label.c_str();
318 insoutput << Label.c_str();
322 insoutput << Label.c_str();
324 }
catch(exception & N) {
325 std::cout <<
"ERROR: TPIDController::CabeceraResultadosInsControlador en el controlador " << fID << std::endl;
326 std::cout <<
"Tipo de error: " << N.what() << std::endl;
std::string PutLabel(int idx)
Returns an integer.
stResInstantCtrl FResInstantCtrl
Struct with the average results of the controllers.
References TController::FResInstantCtrl, and PutLabel().
◆ CabeceraResultadosMedControlador()
| void TPIDController::CabeceraResultadosMedControlador |
( |
stringstream & |
medoutput | ) |
|
|
virtual |
Generate average results header
- Parameters
-
| medoutput | StringStrems where the average results are stored |
Implements TController.
Definition at line 260 of file TPIDController.cpp.
266 medoutput << Label.c_str();
270 medoutput << Label.c_str();
274 medoutput << Label.c_str();
278 medoutput << Label.c_str();
282 medoutput << Label.c_str();
286 medoutput << Label.c_str();
289 }
catch(exception & N) {
290 std::cout <<
"ERROR: TPIDController::CabeceraResultadosMedControlador en el controlador " << fID << std::endl;
291 std::cout <<
"Tipo de error: " << N.what() << std::endl;
std::string PutLabel(int idx)
Returns an integer.
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl, and PutLabel().
◆ ImprimeResultadosInsControlador()
| void TPIDController::ImprimeResultadosInsControlador |
( |
stringstream & |
insoutput | ) |
|
|
virtual |
Print instantaneous results
- Parameters
-
| insoutput | StringStream where the instantaneous results are stored |
Implements TController.
Definition at line 360 of file TPIDController.cpp.
382 }
catch(exception & N) {
383 std::cout <<
"ERROR: TPIDController::CabeceraResultadosInsControlador en el controlador " << fID << std::endl;
384 std::cout <<
"Tipo de error: " << N.what() << std::endl;
stResInstantCtrl FResInstantCtrl
Struct with the average results of the controllers.
References TController::FResInstantCtrl.
◆ ImprimeResultadosMedControlador()
| void TPIDController::ImprimeResultadosMedControlador |
( |
stringstream & |
medoutput | ) |
|
|
virtual |
Print average results
- Parameters
-
| medoutput | StringStream where the average results are stored |
Implements TController.
Definition at line 331 of file TPIDController.cpp.
353 }
catch(exception & N) {
354 std::cout <<
"ERROR: TPIDController::ImprimeResultadosMedControlador en el controlador " << fID << std::endl;
355 std::cout <<
"Tipo de error: " << N.what() << std::endl;
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl.
◆ IniciaMedias()
| void TPIDController::IniciaMedias |
( |
| ) |
|
|
virtual |
Initialize average results
Implements TController.
Definition at line 389 of file TPIDController.cpp.
401 }
catch(exception & N) {
402 std::cout <<
"ERROR: TPIDController::IniciaMedias en el controlador: " << fID << std::endl;
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl.
◆ LeeController()
| void TPIDController::LeeController |
( |
const char * |
FileWAM, |
|
|
fpos_t & |
filepos |
|
) |
| |
|
virtual |
Read the PID data
- Parameters
-
| FileWAM | Input data filename |
| filepos | Position within the input file |
Implements TController.
Definition at line 126 of file TPIDController.cpp.
130 FILE *fich = fopen(FileWAM,
"r");
131 fsetpos(fich, &filepos);
133 fscanf(fich,
"%lf %lf %lf ", &fKP_pos, &fKI_pos, &fKD_pos);
134 fscanf(fich,
"%lf %lf %lf ", &fKP_neg, &fKI_neg, &fKD_neg);
136 fscanf(fich,
"%lf %lf %lf %lf ", &fOutput, &fOutput0, &fMax_out, &fMin_out);
138 fscanf(fich,
"%lf %lf %lf ", &fPeriod, &fDelay, &fGain);
142 fOutput_ant = fOutput;
143 fOutput_filt = fOutput;
144 fOutput_filt_ant = fOutput;
148 fscanf(fich,
"%lf ", &fSetPoint);
149 fscanf(fich,
"%d ", &ctrl);
151 fSetPointControlled =
false;
153 fSetPointControlled =
true;
154 fSetPointControllerID = ctrl;
160 fgetpos(fich, &filepos);
iVector FSensorID
Array with the ID of the sensor inputs.
References TController::FSensorID.
◆ LeeResultadosInsControlador()
| void TPIDController::LeeResultadosInsControlador |
( |
const char * |
FileWAM, |
|
|
fpos_t & |
filepos |
|
) |
| |
|
virtual |
Read the instantaneous results selected
- Parameters
-
| FileWAM | Input data filename |
| filepos | Position within the input file |
Implements TController.
Definition at line 217 of file TPIDController.cpp.
219 int nvars = 0, var = 0;
221 FILE *fich = fopen(FileWAM,
"r");
222 fsetpos(fich, &filepos);
224 fscanf(fich,
"%d ", &nvars);
225 for(
int i = 0; i < nvars; i++) {
226 fscanf(fich,
"%d ", &var);
247 std::cout <<
"Resultados instantaneos en Controlador " << fID <<
" no implementados " << std::endl;
251 fgetpos(fich, &filepos);
253 }
catch(exception & N) {
254 std::cout <<
"ERROR: TPIDController::LeeResultadosInsControlador en el controlador " << fID << std::endl;
255 std::cout <<
"Tipo de error: " << N.what() << std::endl;
stResInstantCtrl FResInstantCtrl
Struct with the average results of the controllers.
References TController::FResInstantCtrl.
◆ LeeResultadosMedControlador()
| void TPIDController::LeeResultadosMedControlador |
( |
const char * |
FileWAM, |
|
|
fpos_t & |
filepos |
|
) |
| |
|
virtual |
Read the average results selected
- Parameters
-
| FileWAM | Input data filename |
| filepos | Position within the input file |
Implements TController.
Definition at line 174 of file TPIDController.cpp.
176 int nvars = 0, var = 0;
178 FILE *fich = fopen(FileWAM,
"r");
179 fsetpos(fich, &filepos);
181 fscanf(fich,
"%d ", &nvars);
182 for(
int i = 0; i < nvars; i++) {
183 fscanf(fich,
"%d ", &var);
204 std::cout <<
"Resultados medios en Controlador " << fID <<
" no implementados " << std::endl;
208 fgetpos(fich, &filepos);
210 }
catch(exception & N) {
211 std::cout <<
"ERROR: TPIDController::LeeResultadosControlador en el controlador " << fID << std::endl;
212 std::cout <<
"Tipo de error: " << N.what() << std::endl;
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl.
◆ Output()
| double TPIDController::Output |
( |
double |
Time | ) |
|
|
virtual |
Return the PID controller output
- Parameters
-
Implements TController.
Definition at line 48 of file TPIDController.cpp.
49 double dt = 0., out = 0., deltaT = 0., Kp = 0., Ki = 0., Kd = 0.;
51 dt = Time - fTime_ant;
53 if(dt > fPeriod && Time > fDwell) {
55 if(fSetPointControlled)
56 fSetPoint = fSetPointController->
Output(Time);
58 fError =
FSensor[0]->Output() - fSetPoint;
84 fdact = Kd * (fError - fError_ant) / dt;
85 fiact = fiact + Ki * fError * dt;
90 fOutput = fpact + fdact + fiact;
92 if(fOutput > fMax_out) {
97 }
else if(fOutput < fMin_out) {
112 deltaT = Time - fTime_ant_filt;
114 fOutput_filt = ((2 * fDelay - deltaT) * fOutput_filt_ant + deltaT * fGain * (fOutput + fOutput_ant)) /
115 (2 * fDelay + deltaT);
116 fOutput_filt_ant = fOutput_filt;
117 fOutput_ant = fOutput;
118 fTime_ant_filt = Time;
std::vector< TSensor * > FSensor
Array with the pointers of the sensor inputs.
void AcumulaResultadosMediosController(double Actual)
virtual double Output(double Time)=0
References AcumulaResultadosMediosController(), TController::FSensor, and TController::Output().
◆ ResultadosInstantController()
| void TPIDController::ResultadosInstantController |
( |
| ) |
|
|
virtual |
Calculate instanteneous results
Implements TController.
Definition at line 478 of file TPIDController.cpp.
493 }
catch(exception & N) {
494 std::cout <<
"ERROR: TPIDController::ResultadosInstantController en el eje " << fID << std::endl;
495 std::cout <<
"Tipo de error: " << N.what() << std::endl;
stResInstantCtrl FResInstantCtrl
Struct with the average results of the controllers.
References TController::FResInstantCtrl.
◆ ResultadosMediosController()
| void TPIDController::ResultadosMediosController |
( |
| ) |
|
|
virtual |
Calculate average results
Implements TController.
Definition at line 408 of file TPIDController.cpp.
437 }
catch(exception & N) {
438 std::cout <<
"ERROR: TPIDController::ResultadosMediosController en el eje: " << fID << std::endl;
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
References TController::FResMediosCtrl.
The documentation for this class was generated from the following files: