CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LM35 sensor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
faridh3



Joined: 17 Mar 2014
Posts: 21

View user's profile Send private message Send e-mail

LM35 sensor
PostPosted: Thu Apr 03, 2014 4:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 03, 2014 4:57 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Apr 03, 2014 5:08 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 03, 2014 6:23 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Apr 03, 2014 6:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 03, 2014 7:03 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Apr 03, 2014 7:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 03, 2014 8:45 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Apr 03, 2014 10:58 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group