這個是一個基于51單片機的非接觸式紅外溫度測量的設計,做出算是一個半成品吧,還不是特別完善,但能夠實現基本功能。我們組決定用STC89C52來做,其他小組大多用STC8A8K64S4A12來做。個人覺得這一題并不是特別難,主要是學會MLX90615的驅動程序以及各種調用,還有老師專門提供的Nokia5110顯示屏來做顯示。剛開始做的時候腦子里是有大致電路的,在網上找了挺多資料 ,邊找邊做。我自己負責程序方面的,然而我程序不是特別突出就會一些基本的調用啥的。隨便放一下我們的設計,大家感興趣可以玩玩哦。
單片機源程序如下:
- #include "nokia_5110.h"
- #include "reg52.h"
- #include "MLX90615.h"
- #include "delay.h"
- #include "stdio.h"
- void Int0Init()
- {
- //設置INT0
- IT0=1;//跳變沿出發方式(下降沿)
- EX0=1;//打開INT0的中斷允許。
- EA=1;//打開總中斷
- }
- void Int0() interrupt 0 //外部中斷0的中斷函數
- {
- unsigned char SlaveAddress; // Contains device address
- unsigned char command,j; // Contains the access command
- unsigned int tdata,i; // Contains data value
- command=RAM_Access|RAM_To; // Form RAM access command + RAM address
- LCD_clear();
- while(1)
- {
- LCD_write_english_string(0,2,"Temperature is ");
- tdata=MemRead(SlaveAddress,command); //Read memory
- tdata=tdata*2-27315;
- if(tdata>3700)
- {
- LCD_BL=0xff;
-
- }
- else{LCD_BL=0x00;}
- for(i=1000;i>1;i=i/10)
- {
- j=tdata/i;
- LCD_write_char(j+'0');
- tdata=tdata-i*j;
- if(i<1000&&i>=100)
- {LCD_write_char('.');}
- }
- LCD_write_char(tdata+'0');
- delay_ms(100);
- LCD_clear();
- LCD_write_english_string(42,3,"Celsius");
- }
- }
- void main(void)
- {
-
- MLX90615_init();
- LCD_init();
- LCD_clear();
- LCD_write_chinese_string(0,0,12,5,0,5);
- delay_ms(100);
- Int0Init(); // 設置外部中斷0
- while(1);
- }
復制代碼
全部資料51hei下載地址:
A1非接觸式紅外溫度測量STC89C52 MLX90615 Nokia5110最終.rar
(5.83 MB, 下載次數: 44)
|