Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DaclePID.cpp
00001 #include "DaclePID.h" 00002 00003 00004 DaclePID::DaclePID(float Kc, float Ti, float Td, float interval) { 00005 00006 setCoeff(Kc, Ti, Td); 00007 dT_ = interval; 00008 00009 accError_ = 0.0; 00010 pidSortie_ = 0.0; 00011 erreurPres_ = 0.0; 00012 minInput_=0; maxInput_=3.3; 00013 minOutput_=0; maxOutput_=3.3; 00014 consigne_=0; 00015 biais_=0; 00016 00017 } 00018 00019 void DaclePID::setCoeff(float Kc, float Ti, float Td){ 00020 00021 Kc_ = Kc; 00022 Ti_ = Ti; 00023 Td_= Td; 00024 00025 } 00026 00027 void DaclePID::setInputLimits(float minInput, float maxInput){ 00028 minInput_=minInput; maxInput_=maxInput; 00029 } 00030 00031 void DaclePID::setOutputLimits(float minOutput, float maxOutput){ 00032 minOutput_=minOutput; maxOutput_=maxOutput; 00033 } 00034 00035 float DaclePID::dacalcul(float erreur){ 00036 00037 float _erreur = to01(erreur)-to01(consigne_); 00038 00039 accError_ += _erreur; 00040 float dErreur = (_erreur - erreurPres_) /dT_; 00041 00042 pidSortie_ = Kc_ * (_erreur + (Ti_ * accError_ * dT_) + (Td_ * dErreur)); 00043 00044 erreurPres_ = _erreur; 00045 00046 return from01(pidSortie_) - from01(biais_); 00047 00048 } 00049 00050 float DaclePID::to01(float x){ 00051 return (x-minInput_)/(maxInput_-minInput_); 00052 } 00053 00054 float DaclePID::from01(float x){ 00055 return (maxOutput_-minOutput_)*x + minOutput_; 00056 }
Generated on Wed Jul 13 2022 00:49:05 by
1.7.2