Control Library by altb

Dependents:   My_Libraries IndNav_QK3_T265

Revision:
5:d8c53cece01b
Parent:
3:27595dd9e433
Child:
10:447f6a864598
--- a/PID_Cntrl.cpp	Fri Jul 05 06:56:49 2019 +0000
+++ b/PID_Cntrl.cpp	Mon Aug 26 07:07:02 2019 +0000
@@ -32,9 +32,12 @@
 {
     this->p = 1.0 - Ts/tau_f;
     this->P = P;
+    this->P_init = P;
     this->I = I;
+    this->I_init = I;
     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
     this->Ts = Ts;
     if(P!=0)
         this->Ka=1/P;
@@ -54,6 +57,12 @@
 {
     this->D_ = D/this->tau_f;
 }
+void PID_Cntrl::scale_PID_param(float sc)
+{
+    this->P = this->P_init * sc;
+    this->I = this->I_init * sc;
+    this->D_ = this->D__init * sc;
+}
 
 float PID_Cntrl::doStep(float e)
 {
@@ -79,4 +88,9 @@
 float PID_Cntrl::get_ulimit(void)
 {
     return this->uMax;
+}
+
+float PID_Cntrl::get_P_gain(void)
+{
+    return this->P;
 }
\ No newline at end of file