📄 叶风 - 利用pid算法和pwm调制实现温度自动控制的源程序.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0063)http://ilovec.123ye.com/infoAction.do?method=show&infoId=114620 -->
<HTML><HEAD><TITLE>叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GBK">
<META content="叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序" name=keywords>
<STYLE type=text/css>BODY {
FONT-SIZE: 12px
}
TD {
FONT-SIZE: 12px
}
TR {
FONT-SIZE: 12px
}
.box {
BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; MARGIN: 0px; BORDER-LEFT: #cccccc 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #cccccc 1px solid
}
.titlebig {
FONT-WEIGHT: bold; FONT-SIZE: 14px; FONT-FAMILY: verdana,宋体
}
.eng1 {
FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #999999; FONT-FAMILY: verdana
}
.width0 {
WIDTH: 200px
}
.width1 {
WIDTH: 360px
}
.width2 {
WIDTH: 190px
}
.width01 {
WIDTH: 560px
}
.width12 {
WIDTH: 550px
}
.widthall {
WIDTH: 750px
}
</STYLE>
<SCRIPT src="叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序.files/common.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 6.00.2900.2722" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<CENTER>
<TABLE class=sbody height=35 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD bgColor=#f0f0f0> </TD>
<TD style="BORDER-BOTTOM: #cac6c3 1px solid" align=middle width=220
bgColor=#f0f0f0 rowSpan=2>
<TABLE class=sbody height=28 cellSpacing=0 cellPadding=0 width=180
align=center border=0>
<TBODY>
<TR>
<TD align=middle></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD style="BORDER-RIGHT: #cac6c3 1px solid; BORDER-TOP: #cac6c3 1px solid"
height=10><IMG height=1 src="" width=1></TD></TR></TBODY></TABLE>
<TABLE height=45 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD vAlign=top><IMG
src="叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序.files/20061121103518859.jpg"> </TD>
<TD vAlign=top align=right width=260> </TD></TR></TBODY></TABLE>
<TABLE height=30 cellSpacing=0 cellPadding=0 width=750 bgColor=#bed6f4
border=0><TBODY>
<TR>
<TD align=middle width=29><IMG
src="叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序.files/union_t_pt01.gif"></TD>
<TD class=titlebig style="COLOR: #346fba; PADDING-TOP: 3px"><A
href="http://ilovec.123ye.com/">首页</A> <A
href="http://ilovec.123ye.com/column.do?columnId=30022">我的简历</A>
<A
href="http://ilovec.123ye.com/column.do?columnId=30023">C语言</A>
<A
href="http://ilovec.123ye.com/column.do?columnId=30024">单片机</A>
<A
href="http://ilovec.123ye.com/column.do?columnId=30147">英语</A>
<A
href="http://ilovec.123ye.com/column.do?columnId=30148">心情驿站</A>
<A href="http://ilovec.123ye.com/book.do?method=list">留言板</A> </TD></TR>
<TR>
<TD bgColor=#83b0e7 colSpan=4 height=1></TD></TR></TBODY></TABLE>
<TABLE height=10 cellSpacing=0 cellPadding=0 width=730 border=0>
<TBODY>
<TR>
<TD></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=2 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD style="FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #666666"
align=middle>利用PID算法和PWM调制实现温度自动控制的源程序</TD></TR>
<TR>
<TD align=middle><A href="http://ilovec.123ye.com/">叶风</A> ycitsj
(2005-08-09 08:53)</TD></TR>
<TR>
<TD style="FONT-SIZE: 14px; COLOR: #666666; LINE-HEIGHT: 140%"><BR>
<TABLE width=1 border=0>
<TBODY>
<TR>
<TD>
<SCRIPT type=text/javascript><!-- google_ad_client = "pub-6478508614958096"; google_alternate_ad_url = "http://www.123ye.com/gg.htm"; google_ad_width = 180; google_ad_height = 150; google_ad_format = "180x150_as"; google_ad_type = "text"; //2007-01-23: up google_ad_channel = "7589437780"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "333333"; google_color_url = "333333"; //--></SCRIPT>
<SCRIPT src="叶风 - 利用PID算法和PWM调制实现温度自动控制的源程序.files/show_ads.js"
type=text/javascript> </SCRIPT>
</TD></TR></TBODY></TABLE><BR>
<P>#include<reg51.h><BR>#include<intrins.h><BR>#include<math.h><BR>#include<string.h><BR>struct
PID {<BR>unsigned int SetPoint; // 设定目标 Desired Value<BR>unsigned
int Proportion; // 比例常数 Proportional Const<BR>unsigned int Integral;
// 积分常数 Integral Const<BR>unsigned int Derivative; // 微分常数
Derivative Const<BR>unsigned int LastError; // Error[-1]<BR>unsigned
int PrevError; // Error[-2]<BR>unsigned int SumError; // Sums of
Errors<BR>};<BR>struct PID spid; // PID Control
Structure<BR>unsigned int rout; // PID Response (Output)<BR>unsigned
int rin; // PID Feedback (Input)</P>
<P>sbit data1=P1^0;<BR>sbit clk=P1^1;<BR>sbit plus=P2^0;<BR>sbit
subs=P2^1;<BR>sbit stop=P2^2;<BR>sbit output=P3^4;<BR>sbit
DQ=P3^3;<BR>unsigned char flag,flag_1=0;<BR>unsigned char
high_time,low_time,count=0;//占空比调节参数<BR>unsigned char
set_temper=35; </P>
<P>unsigned char temper;
<BR>unsigned char i;<BR>unsigned char j=0;<BR>unsigned int
s;<BR>/***********************************************************<BR>延时子程序,延时时间以12M晶振为准,延时时间为30us×time<BR>***********************************************************/<BR>void
delay(unsigned char time)<BR> {<BR> unsigned char
m,n;<BR>
for(n=0;n<time;n++)<BR>
for(m=0;m<2;m++){}<BR>
}<BR>/***********************************************************<BR>写一位数据子程序<BR>***********************************************************/<BR>void
write_bit(unsigned char bitval)<BR> {<BR>
EA=0;<BR>
DQ=0; /*拉低DQ以开始一个写时序*/<BR>
if(bitval==1)<BR>
{<BR>
_nop_();<BR>
DQ=1; /*如要写1,则将总线置高*/<BR>
}<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -