View previous topic :: View next topic |
Author |
Message |
faridh3
Joined: 17 Mar 2014 Posts: 21
|
LM35 sensor |
Posted: Thu Apr 03, 2014 4:47 am |
|
|
Hello,
i need to do a driver for this sensor but just for positive temp. i need to use only AN0, using no interrupts.
I am only getting the ADC result with this code
Code: | int8 ADC_val;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_12);
set_adc_channel(0);
ADC_val = read_adc();
printf(lcd_putc, "ADC val: %03u", ADC_val);
|
This code is not showing on the LCD the temperature, but the ADC result.
how can i convert it to celsius ?
Thanks
Farid |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu Apr 03, 2014 4:57 am |
|
|
Hi,
Sorry, this question is too embarrassingly easy to solve on your own with a little bit of research in the forum archives, and using Google. You'll learn a lot more if you solve this problem yourself rather than asking us to spoon feed you.....
Good Luck!
John |
|
|
faridh3
Joined: 17 Mar 2014 Posts: 21
|
|
Posted: Thu Apr 03, 2014 5:08 am |
|
|
ezflyr wrote: | Hi,
Sorry, this question is too embarrassingly easy to solve on your own with a little bit of research in the forum archives, and using Google. You'll learn a lot more if you solve this problem yourself rather than asking us to spoon feed you.....
Good Luck!
John |
I am sorry but i need this urgently .. i am new at this.
I also have to use a 5 times amplifier for the LM35.
Thanks |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu Apr 03, 2014 6:23 am |
|
|
faridh3,
Your question, and the whole manner in which you ask it screams "late homework assignment"..... It's NOT the purpose of the forum to do your work for you, 'Urgent' or not!
As a test, I did a forum search using 'LM35' as the search criteria, and found the EXACT answer to your question in under 2 minutes! Come on, I really hate to beat you up, but YOU could have found the solution to the problem on your own faster than posting a request for help here.....
John |
|
|
faridh3
Joined: 17 Mar 2014 Posts: 21
|
|
Posted: Thu Apr 03, 2014 6:25 am |
|
|
ezflyr wrote: | faridh3,
Your question, and the whole manner in which you ask it screams "late homework assignment"..... It's NOT the purpose of the forum to do your work for you, 'Urgent' or not!
As a test, I did a forum search using 'LM35' as the search criteria, and found the EXACT answer to your question in under 2 minutes! Come on, I really hate to beat you up, but YOU could have found the solution to the problem on your own faster than posting a request for help here.....
John |
Your are right i know .. i've been searching for 1hour .. i am new at the ADC world .. so thats why.
and its not a homework .. i have a project to do for the next month.
Thanks
Farid |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Apr 03, 2014 7:03 am |
|
|
simple google 'lm35 ccs c code' and you get about 5000 hits....
some within the first 4 pages have EXACTLY what you require..
..well, after you adjust the code to compensate for your x5 amplifer.
hth
jay |
|
|
faridh3
Joined: 17 Mar 2014 Posts: 21
|
|
Posted: Thu Apr 03, 2014 7:21 am |
|
|
temtronic wrote: | simple google 'lm35 ccs c code' and you get about 5000 hits....
some within the first 4 pages have EXACTLY what you require..
..well, after you adjust the code to compensate for your x5 amplifer.
hth
jay |
Thank you jay |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Apr 03, 2014 8:45 am |
|
|
I'll jump in since you sent me a PM.
If you use the code on this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=50320
You will get a nice ADC reading for Positive temperatures only.
If you simply multiply said reading by your ADC constant, your result is in degrees Celcius... thats the standard LM35 output "format".
From there you just have to use the right printf() format.
Both of which you can find in my LM35 "Driver"....
(my "driver" is just a fancy adc averaging function that handles +/- temperatures).
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
faridh3
Joined: 17 Mar 2014 Posts: 21
|
|
Posted: Thu Apr 03, 2014 10:58 am |
|
|
Gabriel wrote: | I'll jump in since you sent me a PM.
If you use the code on this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=50320
You will get a nice ADC reading for Positive temperatures only.
If you simply multiply said reading by your ADC constant, your result is in degrees Celcius... thats the standard LM35 output "format".
From there you just have to use the right printf() format.
Both of which you can find in my LM35 "Driver"....
(my "driver" is just a fancy adc averaging function that handles +/- temperatures).
G. |
Thanks G. |
|
|
|