thermferm/pid.h

changeset 362
c92651a54969
parent 316
73cd31dc6ce1
child 363
468ec0d96cce
--- a/thermferm/pid.h	Thu May 14 22:03:35 2015 +0200
+++ b/thermferm/pid.h	Sat May 16 17:39:30 2015 +0200
@@ -1,17 +1,37 @@
 #ifndef	PID_H
 #define	PID_H
 
+#define	PID_MODE_NONE		0	/* Process control off				*/
+#define	PID_MODE_AUTO		1	/* Process control auto				*/
+#define	PID_MODE_BOO		2	/* Process control Bang On/Off			*/
+
+#define	PID_TYPE_HEAT		0	/* PID is used for heating			*/
+#define	PID_TYPE_COOL		1	/* PID is used for cooling			*/
+
+#define	PID_TIMES		60	/* 60 calculations per minute			*/
+
+
 typedef struct _pid_var {
-	double		iState;		/* Integrator state			*/
-	double		dState;		/* Last measured value input		*/
-	double		iMax;		/* Maximum allowable integrator state	*/
-	double		iMin;		/* Minimum allowable integrator state	*/
-	double		iGain;		/* Integral gain			*/
-	double		pGain;		/* Proportional gain			*/
-	double		dGain;		/* Derivative gain			*/
+	double		iMax;		/* Maximum allowable integrator state		*/
+	double		iGain;		/* Integral gain				*/
+	double		pGain;		/* Proportional gain				*/
+	double		dGain;		/* Derivative gain				*/
+	double		idleRange;	/* Idle range					*/
+
+	double		Input;		/* Input value					*/
+	double		InputD;		/* Process input plus derivative		*/
+	double		InputLast;	/* Process input from last pass			*/
+	double		Err;		/* Error, diff between input and set point	*/
+	double		ErrLast;	/* Error from last pass				*/
+	double		ErrLastLast;	/* Error from next last pass			*/
+	double		SetP;		/* Set point					*/
+	double		OutP;		/* Output of PID algorithm			*/
+	int		Mode;		/* Value is 'PID_AUTO' if loop is automatic	*/
+	int		Type;		/* Value is 'HEAT' or 'COOL'			*/
 } pid_var;
 
 
-double UpdatePID( pid_var *, double, double);
+void InitPID( pid_var *, int);
+void UpdatePID( pid_var *);
 
 #endif

mercurial