Cov txheej txheem:

Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub - Automatics Ntxuam Tswj: 6 Cov Kauj Ruam
Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub - Automatics Ntxuam Tswj: 6 Cov Kauj Ruam

Video: Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub - Automatics Ntxuam Tswj: 6 Cov Kauj Ruam

Video: Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub - Automatics Ntxuam Tswj: 6 Cov Kauj Ruam
Video: Стоит ли покупать датчики температуры DS18B20 с Aliexpress? Результат удивил! 2024, Kaum ib hlis
Anonim
Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub | Automatics Ntxuam Tswj
Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub | Automatics Ntxuam Tswj

Kub Sensor (LM35) cuam tshuam nrog ATmega32 thiab LCD Zaub

Kauj ruam 1:

Hauv txoj haujlwm no, Koj yuav kawm Yuav Ua Li Cas txhawm rau Txheeb Xyuas Qhov Kub Kub (LM35) nrog AVR ATmega32 Microcontroller thiab LCD zaub.

Ua ntej Txoj Haujlwm no koj yuav tsum xav paub txog cov kab lus hauv qab no

yuav ua li cas ntxiv lcd tsev qiv ntawv hauv avr studio | avr microcontroller nyeem

taw qhia rau ADC hauv AVR Microcontroller | rau cov pib tshiab

Kub Sensor (LM35) yog qhov kub thiab txias tus nqi ntsuas kub. Vcc tuaj yeem yog los ntawm 4V txog 20V raws li tau teev tseg los ntawm cov ntawv teev tseg. Txhawm rau siv lub ntsuas ntsuas yooj yim txuas Vcc rau 5V, GND rau hauv av thiab Tawm mus rau ib qho ntawm ADC (analog rau digital hloov pauv channel).

Cov zis yog 10MilliVolts ib qib centigrade. Yog li yog qhov tso tawm yog 310 mV ces kub yog 31 degree C. Txhawm rau ua txoj haujlwm no koj yuav tsum paub nrog ADC ntawm AVRs thiab tseem siv LCD Yog li Kev daws teeb meem ntawm AVRs ADC yog 10 ntsis thiab rau qhov siv hluav taws xob koj siv 5V yog li kev daws teeb meem nyob rau hauv cov nqe lus ntawm voltage yog

5/1024 = 5.1mV kwv yees

Yog li yog ADC qhov txiaj ntsig sib xws rau 5.1mV piv txwv li yog ADC nyeem ntawv yog

10 x 5.1mV = 51mV

Koj tuaj yeem tau txais kev nyeem tus nqi ntawm ib qho ADC channel siv txoj haujlwm adc_result (ch);

Qhov twg ch yog tus lej naj npawb (0-5) thaum ATmega8. Yog tias koj tau txuas nrog LM35 qhov tso tawm rau ADC channel 0 ces hu

adc_result0 = adc_read (0);

qhov no yuav khaws qhov nyeem ADC tam sim no hauv qhov sib txawv adc_value. Cov ntaub ntawv hom adc_value yuav tsum yog int raws li ADC tus nqi tuaj yeem yog 0-1023.

Raws li peb pom ADC cov txiaj ntsig tau yog qhov tseem ceeb ntawm 5.1mV thiab rau 1 degree C qhov tso tawm ntawm LM35 yog 10mV, Yog li 2 units ntawm ADC = 1 degree.

Yog li kom tau qhov kub peb faib adc_value los ntawm ob

kub = adc_result0 /2;

Thaum kawg lub microcontroller yuav tso saib qhov kub nyob hauv qib centigrade hauv 16X2 alphanumeric LCD.

Kauj Ruam 2: Daim duab Circuit Court

Daim duab Circuit Court
Daim duab Circuit Court

Kauj Ruam 3: Txoj Haujlwm

#ifndef F_CPU

#define F_CPU 1600000UL

#ib

#suav nrog

#suav nrog

#suav nrog "LCD/lcd.h"

tsis muaj dab tsi adc_init ()

{

AREF = AVcc

ADMUX = (1 <

// ADC Enable thiab prescaler ntawm 128

ADCSRA = (1 <

}

// nyeem adc tus nqi

uint16_t adc_read (uint8_t ch)

{

// xaiv cov channel sib xws 0 ~ 7

ch & = 0b00000111; // THIAB ua haujlwm nrog 7

ADMUX = (ADMUX & 0xF8) | ch;

// pib hloov dua siab tshiab

// sau '1' rau ADSC

ADCSRA | = (1 <

// tos kom hloov dua siab tshiab kom tiav

// ADSC ua '0' dua

thaum (ADCSRA & (1 <

rov qab (ADC);

}

int lub ntsiab ()

{

DDRB = 0xff;

uint16_t adc_result0;

koj temp;

koj nyob deb;

char tsis [10];

// initialize adc thiab lcd

adc_init ();

lcd_init (LCD_DISP_ON_CURSOR); // CUAS

lcd_clrscr ();

lcd_gotoxy (0, 0);

_delay_ms (50);

thaum (1)

{

adc_result0 = adc_read (0); // nyeem adc tus nqi ntawm PA0

temp = adc_result0/2.01; // nrhiav qhov kub thiab txias

// lcd_gotoxy (0, 0);

// lcd_puts ("Adc =");

// itoa (adc_result0, tsis, 10); // tso saib ADC tus nqi

// lcd_puts (tsis);

lcd_gotoxy (0, 0);

nws (temp, tsis, 10);

lcd_puts ("Temp ="); // tso saib kub

lcd_puts (tsis);

lcd_gotoxy (7, 0);

lcd_puts ("C");

nyob deb = (1.8*temp) +32;

lcd_gotoxy (9, 0);

itoa (deb, tsis, 10);

lcd_puts (tsis);

lcd_gotoxy (12, 0);

lcd_puts ("F");

_delay_ms (1000);

yog (temp> = 30)

{lcd_clrscr ();

lcd_home ();

lcd_gotoxy (0, 1);

lcd_puts ("FAN ON");

PORTB = (1 <

}

yog (temp <= 30)

{

lcd_clrscr ();

lcd_home ();

lcd_gotoxy (7, 1);

lcd_puts ("FAN OFF");

PORTB = (0 <

}

}

}

Kauj Ruam 4: Piav Qhia

Kuv vam tias koj Paub Koj yuav paub Yuav ua li cas pab kom ADC thiab Yuav ua li cas cuam tshuam nrog LCD nrog Avr Microcontroller hauv cov cai no thaum ntsuas kub ntau dua 30 degree ces kiv cua nyob thiab koj tuaj yeem pom ntawm coj Zaub FAN ON thiab thaum Kub Tsawg dua 30 ces kiv cua tawm thiab koj tuaj yeem pom FAN OFF

Kauj Ruam 5: Koj tuaj yeem rub tawm Qhov Project Tag Nrho

Nyem qhov no

Pom zoo: