ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:152.68KB ,
资源ID:7391583      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7391583.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ml 90614红外温度计程序.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

ml 90614红外温度计程序.docx

1、ml 90614红外温度计程序#include #include/#include #define uint unsigned int#define uchar unsigned char#define Nack_number 10/*端口定义*sbit P_RS=P35;sbit P_RW=P36;sbit P_E=P37;sbit SCK=P32; /时钟线sbit SDA=P33;/*数据定义*int bit_out=0,bit_in=0;uchar tempH,tempL,err;unsigned char ltable6;#define clear 0x01 /清除显示#define

2、 home 0x02 /地址归位#define dis_on 0x0f /打开显示:显示控制00001DCB,D=1整体显示开,即打开 / 开关让屏显示 C=1游标开, / B=1游标位置反白允许(此处不允许)#define in_mode 0x06 /输入方式 (进入点设置 :000001I/DS /I/D=1光标右移,AC自动加1,S=0,整体显示不移动)/*函数声明*void start(); /MLX90614发起始位子程序void stop(); /MLX90614发结束位子程序uchar ReadByte(void); /MLX90614接收字节子程序void send_bit(v

3、oid); /MLX90614发送位子程序void SendByte(uchar number); /MLX90614接收字节子程序void read_bit(void); /MLX90614接收位子程序void delay(uint N); /延时程序uint readtemp(void); /读温度数据uint wreadtemp(void); /读温度数据void display(uint Tem); /显示子程序void displayw(uint Tem); /显示子程序void screen_delay1(uint x); /延时函数void screen_initial(); /

4、液晶初始化函数void screen_instruct(uint dat); / 液晶发送控制指令void screen_bit8_serial_input(uint ix);/液晶输入字节函数void dis_str(uchar x, uchar y, uchar *str);/液晶写入函数void screen_write_abyte(uint dat); /发送数据函数/void screen_delay_ms(); /延时函数/以下是12864液晶显示函数/延时函数!/void screen_delay1(uint x) /51+17x(us) uint i,j; for(i=0;i1

5、;i+) for(j=0;jx;j+);/液晶初始化函数,通过去掉0x0c,可以实时显示光标位置!/void screen_initial() P_RS=0; /RS为低电平,进行控制指令 screen_instruct(dis_on); /发送打开显示指令 screen_delay1(70); screen_instruct(clear); /发送清屏指令 screen_delay1(3000); screen_instruct(in_mode); /发送输入方式指令 screen_delay1(7); screen_instruct(0x0c); /显示状态的游标和游标位置不显示 scre

6、en_delay1(7); screen_instruct(home); /发送地址归位指令 screen_delay1(3000);/发送控制指令函数/void screen_instruct(uint dat) uint ch; P_RS=1; ch=0xf8; screen_bit8_serial_input(ch); ch=dat&0xf0; screen_bit8_serial_input(ch); ch=dat4; screen_bit8_serial_input(ch); P_RS=0;/输入字节函数/void screen_bit8_serial_input(uint ix)

7、uint i; P_E=0; for(i=0;i8;i+) if(ix&0x80)=0) P_RW=0; else P_RW=1; ix=1; P_E=1; P_E=0; /使能端发出一个负跳变沿脉冲,详见MPU写资料模块 /写入函数/void dis_str(uchar x, uchar y, uchar *str) /16*4 data uchar loc,*p; code uchar xline5=0,1,3,2,4; p=str; x=xlinex; screen_instruct(home); loc=(16*(x-1)+y-1); if(loc&0x01) loc/=2; scre

8、en_instruct(loc|0x80); screen_write_abyte( ); else loc/=2; screen_instruct(loc|0x80); while(*p) screen_write_abyte(*p+); screen_instruct(0x9e); screen_write_abyte( );/发送数据/void screen_write_abyte(uint dat) uint ch; P_RS=1; ch=0xfa; screen_bit8_serial_input(ch); ch=dat&0xf0; screen_bit8_serial_input(

9、ch); ch=dat4; screen_bit8_serial_input(ch); P_RS=0; / void screen_delay_ms() unsigned int i,j; for(i=0;i500;i+) for(j=0;j=27315) /温度为正 T=T-27315; / a=T/100; /温度整数 b=T-a*100; /温度小数 ltable0=a/100+0; ltable1=a%100/10+0; ltable2=a%10+0; ltable3=.; ltable4=b/10+0; ltable5=b%10+0; dis_str(2,7,ltable); els

