e(k) <ε使用变速积分PID算法。
图9 温度控制曲线图
四 源程序
本设计方案软件实现完全使用汇编程序语言。具体源程序略。
五 结果分析论述
本文针对电热锅炉温度控制系统模型,提出了一种基于单片机AT89S51的设计方案。设计中运用PID算法更新T1的定时常数,PWM输出控制可控硅的通断,从而实现对温度的连续控制。设计结果由图7和图本设计的控制器工作稳定,控制精度高,改进的PID算法超调量大大降低;软件采用模块化结构,9可以看出:
提高了通用性。本设计的目的不仅仅是温度控制本身,主要提供了单片机外围电路及软件包括控制算法设计的思想,应该说,这种思想比控制系统本身更为重要
[求助]
如果用PID算法控制温度要怎么做?
小弟的毕业设计是做个温度控制系统,可PID控制那块儿我是一点不会啊。眼看时间就要到了, 那位大哥,各路高手能不能给段C程序啊。是以18B20为传
感器
pangya622
TOP
2# 大 中 小 发表于 2009-5-23 19:13 只看该作者
参考下我收藏的
#i nclude
struct _pid {
int pv; /*integer that contains the process value*/
单片机教
授
初窥门径
? 个人 int sp; /*integer that contains the set point*/
float integral; float pgain;
空间
? 发短消息
? 加为 float igain; float dgain; int deadband; int last_error;
};
struct _pid warm,*pid;
int process_point, set_point,dead_band;
float p_gain, i_gain, d_gain, integral_val,new_integ;;
/*------------------------------------------------------------------------ pid_init
DESCRIPTION This function initializes the pointers in the _pid
structure
to the process variable and the setpoint. *pv and *sp are
integer pointers.
------------------------------------------------------------------------*/
void pid_init(struct _pid *warm, int process_point, int
set_point) {
struct _pid *pid;
pid = warm;
pid->pv = process_point; pid->sp = set_point;
}
好友
? 当前
离线
/*------------------------------------------------------------------------ pid_tune
DESCRIPTION Sets the proportional gain (p_gain), integral gain
(i_gain),
derivitive gain (d_gain), and the dead band (dead_band) of
a pid control structure _pid.
------------------------------------------------------------------------*/
void pid_tune(struct _pid *pid, float p_gain, float i_gain, float
d_gain, int dead_band)
{
pid->pgain = p_gain; pid->igain = i_gain; pid->dgain = d_gain; pid->deadband = dead_band; pid->integral= integral_val;
pid->last_error=0;
}
/*------------------------------------------------------------------------ pid_setinteg
DESCRIPTION Set a new value for the integral term of the pid
equation.
This is useful for setting the initial output of the
pid controller at start up.
------------------------------------------------------------------------*/
void pid_setinteg(struct _pid *pid,float new_integ)
{
pid->integral = new_integ; pid->last_error = 0;
}
/*------------------------------------------------------------------------ pid_bumpless
DESCRIPTION Bumpless transfer algorithim. When suddenly changing
setpoints, or when restarting the PID equation after an extended pause, the derivative of the equation can cause a bump in the controller output. This function will help smooth out that bump. The process value in *pv should be the updated just before this function is used.
------------------------------------------------------------------------*/
void pid_bumpless(struct _pid *pid)
{
pid->last_error = (pid->sp)-(pid->pv);
}
/*------------------------------------------------------------------------ pid_calc
DESCRIPTION Performs PID calculations for the _pid structure *a. This function uses the positional form of the pid equation, and incorporates an integral windup prevention algorithim. Rectangular integration is used, so this function must be repeated on a consistent
time basis for accurate control.