New PID library with digital anti-windup and process control
Fork of PID_modified by
Diff: PID.cpp
- Revision:
- 5:016c99bb877f
- Parent:
- 4:e3c9cb64be44
- Child:
- 6:0d1e877c7f60
--- 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