New PID library with digital anti-windup and process control

Fork of PID_modified by Chun Feng Huang

Files at this revision

API Documentation at this revision

Comitter:
benson516
Date:
Thu Dec 15 20:13:52 2016 +0000
Parent:
4:e3c9cb64be44
Child:
6:0d1e877c7f60
Commit message:
Add "void Anti_windup()" member function

Changed in this revision

PID.cpp Show annotated file Show diff for this revision Revisions of this file
PID.h Show annotated file Show diff for this revision Revisions of this file
--- a/PID.cpp	Wed Oct 26 17:56:01 2016 +0000
+++ b/PID.cpp	Thu Dec 15 20:13:52 2016 +0000
@@ -142,6 +142,10 @@
     */
             
 }
+
+// Use separately
+// Compute_noWindUP() -- [ Saturation_output(): optional, can be replaced by customized saturation function ] -- Anti_windup(delta) -- output
+//////////////////////////////////////////////////
 void PID::Saturation_output(){
         if( output >= outputLimits_H){
             delta_output = outputLimits_H - output;
@@ -156,4 +160,16 @@
 void PID::Anti_windup(float delta){ // delta_V = Vs - V
     // Anti-windup compensation
     error_I += Ka*delta; // Anti-windup
-}
\ No newline at end of file
+}
+////////////////////////////////////////////////// end Use separately
+
+// Use alone
+// Compute_noWindUP() -- Anti_windup() -- output
+//////////////////////////////////////////////////
+void PID::Anti_windup(){ // delta_V = Vs - V
+
+    PID::Saturation_output();
+    // Anti-windup compensation
+    error_I += Ka*PID::delta_output; // Anti-windup
+}
+////////////////////////////////////////////////// end Use alone
\ No newline at end of file
--- a/PID.h	Wed Oct 26 17:56:01 2016 +0000
+++ b/PID.h	Thu Dec 15 20:13:52 2016 +0000
@@ -11,8 +11,11 @@
         
         // 
         void Compute_noWindUP(float reference_in, float feedbackvalue_in);
+        // Method 1: Separated operation for anti-windup
         void Saturation_output();
         void Anti_windup(float delta); // delta_V = Vs - V
+        // Method 2: Single anti-windup operation
+        void Anti_windup();
         //
            
         void SetOutputLimits(float setoutputLimits_H, float setoutputLimits_L);