Problem with LM35, ADC0804 and 89s52 interface (assembler code)

Status
Not open for further replies.
Room temp 24,9 degrees Celsius. pin 9 1,262 V and pin 6 was 0,262 V

---------- Post added at 09:52 ---------- Previous post was at 08:46 ----------

I changed pin 9 to 1,28 V. It doesn't have to be 100% accurate, but it has to work.

With this change The adc should output 255 for 2.56V = 2560mV.

For 25oC the LM35 will produce 250mV which the ADC will convert into 25.

In the previous case th

---------- Post added at 15:16 ---------- Previous post was at 15:13 ----------

Room temp 24,9 degrees Celsius. pin 9 1,262 V and pin 6 was 0,262 V

---------- Post added at 09:52 ---------- Previous post was at 08:46 ----------

I changed pin 9 to 1,28 V. It doesn't have to be 100% accurate, but it has to work.

For 24.9C the LM35 is giving 262mV?
 

Pin 9 - 2,278 V
Pin 6 - 0,27 to 0,28 V
Room temp 24,9 degrees Celsius
Just Checked.

If I would have C code I could also get it working, But I have no code - that's the problem!

---------- Post added at 15:30 ---------- Previous post was at 15:28 ----------

Yeah, just found out that after many times changing everything I forgot to put Vref voltage back to 1,28 V. I will do the change in 2 min and I will put your code back in it, so you see what it shows.

---------- Post added at 15:38 ---------- Previous post was at 15:30 ----------

1,284 V on Vref pin

---------- Post added at 15:40 ---------- Previous post was at 15:38 ----------

And it shows 95->9595->959595->95959595 ......
 

Strange, It was a tested code. I will soon see it again.

Here is a tested C code:-

First run to display temperature. Then add an if condition to activate the pin connected to relay.



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<8051.h>
#include<stdio.h>
#include<lcd.c>
void disp_digits(int n);
__sfr __at (0x80) ADC_PORT;  //P0 port
 
unsigned int temp;
int hundreds,tens,ones;
unsigned int getadc;
char strbuff[12];
void main(){
while(1){
getadc=ADC_PORT;
MSDelay(100);
LCD_init();
LCD_command(0x86);
temp=getadc;
if(temp>=100)
{
ones=temp%10;
temp=temp/10;
tens=temp%10;
hundreds=temp/10;
sprintf(strbuff,"%d%d%dC",hundreds,tens,ones);
}
else
{
ones=temp%10;
tens=temp/10;
sprintf(strbuff,"%d%dC",tens,ones);
LCD_sendstring(strbuff);
}
MSDelay(100);
}
}


As the LM35 output scale is 10mV/C and for Vref/2 =1.28, ADC's resolution is also 10mV. So we can avoid fraction.

You need two header files lcd.c and Lcd.h
Please read the top of the lcd.h file to configure it according to your connection.
Working version compiled with SDCC compiler.
 

Attachments

  • lcd.zip
    1.5 KB · Views: 46
Reactions: rvs

    rvs

    Points: 2
    Helpful Answer Positive Rating
Thank you, got it working.
 


Dear! I have complete understanding of ADC0804 as well as how to interface it with 89C51 and get results. but I am facing problem to interface LM35 with the ADC. I am facing the same problem as above, explained as:

Let I have to measure temperature from 0 to 100 degree Celsius. Now I know that Vref/2 would be the voltage equal to the maximum voltage by LM35 generated at 100 degree Celsius (correct me if wrong). The reason is that what voltage should I apply to the input of LM35. I cannot understand you as you explained above! from where the value 256 mV come from ? would you like to elaborate it? Thanx
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…