| 3 | #define LIBRARY_VERSION 1.1.1 |
| 4 | |
| 5 | class PID |
| 6 | { |
| 7 | |
| 8 | |
| 9 | public: |
| 10 | |
| 11 | //Constants used in some of the functions below |
| 12 | #define AUTOMATIC 1 |
| 13 | #define MANUAL 0 |
| 14 | #define DIRECT 0 |
| 15 | #define REVERSE 1 |
| 16 | #define P_ON_M 0 |
| 17 | #define P_ON_E 1 |
| 18 | |
| 19 | //commonly used functions ************************************************************************** |
| 20 | PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and |
| 21 | double, double, double, int, int);// Setpoint. Initial tuning parameters are also set here. |
| 22 | // (overload for specifying proportional mode) |
| 23 | |
| 24 | PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and |
| 25 | double, double, double, int); // Setpoint. Initial tuning parameters are also set here |
| 26 | |
| 27 | void SetMode(int Mode); // * sets PID to either Manual (0) or Auto (non-0) |
| 28 | |
| 29 | bool Compute(); // * performs the PID calculation. it should be |
| 30 | // called every time loop() cycles. ON/OFF and |
| 31 | // calculation frequency can be set using SetMode |
| 32 | // SetSampleTime respectively |
| 33 | |
| 34 | void SetOutputLimits(double, double); // * clamps the output to a specific range. 0-255 by default, but |
| 35 | // it's likely the user will want to change this depending on |
| 36 | // the application |
| 37 | |
| 38 | |
| 39 | |
| 40 | //available but not commonly used functions ******************************************************** |
| 41 | void SetTunings(double, double, // * While most users will set the tunings once in the |
| 42 | double); // constructor, this function gives the user the option |
| 43 | // of changing tunings during runtime for Adaptive control |
| 44 | void SetTunings(double, double, // * overload for specifying proportional mode |
| 45 | double, int); |
| 46 | |
| 47 | void SetControllerDirection(int); // * Sets the Direction, or "Action" of the controller. DIRECT |
| 48 | // means the output will increase when error is positive. REVERSE |
| 49 | // means the opposite. it's very unlikely that this will be needed |
| 50 | // once it is set in the constructor. |
| 51 | void SetSampleTime(int); // * sets the frequency, in Milliseconds, with which |
| 52 | // the PID calculation is performed. default is 100 |
| 53 | |
| 54 | |
| 55 | |
| 56 | //Display functions **************************************************************** |
| 57 | double GetKp(); // These functions query the pid for interal values. |
| 58 | double GetKi(); // they were created mainly for the pid front-end, |
| 59 | double GetKd(); // where it's important to know what is actually |
| 60 | int GetMode(); // inside the PID. |
| 61 | int GetDirection(); // |
| 62 |
nothing calls this directly
no outgoing calls
no test coverage detected