全球旧事资料 分类
我的题目是:基于PID算法的温度控制系统89C51单片机,通过键盘输入预设值,与DS18B20测得的实际值做比较,然后驱动制冷或加热电路。用keilC语言来实现PID的控制。u
sig
edi
tPIDCalcstructPIDppu
sig
edi
tNextPoi
tu
sig
edi
tdErrorErrorErrorppSetPoi
tNextPoi
t偏差ppSumErrorError积分dErrorppLastErrorppPrevError当前微分ppPrevErrorppLastErrorppLastErrorErrorretur
ppProportio
Error比例ppI
tegralppSumError积分项ppDerivativedError最佳答案PID算法温控C语言200808171858i
cludereg51hi
cludei
tri
shi
cludemathhi
cludestri
ghstructPIDu
sig
edi
tSetPoi
t设定目标DesiredValueu
sig
edi
tProportio
比例常数Proportio
alCo
stu
sig
edi
tI
tegral积分常数I
tegralCo
stu
sig
edi
tDerivative微分常数DerivativeCo
stu
sig
edi
tLastErrorError1u
sig
edi
tPrevErrorError2u
sig
edi
tSumErrorSumsofErrorsstructPIDspidPIDCo
trolStructureu
sig
edi
troutPIDRespo
seOutputu
sig
edi
tri
PIDFeedbackI
putsbitdata1P10sbitclkP11sbitplusP20sbitsubsP21sbitstopP22sbitoutputP34微分项
fsbitDQP33u
sig
edcharflagflag_10u
sig
edcharhigh_timelow_timecou
t0占空比调节参数u
sig
edcharset_temper35u
sig
edchartemperu
sig
edchariu
sig
edcharj0u
sig
edi
ts延时子程序延时时间以12M晶振为准延时时间为30us×timevoiddelayu
sig
edchartimeu
sig
edcharm
for
0
time
form0m2m写一位数据子程序voidwrite_bitu
sig
edcharbitvalEA0DQ0拉低DQ以开始一个写时序ifbitval1_
op_DQ1如要写1,则将总线置高delay5延时90us供DA18B20采样DQ1释放DQ总线_
op__
op_EA1写一字节数据子程序voidwrite_byteu
sig
edcharvalu
sig
edchariu
sig
edchartemp
fEA0
关中断
TR00fori0i8i写一字节数据,一次写一位tempvali移位操作,将本次要写的位移到最低位temptemp1write_bittemp向总线写该位delay7延时120us后TR01EA1开中断读一位数据子程序r
好听全球资料 返回顶部