|
51hei圖片20211213095124.jpg (63.21 KB, 下載次數(shù): 65)
下載附件
2021-12-13 09:51 上傳
51hei圖片20211213095132.jpg (77.13 KB, 下載次數(shù): 73)
下載附件
2021-12-13 09:51 上傳
電路原理圖如下:
51hei.png (33.03 KB, 下載次數(shù): 65)
下載附件
2021-12-14 00:52 上傳
02.jpg (1.18 MB, 下載次數(shù): 64)
下載附件
2021-12-14 00:51 上傳
04.jpg (994.67 KB, 下載次數(shù): 54)
下載附件
2021-12-14 00:51 上傳
05.jpg (760.26 KB, 下載次數(shù): 54)
下載附件
2021-12-14 00:51 上傳
01.jpg (1.5 MB, 下載次數(shù): 58)
下載附件
2021-12-14 00:51 上傳
07.jpg (1.47 MB, 下載次數(shù): 68)
下載附件
2021-12-14 00:51 上傳
單片機(jī)源程序如下:
- #include"reg52.h"
- #include"intrins.h"
- #include"common.h"
- #include"Key.h"
- #include"lcd1602.h"
- //************************************
- #define Nack_counter 10
- //mlx90614 端口定義
- sbit SCL=P3^6;//時鐘線
- sbit SDA=P3^7;//數(shù)據(jù)線
- //************數(shù)據(jù)定義****************
- bdata uchar flag;//可位尋址數(shù)據(jù)
- sbit bit_out=flag^7;
- sbit bit_in=flag^0;
- bit start_flag;
- uchar DataH,DataL,Pecreg;
- uchar flag1;
- uchar dis0[] = "Life Is Movement";
- uchar dis1[] = " T: 000.00 C ";
- uchar dis2[] = " X: S: ";
- uint Max_Tem = 3800;//最大溫度,100倍
- uint Min_Tem = 2000;//最小溫度
- uint Tem;
- uchar status = 0;
- //************函數(shù)聲明*****************************************
- void start_bit(); //MLX90614 發(fā)起始位子程序
- void stop_bit(); //MLX90614 發(fā)結(jié)束位子程序
- uchar rx_byte(void); //MLX90614 接收字節(jié)子程序
- void send_bit(void); //MLX90614 發(fā)送位子程序
- void tx_byte(uchar dat_byte); //MLX90614 接收字節(jié)子程序
- void receive_bit(void); //MLX90614 接收位子程序
- void delay(uint);
- uint memread(void); //讀溫度數(shù)據(jù)
- void display(uint Tem); //顯示子程序
- //*************主函數(shù)*******************************************
- void main()
- {
- uint i,count;
- //函數(shù)部分
- SCL=1;
- SDA=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SCL=0;
- delay(1000);
- SCL=1;
- dis1[11] =0xdf;
-
- LCD_init(); //lcd初始化
- start_flag = 0;
- delay_ms(2000);
- while(1)
- {
- count++;
- if(count<500)
- {
- Tem=memread(); //讀取溫度
- delay_ms(5000);
- key_det(); //按鍵掃描
- display(Tem); //顯示溫度
- delay_ms(5000);
- for(i=0;i<16;i++)
- {
- LCD_write_char(i,0,dis1[i]);
- LCD_write_char(i,1,dis2[i]);
- }
- delay_ms(500);
- count=0;
- }
- }
- }
- //*********輸入轉(zhuǎn)換并裝載*********
- void display(uint Tem)
- {
- uint T,a,b,min,max;
- T=Tem*2;
- if(T>=27315)
- {
- T=T-27315;
- dis1[5]=' '; // 符號位
- }
- else
- {
- T=27315-T;
- dis1[5]='-'; // 符號位
- }
- a=T/100;
- b=T-a*100;
- dis1[5]=a/100+0x30; // 百位
- dis1[6]=(a%100)/10+0x30; // 十位
- dis1[7]=a%10+0x30; // 個位
- dis1[9]=b/10+0x30; //十分位
- dis1[10]=b%10+0x30; //百分位
- if(Min_Tem<0)
- {
- dis2[3]='-';
- min=-Min_Tem/100;
- }
- else
- {
- dis2[3]=' ';
- min=Min_Tem/100;
- }
- if(Max_Tem<0)
- {
- dis2[10]='-';
- max=-Max_Tem/100;
- }
- else
- {
- dis2[10]=' ';
- max=Max_Tem/100;
- }
-
- dis2[4] = min/100+0x30; //Min
- dis2[5] = (min%100)/10+0x30;
- dis2[6] = min%10+0x30;
- dis2[11]= max/100+0x30; //Max
- dis2[12]= (max%100)/10+0x30;
- dis2[13]= max%10+0x30;
- if(status==0)
- {
- dis2[0] = ' ';
- dis2[7] = ' ';
- }
- if(status==1)
- {
- dis2[0] = '>';
- dis2[7] = ' ';
- }
-
- if(status==2)
- {
- dis2[0] = ' ';
- dis2[7] = '>';
- }
-
- }
- void start_bit(void)
- {
- SDA=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SCL=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SDA=0;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SCL=0;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- }
- //------------------------------
- void stop_bit(void)
- {
- SCL=0;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SDA=0;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SCL=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SDA=1;
- }
- //---------發(fā)送一個字節(jié)---------
- void tx_byte(uchar dat_byte)
- {
- char i,n,dat;
- n=Nack_counter;
- TX_again:
- dat=dat_byte;
- for(i=0; i<8; i++)
- {
- if(dat&0x80)
- bit_out=1;
- else
- bit_out=0;
- send_bit();
- dat=dat<<1;
- }
- receive_bit();
- if(bit_in==1)
- {
- stop_bit();
- if(n!=0)
- {
- n--;
- goto Repeat;
- }
- else
- goto exit;
- }
- else
- goto exit;
- Repeat:
- start_bit();
- goto TX_again;
- exit:
- ;
- }
- //-----------發(fā)送一個位---------
- void send_bit(void)
- {
- if(bit_out==0)
- SDA=0;
- else
- SDA=1;
- _nop_();
- SCL=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- SCL=0;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- }
- //----------接收一個字節(jié)--------
- uchar rx_byte(void)
- {
- uchar i,dat;
- dat=0;
- for(i=0; i<8; i++)
- {
- dat=dat<<1;
- receive_bit();
- if(bit_in==1)
- dat=dat+1;
- }
- send_bit();
- return dat;
- }
- //----------接收一個位----------
- void receive_bit(void)
- {
- SDA=1;
- bit_in=1;
- SCL=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- bit_in=SDA;
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
所有資料51hei附件下載:
程序與原理圖.7z
(583.09 KB, 下載次數(shù): 27)
2021-12-14 01:25 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|