Control Library by altb

Dependents:   My_Libraries IndNav_QK3_T265

Revision:
8:3a8d1218022c
Parent:
7:cb1492f4f2c6
Child:
9:074f4f94b584
--- a/DT1_Cntrl.cpp	Wed Sep 18 09:56:35 2019 +0000
+++ b/DT1_Cntrl.cpp	Thu Sep 19 08:51:03 2019 +0000
@@ -28,7 +28,7 @@
 
 void DT1_Cntrl::setCoefficients(float D, float tau_f, float Ts)
 {
-    this->p = 1.0 - Ts/tau_f;
+    this->p = 1.0f - Ts/tau_f;
     this->tau_f = tau_f;
     this->D_ = D/tau_f;             // modified D, now D is consistent with Matlab PID
     this->D__init = D/tau_f;        // modified D, now D is consistent with Matlab PID
@@ -44,6 +44,8 @@
     float Dpart = D_*(e-eold)+p*yold;
     if(Dpart > uMax) Dpart = uMax;
     else if(Dpart < uMin) Dpart = uMin;
+    eold=e;
+    yold=Dpart;
     return Dpart;
 }