测控仪器设计实验报告--温度测量实验.docx
实验报告(理工类)开课学院及实验室:机械工程学院实验时间:年月曰学生姓名学号成绩学生所在学院年级/专业/班12级/自动化/西华理1课程名称测控仪器设计课程代码实验项目名称温度测量实验项目代码指导教师项目学分一、实验目的二、实验原理三、实验设备、仪器及材料四、实验步骤(按照实际操作过程)五、实验过程记录(数据、图表、计算等)程序:ftinclude<reg52.h>ftinclude<stdio.h>#defineuintunsignedint#defineucharunsignedcharsbitds=P34;sbitlcdrs=P20;sbitICdCn=P22;inttemp;floatf_temp;ucharcodetable=z,0123456789z,;ucharcodetablel=zzTempreature:,;ucharcodetablc2="0123456789.”;voiddelay(uintms).uintx,y;for(x=ms;x>0;x一)(for(y=114;y>0;y一);voidwrite_com(ucharcom)Icdrs=O;P0=com;delay(5);Icden=I;delay(5);Icden=O;voidwrite_data(uchardate)(Icdrs=I;P0=date;delay(5);Icden=I;delay(5);Icden=O;voidinit()(Icden=O;write_com(0x38);write_com(OxOc);write_com(0x06);write_com(0x01);voiddisplay(uchardat)(inti=0;write_com(0x80);for(i=0;i<12;i+).write_data(tableti);write-data(tabledat100);write_data(tab1edat%l00/10);write-data(,);write_data(tabledat%10);voiddsreset(void)(uinti;ds=0;i=103;while(i>0)i-;ds=l;i=4;while(i>0)i一;.bittempreadbit(void)(uinti;bitdat;ds=O;i+;ds=l;i+;i+;dat=ds;i=8jwhile(i>0)i一;return(dat);)uchartempread(void)(uinti,j,dat;dat=0;for(i=l;i<=8;i+÷),j=tempreadbit();dat=(j<<7)I(dat>>l);)return(dat);voidtempwritebyte(uchardat)uinti;ucharj;bittestb;for(j=l;j<=8;j+÷)(testb=dat0x01;dat=dat>>l;if(testb)(ds=0;i+;i+;ds=l;i=8;while(i>0)i一;else(ds=0;i=8;while(i>0)i一;ds=l;i+;i+;)voidtempchange(void)(dsreset();delay(1);tempwritebyte(Oxcc);tempwritebyte(0x44);)uintget_temp()(uchara,b;dsreset();delay(1);tempwritebyte(Oxcc);tempwritebyte(Oxbe);a=tempread();b=tempread();temp=b;temp<<=8;temp=temp!a;f_temp=temp*O.0625;temp=f_temp*10+0.5;f_temp=f_temp+0.05;returntemp;voidmain()(init();while(l)(tempchange();display(get_temp();仿真结果:六、实验结果分析及问题讨论