thermferm/pid.h

changeset 362
c92651a54969
parent 316
73cd31dc6ce1
child 363
468ec0d96cce
equal deleted inserted replaced
361:308f6a436779 362:c92651a54969
1 #ifndef PID_H 1 #ifndef PID_H
2 #define PID_H 2 #define PID_H
3 3
4 #define PID_MODE_NONE 0 /* Process control off */
5 #define PID_MODE_AUTO 1 /* Process control auto */
6 #define PID_MODE_BOO 2 /* Process control Bang On/Off */
7
8 #define PID_TYPE_HEAT 0 /* PID is used for heating */
9 #define PID_TYPE_COOL 1 /* PID is used for cooling */
10
11 #define PID_TIMES 60 /* 60 calculations per minute */
12
13
4 typedef struct _pid_var { 14 typedef struct _pid_var {
5 double iState; /* Integrator state */ 15 double iMax; /* Maximum allowable integrator state */
6 double dState; /* Last measured value input */ 16 double iGain; /* Integral gain */
7 double iMax; /* Maximum allowable integrator state */ 17 double pGain; /* Proportional gain */
8 double iMin; /* Minimum allowable integrator state */ 18 double dGain; /* Derivative gain */
9 double iGain; /* Integral gain */ 19 double idleRange; /* Idle range */
10 double pGain; /* Proportional gain */ 20
11 double dGain; /* Derivative gain */ 21 double Input; /* Input value */
22 double InputD; /* Process input plus derivative */
23 double InputLast; /* Process input from last pass */
24 double Err; /* Error, diff between input and set point */
25 double ErrLast; /* Error from last pass */
26 double ErrLastLast; /* Error from next last pass */
27 double SetP; /* Set point */
28 double OutP; /* Output of PID algorithm */
29 int Mode; /* Value is 'PID_AUTO' if loop is automatic */
30 int Type; /* Value is 'HEAT' or 'COOL' */
12 } pid_var; 31 } pid_var;
13 32
14 33
15 double UpdatePID( pid_var *, double, double); 34 void InitPID( pid_var *, int);
35 void UpdatePID( pid_var *);
16 36
17 #endif 37 #endif

mercurial