VXI VT1422A User Manual
Page 503

Example PID Algorithm Listings 501
/* At startup in the Manual control mode, the output will be held at
*/
/* its current value.
*/
/*
*/
/* At startup, in the Automatic control mode, the output will slew
*/
/* from its initial value towards P_factor * Error at a rate determined
*/
/* by the Integral control constant (I_out is initialized to cancel P_out).
*/
/*
*/
/* For process monitoring, data may be sent to the FIFO and current
*/
/* value table (CVT). There are three levels of data logging, controlled
*/
/* by the History_mode variable. The location in the CVT is based
*/
/* 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.
*/
/*
*/
/* History_mode = 2: All to FIFO and CVT. In this mode, nine values
*/
/* are output to both the CVT and FIFO. A header tag (256 * n + 9)
*/
/* is sent to the FIFO first.
*/
/*
*/
/* Location Value
*/
/* 0 Input
*/
/* 1 Error
*/
/* 2 Output
*/
/* 3 Status
*/
/* 4 Setpoint
*/
/* 5 Proportional term
*/
/* 6 Integral term
*/
/* 7 Derivative term
*/
/* 8 Setpoint Derivative term
*/
/* */
/********************************************************************************************/
/*
*/
/* 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 = 0; /* Manual outout 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
*/
/*
*/