electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

atmega8L avr with temp sensor


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> atmega8L avr with temp sensor
Author Message
welkyb



Joined: 20 Jan 2009
Posts: 2


Post03 Jul 2009 17:05   

lm35 avr


Hi,
I am doing my first avr exp using a temp sensor LM35 to blink blue green or red led according to the temp of the room.
• Connected the leds to PORT B of atmega8L uC and temp sensor to ADC 3 input.
• Using internal oscillator 1MHz as clk, internal reference voltage of 2.56 as reference voltage in FREE RUNING MODE.
• ADLAR = 0 i.e. right adjusted.
• Connected a 0.1uF decoupling capacitor at VREF pin as per datasheet, “Internal 2.56V Voltage Reference with external capacitor at AREF pin”.
• Using prolight leds 1W (for good intensity), transistor in saturation with Ic around 10mA.
According to what I hv understood with temp sensor 10.0 mV/˚C scale factor, output voltage of sensor is input voltage of ADC …...
ADC = ( Vin * 1024 / Vref )
If room temp= 30˚C, Vin = 300mV = 0.3V, So ADC = (.3*1024/2.56)=120. So I hv divided the result by 4.



Fig b.png
atmega8L avr with temp sensor


Here is my code that I hv written in AVR Studio4
#include<avr\io.h>
#define F_CPU 1000000UL
#include <util/delay.h>
int main (void)
{
unsigned int TEMP;
ADMUX= (1<<REFS1)| (1<<REFS0)| (1<<MUX1)| (1<<MUX0);
ADCSRA= (1<<ADEN)| (1<<ADFR);
DDRB|=0xFF;
while(1)
{
TEMP=ADCL+ADCH*256; // ADCH is read only to update ADC data register, otherwise no need
TEMP=TEMP/4;
if(TEMP<=20)
PORTB=1<<PB1; //BLUE
else if(TEMP>20&&TEMP<=2Cool
PORTB=1<<PB0; //GREEN
else if(TEMP>28&&TEMP<=35)
PORTB=1<<PB3; //RED
else
PORTB= ((1<<PB1)| (1<<PB0)| (1<<PB3));
}
}

But I don’t know what the problem is; uC only blinks the led which satisfies the minimum criteria for temp i.e. blue. Even if I multiply the final TEMP variable by 10000 and keep min temp criteria for blue led to blink as less than 2˚C, then also only blue led blinks. It seems the uC is taking no voltage as input.
I hv checked that if I write (PORTB=1<<PB0), then green led blinks or (PORTB=1<<PB3), then red led blinks instead of (PORTB=1<<PB1)

I have connected output pin of sensor directly to uC, is there a problem in it or do I need to use more decoupling capacitors somewhere in the circuit.

plz help
Back to top
Google
AdSense
Google Adsense




Post03 Jul 2009 17:05   

Ads




Back to top
ark5230



Joined: 29 Jun 2009
Posts: 188
Helped: 15
Location: India


Post07 Jul 2009 1:10   

lm35 avr


Circuit diagram does not show LM35 termperature sensor. Rest of the approach to calculate voltage seems to be OK.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> atmega8L avr with temp sensor
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
how to interface a MMC card with Atmega8L In BASCOM-AVR (2)
Read temp with DS18S20 temperature sensor (6)
Dallas DS1821 TEmp Sensor interface with 89C51 (3)
ds1820 temp sensor without microcontroller (2)
Noise with Atmega8l circuit (2)
is it possible to interface TMP100 temp sensor to LPC2129??? (2)
the LM35 temp. sensor - package gets extremely heated (3)
DS1820 Temp Sensor giving odd but coherant values (5)
neeed help with temp monitor with lcd or 7-segment (1)
8051 with Ds1821 (temp.) (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS