y4延时80us以完成此次都时序,之后再读下一数据EA1retur
value复位子程序u
sig
edcharresetu
sig
edcharprese
ceEA0DQ0拉低DQ总线开始复位delay30保持低电平480usDQ1释放总线delay3prese
ceDQ获取应答信号delay28延时以完成整个时序
fEA1retur
prese
ce返回应答信号,有芯片应答返回0无芯片则返回1获取温度子程序voidget_temperu
sig
edcharijdoireset复位whilei01为无反馈信号i0xcc发送设备定位命令write_byteii0x44发送开始转换命令write_byteidelay180延时doireset复位whilei0i0xcc设备定位write_byteii0xbe读出缓冲区内容write_byteijread_byteiread_byteii40x7fsu
sig
edi
tj0x0fss10016jj4temperij获取的温度放在temper中I
itializePIDStructurevoidPIDI
itstructPIDppmemsetpp0sizeofstructPID
fPID计算部分u
sig
edi
tPIDCalcstructPIDppu
sig
edi
tNextPoi
tu
sig
edi
tdErrorErrorErrorppSetPoi
tNextPoi
t偏差ppSumErrorError积分dErrorppLastErrorppPrevError当前微分ppPrevErrorppLastErrorppLastErrorErrorretur
ppProportio
Error比例ppI
tegralppSumError积分项ppDerivativedError温度比较处理子程序compare_temperu
sig
edchariifset_tempertemperifset_tempertemper1high_time100low_time0elsefori0i10iget_temperri
sReadI
putroutPIDCalcspidri
PerformPIDI
teratio
ifhigh_time100high_timeu
sig
edcharrout800elsehigh_time100微分项
flow_time100high_timeelseifset_tempertemperiftemperset_temper0high_time0low_time100elsefori0i10iget_temperri
sReadI
putroutPIDCalcspidri
PerformPIDI
teratio
ifhigh_time100high_timeu
sig
edcharrout10000elsehigh_time0low_time100high_timeelser