View previous topic :: View next topic |
Author |
Message |
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
How to Keep track of time? |
Posted: Thu Jul 08, 2010 1:25 am |
|
|
I need to keep track of a lamp operating time. Have to save values in-between power cuts. What will be the best way to do this?
Hope someone can give me ideas.
Thanks and Regards.
Jai. |
|
![](templates/subSilver/images/spacer.gif) |
Jerson
Joined: 31 Jul 2009 Posts: 122 Location: Bombay, India
|
|
Posted: Thu Jul 08, 2010 4:05 am |
|
|
1. Use an RTC chip like the DS1307
2. Implement a firmware timer code along with a power fail early warning interrupt that you use to save the time values to the EEPROM _________________ Regards
Jerson Fernandes |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Jul 08, 2010 4:08 am |
|
|
The last post brings up the question of:-
Does the PIC loose power during the power cut or do you monitor the power outage another way ?
I assumed the PIC was running on battery or something.
If your PIC has RTCC built in then just use that. Also what accuracy do you need ? Second, ms ? |
|
![](templates/subSilver/images/spacer.gif) |
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
|
Posted: Thu Jul 08, 2010 4:25 am |
|
|
I don't want to use RTC. Don't need to be very accurate. The Clock is 4Mhz crystal.
I have seen other posts on this issue. Want to know whether a diode and huge cap supply for the pic alone and a voltage divider sample idea.Save to internal eeprom. will it work? have to save 4 bytes. |
|
![](templates/subSilver/images/spacer.gif) |
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Jul 08, 2010 4:55 am |
|
|
You would not need an RTC - there is a thesis on the net about getting precise 1sec delays in a PIC.
It's in PDF format.
How you manage to keep the PIC powered is at your discretion. |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Jul 08, 2010 5:19 am |
|
|
WIth a cap you could proberbly keep the PIC running for a little while when the power goes off, depending on current draw.
I assume then you will not be powering the PIC whilst the power is off?
Are you expecting the cap to keep the pic powered up whilst the power is off or do you just want it to keep it on for long enough to store the values ? |
|
![](templates/subSilver/images/spacer.gif) |
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
|
Posted: Thu Jul 08, 2010 7:08 am |
|
|
Are you expecting the cap to keep the pic powered up whilst the power is off - I ONLY WISH.
No Just Long enough to store the 4 byte values on the internal eeprom of pic. |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Jul 08, 2010 7:12 am |
|
|
So what are the 4 bytes ?
The pic will have no knowledge of how long it was off and it will not be able to work out how long it was off unless you have some extenal timer.
Each time the pic powers up will you be setting the time info on it somehow?
You will only be able to monitor how long the pic was on for each time. This will not tell you how long the power was off. |
|
![](templates/subSilver/images/spacer.gif) |
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Jul 08, 2010 9:08 am |
|
|
This is going to get complicated.
As I said at the beginning - How you manage to keep the PIC powered is at your discretion.
This is a forum for the CCS compiler.
Keeping the PIC powered has nothing to do with it. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Jul 08, 2010 3:07 pm |
|
|
vsmguy wrote: | This is a forum for the CCS compiler.
Keeping the PIC powered has nothing to do with it. | True, but this forum does allow threads that are slightly off topic as long as they are PIC related. From the CCS Forum Policy and Guidelines: Quote: | 6. Stay on topic
This forum's sole purpose is to help people with programming Microchip's in CCS PIC C. Also, generally any discussion about Microchip's, firmware designing and electronic components in embedded systems is considered on topic. | I like the question and would like to see an answer. |
|
![](templates/subSilver/images/spacer.gif) |
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Jul 08, 2010 3:38 pm |
|
|
A good way to power the PIC would be to have a LDO connected to the regular 9V battery via a relay/FET that switches when there is no external power.
This would give the PIC all the backup it would ever need. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Jul 08, 2010 7:14 pm |
|
|
Quote: |
Does the PIC loose power during the power cut or do you monitor the power outage another way ?
|
This question had not been answered and it is decisive in this stage.
Another data that you must know previously is current drain of the whole circuit in idle state.
The PIC drain current depends mainly of how do you set the oscillator circuits while in sleep/idle mode
minimizing its internal modules activity. If your application is able to run in this way, you will get the PIC
running at VERY LOW consumption (uA level) and a the 9V battery option would be applicable.
In order to consider the autonomy of operation with 9V battery I attach this info:
http://data.energizer.com/PDFs/522.pdf
Humberto |
|
![](templates/subSilver/images/spacer.gif) |
|