Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

auto_mitch

Full Member level 3
temperatura lm35 celcius formula *5/255

Hi!
this is my first project using the ADC of my mega8535.
i want to measure the temperature through lm35 and display it on the lcd. i have connected the AREF=4.7V
Vcc=4.7V,AVcc=4.7V. My analogue channel is ADC3(PA3). The LM35 is connected to 4.7V and the signal pin is directly connected to ADC3. As i have seen in datasheet with this connection i can measure 2-150 Celcius degrees, and for each degree you measure 10mv. From these information i have calculated the function that converts voltage to temperature (Temp=0.1*Voltage+2).
This is my code in codevision. My problem is that i cannot measure normal temperature and my highest temp that i can measure is 30.82C. Could you please help me what am doing wrong.
thanx.

Code:
#include <mega8535.h>
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
#include <delay.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include<stdio.h>

float current_temp;
float voltage;
char lcdbuffer[16];

{
}

void temp()
{
current_temp=0.1*voltage+2.0;
ftoa(current_temp,2,lcdbuffer);
lcd_gotoxy(8,0);
lcd_puts(lcdbuffer);
}

void main(void)
{
lcd_init(16);         // LCD Initialization.
lcd_gotoxy(0,0);
lcd_putsf("Temp:");
while (1)
{
#asm ("sei")

temp();
};
}

thabs

Newbie level 2
I think you should maybe put an amplifier to the LM35 before sending to ADC. The voltage would now be higher than the expected 10mv temperature, so you will also be required to change your temperature scaling formula.

rikie_rizza

Full Member level 6
LM35 is 1C accuracy. so, in order to achieve 1C you must convert each 10mV rising to 1C. 5mV doesnt guarentee 0.5C.

Anyway, have you measure the output... i think its hardware problem.

tom_hanks

Full Member level 5
from my exp...

ref vge should be always less the supply vge...
i would recomend u to connet Vcc to 5V... and Vref to4.7...

Then only u can get the full scale reading.....

otherwise the 4.7volts equivivalent value will be the maximum ADC can measure...

put a 100pf cap on the adc line...
or for more accuracy use a OPAMP vge follower between the ADC & pIC....

pls donot forget to pres helpme

Code:
//ADC interrupt service routine
{
}

void temp()
{
current_temp=0.1*voltage+2.0;
ftoa(current_temp,2,lcdbuffer);
lcd_gotoxy(8,0);
lcd_puts(lcdbuffer);
}

void main(void)
{
lcd_init(16);         // LCD Initialization.
lcd_gotoxy(0,0);
lcd_putsf("Temp:");
while (1)
{
#asm ("sei")
temp(); [/b]
};
}

auto_mitch

Points: 2

harii74

Member level 5
Hi,
You just go through the full scall analog in and find out the resolution of an ADC with reference.
You adjust sensor out either POT or Amplifier.
Eg:
Dout is 8 bits ( 255 decimal)
So,The resolution is == 5/255 -1
= 19.86 millivolts

Solution:
Sesonr output is 10mv/ c
so use amplifier to get approx 20mv/c

This is called signal conditioner

Status
Not open for further replies.