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

Temperature reading

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







Temperature reading
PostPosted: Tue Apr 22, 2008 2:51 am     Reply with quote

Hello,

I would like to read a temperature like every 5 sec. I all ready know how to do the reading, but it's the part when I want to do an interrupt every 5 sec that i don't know how to do...

Can any one give me a tip?

Thanks

Jonathan
Supernova
Guest







PostPosted: Tue Apr 22, 2008 2:54 am     Reply with quote

oh by the way i'm using a PIC18f452 at 20MHZ if this can be of any use.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Temperature reading
PostPosted: Tue Apr 22, 2008 4:44 am     Reply with quote

Supernova wrote:
Hello,
I would like to read a temperature like every 5 sec..

I would not bother with interrupts. It is just as easy to poll timers in a loop, depending on what else the processor is doing. Set up a timer using the maximum prescaler available. Then periodically check to see if 5 sec. has elapsed, in order to do your temperature reading.

Robert Scott
Real-Time Specialties
foodwatch



Joined: 18 Apr 2006
Posts: 66

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Apr 22, 2008 11:02 am     Reply with quote

I do this in my existing products. You can use something in the 18F family (I use an 18f4550 which might be overkill). Use the internal oscillator set to 1 or 4 mhz. Set the wdt timeout to either 1024 (about 4+ secs) or 2048 (about 9secs). I use the national LM61 analog temp chip. Create a simple loop, turn on wdt then sleep(). When you wake from sleep, read adc on the port you are connecting the lm61 to. Take the result, *.00488 (if using 10 bit ad) and the result is a float in millivolts. Subtract 600 from the result and the temp is in 10's of degrees c. The lm61 gives 600mv for 0 c so you can read -40c as 200mv (results always a positive number). The lm61 has its own internal regulator and will work from 3-10vdc. I run mine on the 5v to the cpu. I even run it off an output pin on the 4550 when I need to switch off the lm61 when running on batteries. Hope this gets you going in the right direction...
foodwatch



Joined: 18 Apr 2006
Posts: 66

View user's profile Send private message Yahoo Messenger

PostPosted: Wed Apr 23, 2008 8:03 pm     Reply with quote

with the 18f452 you should be able to follow the above and get good results with 1/2 degree c resolution
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