This is a copy of the Reference Standard PID controller ala controlguru.com
Dependents: PIDHeater Printer PIDHeater82 UltiSaverController
Fork of PID by
Revision 1:117e0c36eb22, committed 2016-01-25
- Comitter:
- unix_guru
- Date:
- Mon Jan 25 22:29:38 2016 +0000
- Parent:
- 0:d58c1b8d63d9
- Child:
- 2:55bf0f813bb4
- Commit message:
- Old Standard PID library from ControlGuru.com
Changed in this revision
PID.cpp | Show annotated file Show diff for this revision Revisions of this file |
PID.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/PID.cpp Wed Feb 26 08:46:04 2014 +0000 +++ b/PID.cpp Mon Jan 25 22:29:38 2016 +0000 @@ -1,13 +1,12 @@ /** * Includes */ -#include "stdafx.h" #include "PID.h" PID::PID(float Kc, float tauI, float tauD, float interval) { usingFeedForward = false; - //inAuto = false; + inAuto = false; //Default the limits to the full range of I/O. //Make sure to set these to more appropriate limits for your application. @@ -135,7 +134,7 @@ accError_ = 0; } -/* + void PID::setMode(int mode) { //We were in manual, and we just got set to auto. @@ -146,7 +145,7 @@ inAuto = (mode != 0); -}*/ +} void PID::setInterval(float interval) { @@ -159,7 +158,7 @@ } } -/* + void PID::setSetPoint(float sp) { setPoint_ = sp; @@ -171,7 +170,7 @@ processVariable_ = pv; } -*/ + void PID::setBias(float bias){ bias_ = bias;
--- a/PID.h Wed Feb 26 08:46:04 2014 +0000 +++ b/PID.h Mon Jan 25 22:29:38 2016 +0000 @@ -1,14 +1,17 @@ -#pragma once +//#pragma once #ifndef PID_H #define PID_H +#define MANUAL_MODE 0 +#define AUTO_MODE 1 + class PID { public: /* - * Constructeur + * Constructor * Sets default limits, calculates tuning parameters, and sets manual mode with no bias. * @param Kc - Tuning parameter * @param tauI - Tuning parameter @@ -53,6 +56,26 @@ void setInterval(float interval); /* + * Set the target value for the PID loop to maintain. + * @param sp The target value to maintain. + */ + void setSetPoint(float sp); + + /* + * Set the target value for the PID loop to maintain. + * @param pv The target value to maintain. + */ + void setProcessValue(float pv); + + /** + * Set PID to manual or auto mode. + * + * @param mode 0 -> Manual + * Non-zero -> Auto + */ + void setMode(int mode); + + /* * Set the bias. * @param bias The bias for the controller output. */ @@ -77,7 +100,8 @@ private: bool usingFeedForward; - + bool inAuto; + //Actual tuning parameters used in PID calculation. float Kc_; float tauR_;