Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Fixed sign of derivative terms (issue #29)
  • Loading branch information
Dlloydev committed Sep 25, 2021
1 parent 91b639f commit fb6297e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QuickPID",
"version": "2.4.7",
"version": "2.4.8",
"description": "A fast PID controller with AutoTune dynamic object, 10 tuning rules, Integral anti-windup, TIMER Mode and mixing of Proportional and Derivative on Error to Measurement. Also includes analogWrite compatibility for ESP32 and ESP32-S2.",
"keywords": "PID, controller, signal",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=QuickPID
version=2.4.7
version=2.4.8
author=David Lloyd
maintainer=David Lloyd <dlloydev@testcor.ca>
sentence=A fast PID controller with AutoTune dynamic object, 10 tuning rules, Integral anti-windup, TIMER Mode and mixing of Proportional and Derivative on Error to Measurement.
Expand Down
6 changes: 3 additions & 3 deletions src/QuickPID.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************************
QuickPID Library for Arduino - Version 2.4.7
QuickPID Library for Arduino - Version 2.4.8
by dlloydev https://github.com/Dlloydev/QuickPID
Based on the Arduino PID Library and work on AutoTunePID class
by gnalbandian (Gonzalo). Licensed under the MIT License.
Expand Down Expand Up @@ -63,14 +63,14 @@ bool QuickPID::Compute() {
peTerm = kpe * error;
iTerm = ki * error;
dmTerm = kdm * dInput;
deTerm = -kde * error;
deTerm = kde * error;

outputSum += iTerm; // include integral amount
if (outputSum > outMax) outputSum -= outputSum - outMax; // early integral anti-windup at outMax
else if (outputSum < outMin) outputSum += outMin - outputSum; // early integral anti-windup at outMin
outputSum = constrain(outputSum, outMin, outMax); // integral anti-windup clamp
outputSum = constrain(outputSum - pmTerm, outMin, outMax); // include pmTerm and clamp
*myOutput = constrain(outputSum + peTerm + dmTerm - deTerm, outMin, outMax); // totalize, clamp and drive the output
*myOutput = constrain(outputSum + peTerm - dmTerm + deTerm, outMin, outMax); // totalize, clamp and drive the output

lastInput = input;
lastTime = now;
Expand Down

0 comments on commit fb6297e

Please sign in to comment.