calibrating lm35 analog value to degree Celsius using 8051

Status
Not open for further replies.
i am working on a project which objective is to measure the temperature of surroundings..using AT89s52 micro-controller and ADC0804 for A to D conversion.. the temperature meant to be shown on LCD..
after doing some research i managed to read ADC values coming from the LM35 and displaying it on LCD..

now... finally the tricky thing which i fails to understand...( may be because i won't get any useful material to study)..
so i want to know...
- how to convert the ADC value to corresponding Degree Celsius
-how the step change get affected by varying the Vref/2 and how this affect my code..

My circuit Diagram and CODE( iam getting the varying ADC value on LCD as i change the temperature) is given as..


#include<reg52.h>
#include"lcd.h"
void delay1(unsigned int);
sbit chipsel =P1^4;
sbit write = P1^5;
sbit intr = P1^7;
sbit readAD = P1^6;
unsigned int val=0,i,j;
void conv();
void read();
void main()
{
init();
while(1)
{
conv();
read();
cmd(0x01);
op(val);
delay(1);
}
}
void conv()
{
chipsel = 0; //Make CS low
write = 0; //Make WR low
write = 1; //Make WR high
chipsel = 1; //Make CS high
while(intr); //Wait for INTR to go low
}

void read()
{
chipsel = 0; //Make CS low
readAD = 0; //Make RD low
val = P3; //Read ADC port
readAD = 1; //Make RD high
chipsel = 1; //Make CS high
}

void delay1(unsigned int y)
{
for(i=0;i<y;i++)

for(j=0;j<1275;j++);

}


the LCD source code is in the attachment with the circuit diagram
 

Attachments

  • prjct.png
    24.5 KB · Views: 847
  • temp.c
    764 bytes · Views: 359
  • lcd.h
    650 bytes · Views: 325
I see no software person has answered you. I am a hardware person.
- how to convert the ADC value to corresponding Degree Celsius
-how the step change get affected by varying the Vref/2 and how this affect my code..
Get the data sheet for the LM35. It has a temperature to voltage graph.
ADCs in micro controllers do not measure voltage directly. In 8 bit mode they measure from 0 to 255. Where 0=0 volts and 255=vref.

You need to think; at freezing=some voltage from the LM35 and a certain ADC reading.
At boiling= a LM35 voltage and a ADC reading. (based on the value of VREF)
With some math you should be able to connect temperature to ADC reading.
 

thanks for your help sir!
i am a noob here and this graph doesn't make me any sense.. its from LM35 Data sheet




i did read some tutorials.. but those are not complete tutorial.. they don't explain what should be the voltage at Vref/2 pin of ADC0804 . and how the step change changes by varying that Vref/2 voltage..
all i get to know that LM35 output voltage changes about 10mV per degree rise in temprature...

all this Vref thing confusing me
 

Attachments

  • upload_2014-12-10_10-44-55.png
    33.6 KB · Views: 399
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…