Keeping program STATUS in PIC
Keeping program STATUS in PIC
(OP)
Does anyone know of a way I can keep the status of my PIC in memory indefinitely in the event of a power loss?
For example, as the program is running power is lost for a month. When the system is powered up again, I want the program to pick up right where it was when it lost power.
For example, as the program is running power is lost for a month. When the system is powered up again, I want the program to pick up right where it was when it lost power.
Nic Van Engen
Electrical Technician
RE: Keeping program STATUS in PIC
If the PIC were controlling machinery, it would immediately resume an operation that was terminated a month prior? Without knowing whether the workpiece was even still there, Or if there's someone's hand in the way?
TTFN
RE: Keeping program STATUS in PIC
However, if it was controlling machinery, one would certainly incorporate a START button of some sort which would resume the system where it left off, rather than just starting it upon power-up, in order to prevent a dangerous situation.
The important thing is that all timers/counters/bits/whatever keep their values indefinitely without power, like a mechanical timer/counter would.
Nic Van Engen
Electrical Technician
RE: Keeping program STATUS in PIC
RE: Keeping program STATUS in PIC
Nic Van Engen
Electrical Technician
RE: Keeping program STATUS in PIC
TTFN
RE: Keeping program STATUS in PIC
Nic Van Engen
Electrical Technician
RE: Keeping program STATUS in PIC
http://ww
TTFN
RE: Keeping program STATUS in PIC
RE: Keeping program STATUS in PIC
All EEPROM is endurance limited. This means you cannot continuously update it or it will rapidly fail. Furthermore its update rate is only a tiny fraction of the memory's functional speed so constant "backup" is impossible.
There are ways that you can do essentially what you want but they would not be "termed" the way you are stating it.
It is a relatively easy task to save "entered" values and for the controller to then "control to them". Then if power is lost and returns the system can go back to controlling to these previously saved settings.
As IRstuff said the continuation of a program from where the power failed would be a BAD idea.
Keith Cress
Flamin Systems, Inc.- http://www.flaminsystems.com
RE: Keeping program STATUS in PIC
There are PICs with internal eeprom, such as the 16f84a etc.
RE: Keeping program STATUS in PIC
Once again, if it DID have moving parts, one would use a start button and some sort of warning/delay or whatever it takes to make it safe upon power-up. I can't beleive there aren't systems out there with this kind of requirement.
Our system NEEDS to restart automatically, where it stopped, if power is lost for any length of time (and it needs to start where it left off), and it needs to do this automatically WITHOUT human interaction. Having to restart it manually would be a major inconvenience.
Don't most eeproms have a rating of like 1,000,000 writes? If you were to write the timer values to it every 1/2 hour, the eeprom would last for almost 60 years before it is "worn out".
zeitghost - you said you use battery-backed ram - what is the life span of the battery (do you need to replace it every year?), and how long does it hold the memory in the event of extended power loss? I need 100% maintenance free, and I need it to hold the info indefinitely. Would your idea be able to do this?
Nic Van Engen
Electrical Technician
RE: Keeping program STATUS in PIC
http://www.didya.com/16f84.asp
in other cases, only 100,000
TTFN
RE: Keeping program STATUS in PIC
For "ordinary" processors the way to do this continuation / restart action (often known as "warm start") requires specific code to be written into the program to save important data when the power fails, and also to reload this data when the power comes back.
This requires interrupt action when a power fail situation is detected to save the important data. As suggested by other posts, this can be non-volatile (NVRAM) or EEPROM to save these without power, or battery backed RAM. You also need to save a warm start flag status so you know the power has been interrupted at some point.
When power returns the processor will start the program, but as part of this sequence it first checks the warm start flag status: if it's not been set then it continues startup as normal, if the flag is set then the program recovers the stored variables and execution resumes from a known programmed recovery point - but this is NOT "where it left off".
RE: Keeping program STATUS in PIC
i.e. how often it's running with no 5V rail.
Since the clock chip uses uA, a couple of AAs will last a long time.
Alternatively, a single Lithium cell will last a long time too.
As mentioned above, just saving variables doesn't save the state of the machine.
The PIC is capable of detecting the cause of a reset, whether it be a brown out, cold start or watchdog.
RE: Keeping program STATUS in PIC
Plesae read FAQ240-1032
My WEB: <http://geocities.com/nbucska/>
RE: Keeping program STATUS in PIC