Skip to content
This repository was archived by the owner on Sep 20, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions PID loop
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <iostream>
using namespace std;

class PID{
//scale factors
double pScale = 0.0;
Expand All @@ -19,9 +22,10 @@ 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:
double update(double currVal, double idealVal);
void print() {cout << pid << endl;}
};
Expand All @@ -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;
Expand All @@ -51,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();

Expand Down