496 Example PID Algorithm Listings Appendix G
/* on 'n', where n is the algorithm number (as returned by ALG_NUM, for*/
/* example). The first value is placed in the (10 * n)th 32-bit word of */
/* the CVT. The other values are written in subsequent locations. */
/* */
/* History_mode = 0: Summary to CVT only. In this mode, four values */
/* are output to the CVT. */
/* */
/* Location Value */
/* 0 Input */
/* 1 Error */
/* 2 Output */
/* 3 Status */
/* */
/* History_mode = 1: Summary to CVT and FIFO. In this mode, the four*/
/* summary values are written to both the CVT and FIFO. A header */
/* tag (256 * n + 4) is sent to the FIFO first, where n is the Algorithm */
/* number (1 - 32).<N> */
/* */
/********************************************************************************************/
/* */
/* User determined control parameters */
static float Setpoint = 0; /* The setpoint */
static float P_factor = 1; /* Proportional control constant */
static float I_factor = 0; /* Integral control constant */
static float D_factor = 0; /* Derivative control constant */
static float Error_max = 9.9e+37; /* Error alarm limits */
static float Error_min = -9.9e+37;
static float PV_max = 9.9e+37; /* Process Variable alarm limits */
static float PV_min = -9.9e+37;
static float Out_max = 9.9e+37; /* Output clip limits */
static float Out_min = -9.9e+37;
static float D_max = 9.9e+37; /* Derivative clip limits */
static float D_min = 9.9e+37;
static float I_max = 9.9e+37; /* Integral clip limits */
static float I_min = -9.9e+37;
static float Man_state = 0; /* Activates manual control */
static float Man_out = 0; /* Target Manual output value */
static float Man_inc = 9.9e+37;/* Manual output change increment */
static float SD_factor = 0; /* Setpoint Derivative constant */
static float SD_max = 9.9e+37; /* Setpoint Derivative clip limits */
static float SD_min = 9.9e+37;
static float History_mode = 0; /* Activates fifo data logging */
/* */
/* Other Variables */
static float I_out; /* Integral term */
static float D_out; /* Derivative term */
static float Error; /* Error term */
static float PV_old; /* Last process variable */
static float Setpoint_old; /* Last setpoint - for derivative */
static float SD_out; /* Setpoint derivative term */
static float Status = 0; /* Algorithm status word */
/* */
/* B0 - PID_out at clip limit */
/* B1 - I_out at clip limit */
/* B2 - D_out at clip limit */
/* B3 - SD_out at clip limit */
/* B4 - in Manual control mode */
/* B5 - Error out of limits */
/* B6 - PV out of limits */
/* others - unused */
/* */
/* */