第一范文网 - 专业文章范例文档资料分享平台

基于单片机的无线多路数据(温度)采集系统的设计与实现(毕业论文)

来源:用户分享 时间:2025/7/20 16:18:15 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

附录2: 发射部分主程序

#include

#include”ds18b20.h”

#define uchar unsigned char

/***********pt2262发射函数***********/

void send_dat(uchar x)

{

uchar x1,x2;

x1=x&0x0f;

P2=x1;//将数据的低4位先发送出去 x2=x>>4;

P2=x2;//再将数据的高4位发送出去 }

/************主函数******************/ void main() {

while(1) {

read_ds18b20();//读取温度 send_dat(temp1);//发射温度1

send_dat(temp2);//发射温度2 send_dat(temp3);//发射温度3

} }

Ds18b20.h头文件: #ifndef _ds18b20 #define _ds18b20

uchar temperature,y1,y2,x2,y3; #define DQ P1_0 //温度接收口 uchar tpl; uchar tph;

/************************************************************/ void delay_b(uint t) {

uint i;

while(t--) {

for(i=0;i<125;i++); }

}

/************************************************************/ void txreset(void) { }

/************************************************************/ void rxwait(void)

{ uint i; uint i; DQ=0; i=100;

while(i>0) i--; DQ=1; i=4;

while(i>0) i--;

while(DQ);

/************************************************************/ bit rdbit(void)

{ uint i; bit b; DQ=0; i++; DQ=1; i++;i++; while(!DQ); i=4;

while(i>0) i--; }

b=DQ; i=8; while(i>0) i--; return (b); }

/************************************************************ *Function:读18B20的一个字节

*************************************************************/ uchar rdbyte(void)

{

uchar i,j,b; for(i=1;i<=8;i++)

{

}

return (b); }

j=rdbit(); b=(j<<7) | (b>>1);

/************************************************************ *Function:向18B20写入一个字节

*************************************************************/ void wrbyte(uchar b) {

uint i;

uchar j, btm;

for(j=1; j<=8;j++)

{

btm=b&0x01; b=b>>1;

if(btm==1)

{

DQ=0; i++;i++; DQ=1; i=8; while(i>0) i--;

}

else

{

DQ=0; i=8; while(i>0) i--; DQ=1; i++; i++;

} }

}

/************************************************************ *Function:温度转换

*************************************************************/ void convert(void) { }

/************************************************************/

txreset(); rxwait(); delay_b(1); wrbyte(0xcc); wrbyte(0x44);

//延时

基于单片机的无线多路数据(温度)采集系统的设计与实现(毕业论文).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c9rm7o7ykg20a6ri16ozy38gut0xt46013sf_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top