brewco/pid.h

Sun, 06 Dec 2015 14:29:37 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 06 Dec 2015 14:29:37 +0100
changeset 448
7fe45f6e4f48
parent 446
78e9d5234d15
permissions
-rw-r--r--

Added PID editor.

434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 #ifndef PID_H
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 #define PID_H
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
5 #define P_MANUAL 0
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
6 #define P_AUTOMATIC 1
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
7 #define P_DIRECT 0
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
8 #define P_REVERSE 1
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 typedef struct _pid_var {
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
11 double Kp; /* (P)roportional Tuning Parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
12 double Ki; /* (I)ntegral Tuning Parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
13 double Kd; /* (D)erivative Tuning Parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
14 double dispKp;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
15 double dispKi;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
16 double dispKd;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
17 int Direction; /* Controller direction */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
18 double *myInput; /* Input parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
19 double *myOutput; /* Output parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
20 double *mySetpoint; /* Setpoint parameter */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
21 long lastTime; /* Last compute time */
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
22 double ITerm;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
23 double lastInput;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
24 long SampleTime;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
25 double outMin;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
26 double outMax;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
27 int inAuto;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 } pid_var;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
31 void PID_init(pid_var *, double *, double *, double *, double, double, double, int);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
32 void PID_setMode(pid_var *, int);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
33 void PID_setOutputLimits(pid_var *, double, double);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
34 void PID_setTunings(pid_var *, double, double, double);
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
35 void PID_setDirection(pid_var *, int);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
36 void PID_setSampleTime(pid_var *, int);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
37 double PID_getKp(pid_var *);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
38 double PID_getKi(pid_var *);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
39 double PID_getKd(pid_var *);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
40 int PID_getMode(pid_var *);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
41 int PID_getDirection(pid_var *);
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
42 int PID_getSampleTime(pid_var *);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
43 int PID_compute(pid_var *);
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
44
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 #endif

mercurial