• 回答数

    3

  • 浏览数

    114

密云汉子
首页 > 学术期刊 > 高精度数字体温计的设计毕业论文

3个回答 默认排序
  • 默认排序
  • 按时间排序

xuliduruixue

已采纳

AT89C51单片机那可以的要求的撒

344 评论

迷糊喵星人

#include #define uchar unsigned char#define uint unsigned intsbit DS=P2^2; //define interfaceuint temp; // variable of temperatureuchar flag1; // sign of the result positive or negativesbit dula=P2^6;sbit wela=P2^7;unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};unsigned char code table1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd, 0x87,0xff,0xef};void delay(uint count) //delay{ uint i; while(count) { i=200; while(i>0) i--; count--; }}void dsreset(void) //send reset and initialization command{ uint i; DS=0; i=103; while(i>0)i--; DS=1; i=4; while(i>0)i--;}bit tmpreadbit(void) //read a bit{ uint i; bit dat; DS=0;i++; //i++ for delay DS=1;i++;i++; dat=DS; i=8;while(i>0)i--; return (dat);}uchar tmpread(void) //read a byte date{ uchar i,j,dat; dat=0; for(i=1;i<=8;i++) { j=tmpreadbit(); dat=(j<<7)|(dat>>1); //读出的数据最低位在最前面,这样刚好一个字节在DAT里 } return(dat);}void tmpwritebyte(uchar dat) //write a byte to ds18b20{ uint i; uchar j; bit testb; for(j=1;j<=8;j++) { testb=dat&0x01; dat=dat>>1; if(testb) //write 1 { DS=0; i++;i++; DS=1; i=8;while(i>0)i--; } else { DS=0; //write 0 i=8;while(i>0)i--; DS=1; i++;i++; } }}void tmpchange(void) //DS18B20 begin change{ dsreset(); delay(1); tmpwritebyte(0xcc); // address all drivers on bus tmpwritebyte(0x44); // initiates a single temperature conversion}uint tmp() //get the temperature{ float tt; uchar a,b; dsreset(); delay(1); tmpwritebyte(0xcc); tmpwritebyte(0xbe); a=tmpread(); b=tmpread(); temp=b; temp<<=8; //two byte compose a int variable temp=temp|a; tt=temp*0.0625; temp=tt*10+0.5; return temp;}void display(uint temp) //显示程序{ uchar A1,A2,A2t,A3; A1=temp/100; A2t=temp%100; A2=A2t/10; A3=A2t%10; dula=0; P0=table[A1]; //显示百位 dula=1; dula=0; wela=0; P0=0x7e; wela=1; wela=0; delay(1); dula=0; P0=table1[A2]; //显示十位 dula=1; dula=0; wela=0; P0=0x7d; wela=1; wela=0; delay(1); P0=table[A3]; //显示个位 dula=1; dula=0; P0=0x7b; wela=1; wela=0; delay(1);}void main(){ uchar a; do { tmpchange(); for(a=10;a>0;a--) { display(tmp()); } } while(1);}

244 评论

舜井街的猫

这是一个仿真实例,可以参考一下试试。

101 评论

相关问答

  • 热电偶温度计的设计研究论文

    毕业设计(论文)报告 系 别: 电子与电气工程学院 专 业: 电子信息工程 班 号: 电子 0 8 5 学 生 姓 名: 傅浩 学 生 学 号: 0800122

    sky刘小子 2人参与回答 2023-12-12
  • 高精度数字体温计的设计毕业论文

    AT89C51单片机那可以的要求的撒

    密云汉子 3人参与回答 2023-12-08
  • 数字温度计毕业论文中期检查表

    1 好 2 快 3 无问题 4好好干

    huangxinru7 4人参与回答 2023-12-10
  • 温度传感器毕业设计论文

    传感器(英文名称:transducer/sensor)是直接作用于被测量、并能按一定规律将其转化为同种或别种量值输出的器件。这是我为大家整理的传感器技术论文

    华美新建材 2人参与回答 2023-12-06
  • 数字式温度计毕业论文

    毕业设计(论文)报告 系 别: 电子与电气工程学院 专 业: 电子信息工程 班 号: 电子 0 8 5 学 生 姓 名: 傅浩 学 生 学 号: 0800122

    五小样儿同学 5人参与回答 2023-12-09