View previous topic :: View next topic |
Author |
Message |
Supernova Guest
|
Temperature reading |
Posted: Tue Apr 22, 2008 2:51 am |
|
|
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
|
|
Posted: Tue Apr 22, 2008 2:54 am |
|
|
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
|
Re: Temperature reading |
Posted: Tue Apr 22, 2008 4:44 am |
|
|
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
|
|
Posted: Tue Apr 22, 2008 11:02 am |
|
|
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
|
|
Posted: Wed Apr 23, 2008 8:03 pm |
|
|
with the 18f452 you should be able to follow the above and get good results with 1/2 degree c resolution |
|
|
|