Allow to set the resolution to either microseconds or microseconds

This commit is contained in:
Kristian Sloth Lauszus
2013-07-19 16:23:42 +02:00
parent d21d7e3d09
commit 9f59efabfc
2 changed files with 38 additions and 7 deletions

View File

@ -13,6 +13,8 @@ class PID
#define MANUAL 0
#define DIRECT 0
#define REVERSE 1
#define MILLIS 0
#define MICROS 1
//commonly used functions **************************************************************************
PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
@ -41,6 +43,9 @@ class PID
// once it is set in the constructor.
void SetSampleTime(int); // * sets the frequency, in Milliseconds, with which
// the PID calculation is performed. default is 100
void setResolution(int); // * Set the resolution of the getTime() function.
// MILLIS sets the resolution to milliseconds.
// MICROS sets the resolution to microseconds.
@ -53,6 +58,8 @@ class PID
private:
void Initialize();
unsigned long getTime(); // * This will call either millis() or micros()
// depending on the used resolution.
double dispKp; // * we'll hold on to the tuning parameters in user-entered
double dispKi; // format for display purposes
@ -73,6 +80,7 @@ class PID
double ITerm, lastInput;
unsigned long SampleTime;
double secondsDivider;
double outMin, outMax;
bool inAuto;
};