PID controller in parallel form implemented in floating-point arithmetic. Features Derivative-on-Measurement, anti-windup through conditional integration, bumpless transfer, and feed-forward.  
 More...
#include <PID.h>
 | 
|   | PID (const double *pv, double *cv, const double *sp, double Kp, double Ki, double Kd, double Kf, uint16_t dt, double cvMin, double cvMax, double a) | 
|   | Constructor.  
  | 
|   | 
| bool  | compute () | 
|   | Run a cycle of the PID loop.  
  | 
|   | 
| void  | setAuto (bool inAuto) | 
|   | Set the mode of the controller.  
  | 
|   | 
| void  | setGains (double Kp, double Ki, double Kd, double Kf, uint16_t dt) | 
|   | Set the gains and timestep.  
  | 
|   | 
 | 
| void  | init () | 
|   | Method to be called when the controller goes from manual to auto mode for proper bumpless transfer.  
  | 
|   | 
| double  | clip (double value) const | 
|   | Clip value to [cvMin, cvMax].  
  | 
|   | 
 | 
| const double &  | pv | 
|   | Process variable.  
  | 
|   | 
| double &  | cv | 
|   | Control variable.  
  | 
|   | 
| const double &  | sp | 
|   | Setpoint.  
  | 
|   | 
| double  | Kp | 
|   | 
| double  | Ki | 
|   | 
| double  | Kd | 
|   | 
| double  | Kf | 
|   | Gains.  
  | 
|   | 
| double  | a | 
|   | Smoothing factor for EWA filter for derivative.  
  | 
|   | 
| uint16_t  | dt | 
|   | Timestep.  
  | 
|   | 
| bool  | inAuto = false | 
|   | Mode.  
  | 
|   | 
| double  | lastPv | 
|   | Last value of pv.  
  | 
|   | 
| double  | lastE | 
|   | Last value of error.  
  | 
|   | 
| double  | lastDPV | 
|   | Last value of derivative term.  
  | 
|   | 
| double  | integral | 
|   | Integral of pv.  
  | 
|   | 
PID controller in parallel form implemented in floating-point arithmetic. Features Derivative-on-Measurement, anti-windup through conditional integration, bumpless transfer, and feed-forward. 
Definition at line 8 of file PID.h.
 
◆ PID()
      
        
          | PID::PID  | 
          ( | 
          const double * |           pv,  | 
        
        
           | 
           | 
          double * |           cv,  | 
        
        
           | 
           | 
          const double * |           sp,  | 
        
        
           | 
           | 
          double |           Kp,  | 
        
        
           | 
           | 
          double |           Ki,  | 
        
        
           | 
           | 
          double |           Kd,  | 
        
        
           | 
           | 
          double |           Kf,  | 
        
        
           | 
           | 
          uint16_t |           dt,  | 
        
        
           | 
           | 
          double |           cvMin,  | 
        
        
           | 
           | 
          double |           cvMax,  | 
        
        
           | 
           | 
          double |           a ) | 
        
      
 
Constructor. 
- Parameters
 - 
  
    | pv | Pointer to process variable  | 
    | cv | Pointer to control value  | 
    | sp | Pointer to setpoint  | 
    | Kp | Proportional gain  | 
    | Ki | Integral gain (in 1/s)  | 
    | Kd | Derivative gain (in s)  | 
    | Kf | Feed-forward gain  | 
    | dt | Timestep (in ms)  | 
    | cvMin | Lower limit for control value  | 
    | cvMax | Upper limit for control value  | 
    | a | Smoothing factor for EWA filter for derivative  | 
  
   
Definition at line 3 of file PID.cpp.
 
 
◆ clip()
  
  
      
        
          | double PID::clip  | 
          ( | 
          double |           value | ) | 
           const | 
         
       
   | 
  
private   | 
  
 
Clip value to [cvMin, cvMax]. 
- Parameters
 - 
  
  
 
- Returns
 - Clipped value 
 
Definition at line 44 of file PID.cpp.
 
 
◆ compute()
Run a cycle of the PID loop. 
- Returns
 - True if a PID step was run, and false if not. 
 
Definition at line 17 of file PID.cpp.
 
 
◆ init()
Method to be called when the controller goes from manual to auto mode for proper bumpless transfer. 
Definition at line 9 of file PID.cpp.
 
 
◆ setAuto()
      
        
          | void PID::setAuto  | 
          ( | 
          bool |           inAuto | ) | 
           | 
        
      
 
Set the mode of the controller. 
- Parameters
 - 
  
    | inAuto | Set to true for automatic, false for manual.  | 
  
   
Definition at line 52 of file PID.cpp.
 
 
◆ setGains()
      
        
          | void PID::setGains  | 
          ( | 
          double |           Kp,  | 
        
        
           | 
           | 
          double |           Ki,  | 
        
        
           | 
           | 
          double |           Kd,  | 
        
        
           | 
           | 
          double |           Kf,  | 
        
        
           | 
           | 
          uint16_t |           dt ) | 
        
      
 
Set the gains and timestep. 
- Parameters
 - 
  
    | Kp | Proportional gain  | 
    | Ki | Integral gain (in 1/s)  | 
    | Kd | Derivative gain (in s)  | 
    | Kf | Feed-forward gain  | 
    | dt | Timestep (in ms)  | 
  
   
Definition at line 59 of file PID.cpp.
 
 
Smoothing factor for EWA filter for derivative. 
Definition at line 15 of file PID.h.
 
 
◆ cv
Control variable. 
Definition at line 11 of file PID.h.
 
 
◆ cvMax
Lower/upper limits for cv. 
Definition at line 34 of file PID.h.
 
 
◆ cvMin
Definition at line 34 of file PID.h.
 
 
◆ dt
Timestep. 
Definition at line 16 of file PID.h.
 
 
◆ dTerm
Definition at line 33 of file PID.h.
 
 
◆ fTerm
◆ inAuto
Mode. 
Definition at line 18 of file PID.h.
 
 
◆ integral
Integral of pv. 
Definition at line 22 of file PID.h.
 
 
◆ iTerm
Definition at line 33 of file PID.h.
 
 
◆ Kd
Definition at line 14 of file PID.h.
 
 
◆ Kf
Gains. 
Definition at line 14 of file PID.h.
 
 
◆ Ki
Definition at line 14 of file PID.h.
 
 
◆ Kp
Definition at line 14 of file PID.h.
 
 
◆ lastDPV
Last value of derivative term. 
Definition at line 21 of file PID.h.
 
 
◆ lastE
Last value of error. 
Definition at line 20 of file PID.h.
 
 
◆ lastPv
Last value of pv. 
Definition at line 19 of file PID.h.
 
 
◆ pTerm
Definition at line 33 of file PID.h.
 
 
◆ pv
Process variable. 
Definition at line 10 of file PID.h.
 
 
◆ sp
Setpoint. 
Definition at line 12 of file PID.h.
 
 
The documentation for this class was generated from the following files: