紅外測溫系統(tǒng)設(shè)計(jì)
基于ATMEGA88的紅外測溫儀作品采用ATMEL公司的ATMGEA88 作為MCU,內(nèi)部有8K FLASH,1kram。工作在內(nèi)部8M RC振蕩下,耗電僅為2MA左右。采用RISC指令集的AVR核心,運(yùn)算速度大大超過傳統(tǒng)的51單片機(jī)。內(nèi)部帶有3個(gè)定時(shí)器,8路10位AD(模數(shù)轉(zhuǎn)換器),串口,硬件SPI,方便使用。大批量采購價(jià)格目前由于炒貨的原因漲價(jià)到12RMB。(具體問題可以搜索下,網(wǎng)上吹捧得很多)推薦你看一下中文的PDF,到處都有下載的。采用這塊芯片主要來說就有一點(diǎn),比51先進(jìn),功耗低,內(nèi)帶AD,而且外部不需要加晶振。使用一塊LCD5110手機(jī)屏作為顯示設(shè)備,可以顯示輸出電壓以及當(dāng)前狀態(tài)。液晶屏參數(shù)為72*48,點(diǎn)陣式,使用一個(gè)驅(qū)動(dòng)庫作為支持,方便開發(fā),工作在3.3V電壓下。耗電極低,小于1MA,背光耗電為20MA。推薦精選使用一片LDO(低壓差線性穩(wěn)壓源)作為系統(tǒng)電源,LM1117-3.3V,輸出電壓為3.3V,最大電流500MA以下為單片機(jī)的復(fù)位電路和燒錄程序用的接口推薦精選使用OTP-538U紅外傳感器,該傳感器是一種紅外線感應(yīng)型的溫度探測器。主要工作原理是利用紅外線的波長在硅片上產(chǎn)生相應(yīng)的電壓,根據(jù)檢測到的電壓不同來檢測不同的溫度。由于只要是發(fā)熱的光源就會(huì)輻射紅外線,所以可以對溫度進(jìn)行非接觸式的檢測。傳感器由一個(gè)熱敏電阻和傳感器部分組成。傳感器部分根據(jù)外部的溫度產(chǎn)生相應(yīng)的電壓,而熱敏電阻根據(jù)外部溫度不同,電阻值產(chǎn)生變化,由此來補(bǔ)充因?yàn)橥饨绛h(huán)境對傳感器的影響,因此可以做到比較高的精度。價(jià)格為RMB40每顆,以下是接口電路下表是溫度與電壓輸出的比例推薦精選下表是熱敏電阻的變化比率推薦精選由于這兩個(gè)值變化很難算。應(yīng)用電路上都是4個(gè)電阻做的,而且沒有電壓偏移和溫度的關(guān)系。所以我直接舍棄了溫度補(bǔ)償。推薦精選這個(gè)圖的電阻值我完全計(jì)算不出來。淚流滿面。采用TI公司的儀表放大器INA114,采用儀表放大器最大的好處是增加了輸入阻抗,而且放大倍數(shù)比較好調(diào)整,高CMRR,而且噪聲極低,最關(guān)鍵的是,輸入失調(diào)電壓小。價(jià)格為RMB32。以下是儀放的基本參數(shù)LOW OFFSET VOLTAGE: 50mV maxLOW DRIFT: 0.25mV/°C maxLOW INPUT BIAS CURRENT: 2nA maxHIGH COMMON-MODE REJECTION:115dB minINPUT OVER-VOLTAGE PROTECTION:±40VWIDE SUPPLY RANGE: ±2.25 to ±18VLOW QUIESCENT CURRENT: 3mA max當(dāng)R5=100時(shí),放大倍數(shù)為500倍。G=50K/R5。運(yùn)放為雙電源運(yùn)放,所以提供了雙電源。放大后的電壓大概為75MV(26度),145MV(37度)。由于沒有準(zhǔn)確校準(zhǔn),所以必定有偏差。采用美信公司的反相電荷泵芯片MAX889T作為負(fù)向電源的輸出。最大輸出電流為200MA,可以滿足運(yùn)放的需求,留有足夠的余量。電荷泵工作在2M開關(guān)頻率下,只需要1UF的電容就可以工作。不需要外加電感,最大工作電壓為5.5V ,漏電流為20MA。RMB20一個(gè)。軟件流程圖推薦精選程序帶注釋#include <mega88.h>#include "lcd5110.h"#include <delay.h>float wendu;/定義float型的函數(shù)保存溫度,方便計(jì)算小數(shù)#define FIRST_ADC_INPUT 5#define LAST_ADC_INPUT 5unsigned int adc_dataLAST_ADC_INPUT-FIRST_ADC_INPUT+1;#define ADC_VREF_TYPE 0xC0/AD初始化,時(shí)鐘62.5K,內(nèi)部1.1V基準(zhǔn),采用自動(dòng)掃描模式,掃描通道AD通道5/ ADC interrupt service routine/ with auto input scanninginterrupt ADC_INT void adc_isr(void)static unsigned char input_index=0;/ Read the AD conversion resultadc_datainput_index=ADCW;/ Select next ADC inputif (+input_index > (LAST_ADC_INPUT-FIRST_ADC_INPUT) input_index=0;推薦精選ADMUX=(FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff)+input_index;/ Delay needed for the stabilization of the ADC input voltagedelay_us(10);/ Start the AD conversionADCSRA|=0x40;/ Declare your global variables herevoid main(void) /系統(tǒng)初始化/ Declare your local variables here/ Crystal Oscillator division factor: 1#pragma optsize-CLKPR=0x80;CLKPR=0x00;#ifdef _OPTIMIZE_SIZE_#pragma optsize+#endif/ Input/Output Ports initialization/ Port B initialization/ Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In / State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00;DDRB=0xff;/ Port C initialization/ Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In / State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00;DDRC=0x00;/ Port D initialization/ Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In / State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00;DDRD=0x00;/ Timer/Counter 0 initialization/ Clock source: System Clock/ Clock value: Timer 0 Stopped/ Mode: Normal top=FFh推薦精選/ OC0A output: Disconnected/ OC0B output: DisconnectedTCCR0A=0x00;TCCR0B=0x00;TCNT0=0x00;OCR0A=0x00;OCR0B=0x00;/ Timer/Counter 1 initialization/ Clock source: System Clock/ Clock value: Timer1 Stopped/ Mode: Normal top=FFFFh/ OC1A output: Discon./ OC1B output: Discon./ Noise Canceler: Off/ Input Capture on Falling Edge/ Timer1 Overflow Interrupt: Off/ Input Capture Interrupt: Off/ Compare A Match Interrupt: Off/ Compare B Match Interrupt: OffTCCR1A=0x00;TCCR1B=0x00;TCNT1H=0x00;TCNT1L=0x00;ICR1H=0x00;ICR1L=0x00;OCR1AH=0x00;OCR1AL=0x00;OCR1BH=0x00;OCR1BL=0x00;/ Timer/Counter 2 initialization/ Clock source: System Clock/ Clock value: Timer2 Stopped/ Mode: Normal top=FFh/ OC2A output: Disconnected/ OC2B output: DisconnectedASSR=0x00;TCCR2A=0x00;TCCR2B=0x00;TCNT2=0x00;OCR2A=0x00;OCR2B=0x00;推薦精選/ External Interrupt(s) initialization/ INT0: Off/ INT1: Off/ Interrupt on any change on pins PCINT0-7: Off/ Interrupt on any change on pins PCINT8-14: Off/ Interrupt on any change on pins PCINT16-23: OffEICRA=0x00;EIMSK=0x00;PCICR=0x00;/ Timer/Counter 0 Interrupt(s) initializationTIMSK0=0x00;/ Timer/Counter 1 Interrupt(s) initializationTIMSK1=0x00;/ Timer/Counter 2 Interrupt(s) initializationTIMSK2=0x00;/ Analog Comparator initialization/ Analog Comparator: Off/ Analog Comparator Input Capture by Timer/Counter 1: OffACSR=0x80;ADCSRB=0x00;/ ADC initialization/ ADC Clock frequency: 1000.000 kHz/ ADC Voltage Reference: Int., cap. on AREF/ ADC Auto Trigger Source: Free Running/ Digital input buffers on ADC0: On, ADC1: On, ADC2: On, ADC3: On/ ADC4: On, ADC5: OnDIDR0=0x00;ADMUX=FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff);ADCSRA=0xEF;ADCSRB&=0xF8;LCD_init(); /液晶初始化PORTB.5=1; /打開背光/ Global enable interrupts#asm("sei")while (1) /LCD_write_6_8string(0,0," "); / LCD_write_number(24,0,adc_data0); wendu=adc_data0; /采集電壓 wendu=wendu/6+12; /計(jì)算溫度推薦精選 LCD_write_6_8string(0,1," Temperature "); LCD_write_6_8string(0,2," "); LCD_write_float(24,2,wendu); /將計(jì)算后的溫度輸出到屏幕上 LCD_write_6_8string(0,4," Just for a "); LCD_write_6_8string(0,5," simple test "); delay_ms(200); /延時(shí)0.2S / Place your code here ; (注:可編輯下載,若有不當(dāng)之處,請指正,謝謝!) 推薦精選