- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
温度测试C语言程序(Temperature test, C language program)
温度测试C语言程序(Temperature test, C language program)
#包括 AT89X52。”
# unsigned int定义单元
#定义unsigned char函数
公司魏= P2 ^ 7;
公司^ 6段= P2;
公司pin_1820 = P1 ^ 7;
函数温度[ ] = { 0x3F,0x06,0x5b,0x4f,0x66,0x6d,7d,0x07,0x7f,0x6f,0x39,0x40 };//共阴极显示字符0 ~ 9,C,—
函数temp1 [ ] = { 0xBF 0x86,0xbd,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef };//共阴带小数点~ 9 0。
点F;/ /负温度标志
位标志;// DS18B20初始化成功标志
tempint函数,tempdf;/ /温度整数部分和小数部分
无效wei_lock(UCHAR魏)/数码管位控制
{
魏= 1;
P0 =卫;
魏= 0;
}
无效duan_lock(uchar duan)/数码管段控制
{
单元我;
段= 1;
P0 =温度[端];
段= 0;
对于(i = 500;i 0;i…);
}
无效duan2_lock(uchar duan)/数码管段控制
{
单元我;
段= 1;
P0 = temp1 [端];
段= 0;
对于(i = 500;i 0;i…);
}
无效set_ds1820() /初始化DS18B20
{
(1)
{
延迟的函数;
标志=0;
pin_1820 = 1;//总线高电平
延迟= 1;
而(延迟);/ /稍微延时
pin_1820 = 0;//总线拉低
延迟= 250;
而(延迟);/ /延时500us
pin_1820 = 1;//拉高总线
延迟= 30;
而(延迟);/ /延时60us
而(!pin_1820)/当DS1820拉低总线
{
延迟= 120;
而(延迟);/ /延时240us
如果(pin_1820)
{
标志= 1;// DS1820初始化成功标志
打破;
}
}
如果(旗)/初始化成功后再延时480us,时序要求
{
延迟= 240;
虽然(延迟);
打破;
}
}
}
无效write_ds1820(函数命令)/写8位
{
函数的延迟,我;
为(i = 8;我0;我循环次写入)/ / 8
{
pin_1820 = 0;//拉低总线
延迟= 6;
而(延迟);/ /延时12us
pin_1820 =命令和语句;//将数据放在总线上,进行采样
延迟= 25;
而(延迟);/ /延时50US,采样完毕
命令指令 = 1;//数据右移一位,准备下次数据
pin_1820 = 1;//释放总线
}
}
无效read_ds1820() /读1820的数据
{
函数的延迟,我,J,K,温度,丹贝,temp1;
J = 2;//读2位字节的数据
做
{
为(i = 8;我0;我一个字节分位读取)/ / 8
{
温度 = 1;//读取1位右移1位
PIN_1820=0; / / data line set low level
Delay=1;
While (--delay); / / 2us delay
PIN_1820=1; / / pull up the bus
Delay=4;
While (--delay); / / 8us delay
If (PIN_1820 temp|=0x80); / / read 1 bit data
Delay=25;
While (--delay); / / read 1 bit data after a delay of 50uS
}
If (j==2 temp1=temp); / / read the first word temp1
Else temph=temp; / / read the second word temph
}while (--j);
F=0; / / the initial temperature is positive sign
If ((temph0xf8) =0x00!) / / if the temperature is negative, to complement
{
F=1; / / negative temperature F 1
Temph=~temph;
Temp1=~temp1;
K=temp1+1;
Temp1=k;
If (k255)
{
Temph++;
}
}
Tempdf=temp10x0f; / / read data is converted into a temperature value
Temp1=4; / / tempint decimal intege
您可能关注的文档
- 检察院提起民事诉讼的若干程序问题初探(A probe into several procedural issues of civil proceedings brought by procuratorate).doc
- 检察权的配置与司法体制改革(The allocation of procuratorial power and the reform of judicial system).doc
- 检测与传感技术大作业(Inspection and sensing technology major operations).doc
- 检查和处理电动机故障的方法(Method for checking and handling Motor Faults).doc
- 检测你是否变老10指标(Check whether you are getting old 10 indicators).doc
- 检测修复磁盘(Detection recovery disk).doc
- 检测链表(Check list).doc
- 桩基详解(Detailed description of pile foundation).doc
- 检视、设计公管理司薪资结构(Review and design the salary structure of the management division).doc
- 检验人员基本功(Basic skills of inspection personnel).doc
- 温度计和温标的发明(The invention of the thermometer and temperature scale).doc
- 温度计代码(Thermometer code).doc
- 温度转换(Temperature conversion).doc
- 温控(temperature control).doc
- 温柔地裁员裁的是人心(Gently downsizing cutting people's hearts).doc
- 温氏奔豚汤(Wen bentun soup).doc
- 温江区柳城幼儿园岗位设置方案(Wenjiang Liucheng kindergarten post program).doc
- 温泉注意事项(Hot spring precautions).doc
- 温里药(Warm herbs).doc
- 温湿度传感器DHT11多传感器课设程序液晶LCD1602(Temperature and humidity sensor, DHT11, multi sensor program, LCD, LCD1602).doc
原创力文档


文档评论(0)