10、e /温度为负 T=27315-T; a=T/100; b=T-a*100; ltable0=-; ltable1=a/10+0; ltable2=a%10+0; ltable3=.; ltable4=b/10+0; ltable5=b%10+0; dis_str(2,7,ltable); void displayw(uint Tem) uint T,a,b; T=Tem*2; if(T=27315) /温度为正 T=T-27315; / a=T/100; /温度整数 b=T-a*100; /温度小数 ltable0=a/100+0; ltable1=a%100/10+0; ltable2=a

11、%10+0; ltable3=.; ltable4=b/10+0; ltable5=b%10+0; dis_str(3,7,ltable); else /温度为负 T=27315-T; a=T/100; b=T-a*100; ltable0=-; ltable1=a/10+0; ltable2=a%10+0; ltable3=.; ltable4=b/10+0; ltable5=b%10+0; dis_str(3,7,ltable); /*void start(void) /停止条件是 SCK=1时,SDA由1到0 SDA=1; delay(4); SCK=1; delay(4); SDA=0

12、; delay(4); SCK=0; delay(4);/-void stop(void) /停止条件是 SCK=1时,SDA由0到1 SCK=0; delay(4); SDA=0; delay(4); SCK=1; delay(4); SDA=1;/-发送一个字节-void SendByte(uchar number) uchar i,n,dat; n=Nack_number; /可以重发次数Send_again: dat=number; for(i=0;i8;i+) /8位依次发送 if(dat&0x80) /取最高位 bit_out=1; /发1 else bit_out=0; /发0

13、send_bit(); /发送一个位 dat=dat1; /左移一位 read_bit(); /接收1位 应答信号 if(bit_in=1) /无应答时重发 stop(); if(n!=0) n-; /可以重发Nack_number=10次 goto Repeat; /重发 else goto exit; /退出 else goto exit; Repeat: start(); /重新开始 goto Send_again; /重发 exit: ; /退出/-发送一个位-void send_bit(void) if(bit_out=1) SDA=1; /发1 else SDA=0; /发0 _n

14、op_(); SCK=1; /上升沿 delay(4);delay(4); SCK=0; delay(4);delay(4);/-接收一个字节-uchar ReadByte(void) uchar i,dat; dat=0; /初值为0 for(i=0;i8;i+) dat=dat1; /左移 read_bit(); /接收一位 if(bit_in=1) dat=dat+1; /为1时对应位加1 SDA=0; /发送应答信号0 send_bit(); return dat; /带回接收数据/-接收一个位-void read_bit(void) SDA=1; /数据端先置1 bit_in=1;

15、SCK=1; /上升沿 delay(4);delay(4); bit_in=SDA; /读数据 _nop_(); SCK=0; delay(4);delay(4);/-uint readtemp(void) SCK=0; start(); /开始条件 SendByte(0x00); /发送从地址00 SendByte(0x07); /发送命令 start(); /开始条件 SendByte(0x01); /读从地址00 bit_out=0; tempL=ReadByte(); /读数据低字节 bit_out=0; tempH=ReadByte(); /读数据高字节 bit_out=1; err

16、=ReadByte(); /读错误信息码 stop(); /停止条件 return(tempH*256+tempL);uint wreadtemp(void) SCK=0; start(); /开始条件 SendByte(0x00); /发送从地址00 SendByte(0x06); /发送命令 start(); /开始条件 SendByte(0x01); /读从地址00 bit_out=0; tempL=ReadByte(); /读数据低字节 bit_out=0; tempH=ReadByte(); /读数据高字节 bit_out=1; err=ReadByte(); /读错误信息码 stop(); /停止条件 return(tempH*256+tempL);/-延时-void delay(uint n) uint j; for(j=0;jn;j+) _nop_();

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1