Você está na página 1de 7

11090350

Embedded Systems

Table Of Content
TEMPERATURE SENSOR COMPONENT USED PROJECT CODE 24 25 26

M.M.E.C Mullana

Page24

11090350

Embedded Systems

TEMPERATURE SENSOR
An analog temperature sensor is pretty easy to explain, its a chip that tells you what the ambient temperature is!

These sensors use a solid-state technique to determine the temperature. That is to say, they don't use mercury (like old thermometers), bimetalic strips (like in some home thermometers or stoves), nor do they use thermistors (temperature sensitive resistors). Instead, they use the fact as temperature increases, the voltage across a diode increases at a known rate. (Technically, this is actually the voltage drop between the base and emitter - the Vbe - of a transistor.) By precisely amplifying the voltage change, it is easy to generate an analog signal that is directly proportional to temperature. There have been some improvements on the technique but, essentially that is how temperature is measured.
M.M.E.C Mullana Page24

11090350

Embedded Systems

Because these sensors have no moving parts, they are precise, never wear out, don't need calibration, work under many environmental conditions, and are consistant between sensors and readings. Moreover they are very inexpensive and quite easy to use.

COMPONENTS USEDLM35 MICROCONTROLLER AVR LCD

BLOCK DIAGRAM

M.M.E.C Mullana

Page24

11090350

Embedded Systems

PROJECT CODE
CODING FOR TEMPERATURE DETECTOR

FOR TRANSMIT

#include <avr/io.h> #include <util/delay.h> #include "usart.h" #include "LCD_mega128.h" void InitADC() { ADMUX=(1<<REFS0) ; ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //Prescalar div factor =128} uint8_t ReadADC(uint8_t ch) { uint8_t data,data1; ch=(ADMUX & 0xf0)|(ch& 0x0f); ADMUX=ch; ADCSRA|=(1<<ADSC); //Wait for conversion to complete while(!(ADCSRA & (1<<ADIF))); ADCSRA|=(1<<ADIF); data=ADCL; data1=ADCH; return(data); } void Wait()

M.M.E.C Mullana

Page24

11090350

Embedded Systems

{ uint8_t i; for(i=0;i<20;i++) _delay_loop_2(0); } void main() { uint8_t adc_result; uint8_t data; //Initialize ADC InitADC(); //Initialize LCD InitLCD(LS_BLINK); LCDClear(); //Initialize the USART with Baud rate = 2400bps USARTInit(416); //Put some intro text into LCD LCDWriteString("temperature!!"); LCDWriteStringXY(0,1,"Temp="); while(1) { adc_result=ReadADC(5); data=adc_result/2; UWriteData('J'); //Send 'A' UWriteData('A'); //Send Another 'A' UWriteData('A'); //Send the data; UWriteData(data); //Send inverse of data for error detection purpose UWriteData(~data); //End the packet by writing 'Z' UWriteData('Z'); //Wait for some time _delay_loop_2(0); //Convert to degree Centrigrade //J for junk

M.M.E.C Mullana

Page24

11090350

Embedded Systems

_delay_loop_2(0); _delay_loop_2(0); _delay_loop_2(0); LCDWriteIntXY(5,1,data,3); Wait(); LCDWriteStringXY(8,1,"`C"); Wait(); }

FOR RECIEVE

#include <avr/io.h> #include "usart.h" #include "LCD_mega128.h" void Wait() { uint8_t i; for(i=0;i<20;i++) _delay_loop_2(0); } void main() { uint8_t, i; uint8_t packet[5],data=0; //Initialize the USART with Baud rate = 2400bps USARTInit(416); //Initialize LCD InitLCD(LS_BLINK); LCDClear(); //Put some intro text into LCD LCDWriteString("temperature!!"); LCDWriteStringXY(0,1,"Temp="); while(1) { //Wait for a packet M.M.E.C Mullana Page24

11090350

Embedded Systems

while(!UDataAvailable()); if(UReadData()!='A') continue; while(!UDataAvailable()); if(UReadData()!='A') continue; while(UDataAvailable()!=3); //Get the packet for(i=2;i<5;i++) { } if(packet[2]!=((uint8_t)~packet[3])) continue; if(packet[4]!='Z') continue; //The packet is ok data=packet[2]; //Print the value in 6th column second line LCDWriteIntXY(5,1,data,5); Wait(); //Print in 9th column second line LCDWriteStringXY(10,1,"`C"); Wait(); } } } packet[i]=UReadData();

M.M.E.C Mullana

Page24

Você também pode gostar