adison.mhanna
Newbie level 4
hello guys.
I really get stuck!!!
I am designing a temperature logger on the PC. I am using LM35 with PIC16F877A microcontroller with its built-in ADC
I want to send the value of the temperature to the PC using MAX232 to log it somewhere in my database
I don't need to display the temperature on an LCD, all I need is to get the value from the LM35 and send it through the RS232 serial port
I tried so many times with the same wrong result: I am getting values that is always changing even if I am putting a fixed voltage instead of the LM35 sensor.
I have only one analog input.
this is the code that I am using:
I think the error is in the VREF settings. Actually I don't know how to set it and what should I connect to it.
I've already done so many researches in google and in this forum, and I got no answer for my problem. The circuit diagram is the same as the following circuit posted in this forum:
I am getting those values on my PC HyperTerminal while of course the temperature did not changed that way in few seconds :!::!::!:
68.0 C
44.0 C
27.0 C
38.0 C
89.0 C
57.0 C
102.0 C
77.0 C
76.0 C
59.0 C
68.0 C
77.0 C
38.0 C
38.0 C
51.0 C
64.0 C
44.0 C
.
.
.
.
please I need a very urgent help in fixing this issue.
Thank you
I really get stuck!!!
I am designing a temperature logger on the PC. I am using LM35 with PIC16F877A microcontroller with its built-in ADC
I want to send the value of the temperature to the PC using MAX232 to log it somewhere in my database
I don't need to display the temperature on an LCD, all I need is to get the value from the LM35 and send it through the RS232 serial port
I tried so many times with the same wrong result: I am getting values that is always changing even if I am putting a fixed voltage instead of the LM35 sensor.
I have only one analog input.
this is the code that I am using:
Code:
#include <16f877a.h>
#device adc=10
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
float temp;
void main()
{
SETUP_ADC(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(AN0);
SET_ADC_CHANNEL(0);
delay_ms(100);
while(1) // infinite loop
{
temp = read_adc();
delay_us(100);
printf("%2.1f C\n",temp);
}
}
I think the error is in the VREF settings. Actually I don't know how to set it and what should I connect to it.
I've already done so many researches in google and in this forum, and I got no answer for my problem. The circuit diagram is the same as the following circuit posted in this forum:
I am getting those values on my PC HyperTerminal while of course the temperature did not changed that way in few seconds :!::!::!:
68.0 C
44.0 C
27.0 C
38.0 C
89.0 C
57.0 C
102.0 C
77.0 C
76.0 C
59.0 C
68.0 C
77.0 C
38.0 C
38.0 C
51.0 C
64.0 C
44.0 C
.
.
.
.
please I need a very urgent help in fixing this issue.
Thank you