From 0fdac659c0ce16c32c8536b2e93878bb92749e2a Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 3 Dec 2016 20:10:52 -0600 Subject: [PATCH 1/4] Fixing bugs added '#include ' and 'using namespace std;' so printing to the screen would work. made 'update' class method public so it could be defined later. put semicolon after iTemp. --- PID loop | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PID loop b/PID loop index 38d8159..09742b0 100644 --- a/PID loop +++ b/PID loop @@ -1,3 +1,6 @@ +#include +using namespace std; + class PID{ //scale factors double pScale = 0.0; @@ -22,6 +25,7 @@ class PID{ PID(); // Constructor, does nothing now // Class methods + public: double update(double currVal, double idealVal); void print() {cout << pid << endl;} }; @@ -40,7 +44,7 @@ double PID::update(double currVal, double idealVal){ if (iTemp > iMax) iTemp = iMax; if (iTemp < iMin) - iTemp = iMin + iTemp = iMin; iTerm = iScale * iTemp; pid = pTerm + iTerm + dTerm; From 727601f6588abcdd6a4b661a1e8737d3f2ab7879 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 3 Dec 2016 20:13:10 -0600 Subject: [PATCH 2/4] Update PID loop --- PID loop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PID loop b/PID loop index 09742b0..49d0daa 100644 --- a/PID loop +++ b/PID loop @@ -1,4 +1,4 @@ -#include +#include using namespace std; class PID{ From 29ea5b1c601a10d344a4f6dd8d3d491cde8d14a7 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 3 Dec 2016 20:15:49 -0600 Subject: [PATCH 3/4] commented out PID constructor --- PID loop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PID loop b/PID loop index 49d0daa..9ba365b 100644 --- a/PID loop +++ b/PID loop @@ -22,7 +22,7 @@ class PID{ double pid = 0; //these terms and above need to be inisalized outside the loop // Constructor - PID(); // Constructor, does nothing now + //PID(); // Constructor, does nothing now // Class methods public: From b66c72b6f6e7c9975202a784308fb344ff8ec9cb Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 3 Dec 2016 20:20:13 -0600 Subject: [PATCH 4/4] Added arguments Added arguments for update method so the code will actually compile and run. These two arguments need to be set to the error value (arg1) and the ideal value (arg2) sometime in the future. --- PID loop | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PID loop b/PID loop index 9ba365b..e29fa82 100644 --- a/PID loop +++ b/PID loop @@ -55,6 +55,10 @@ double PID::update(double currVal, double idealVal){ int main(){ PID myPid; + //need to insert error value and desired valur into these arguments + double arg1 = 0.5; + double arg2 = 0.0; + myPid.update(arg1, arg2); myPid.print();