×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Keeping program STATUS in PIC

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.

Nic Van Engen
Electrical Technician

Replies continue below

Recommended for you

RE: Keeping program STATUS in PIC

Frankly, given that you've given no information, such a concept is a BAD idea.  

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

(OP)
The PIC will not be controlling machinery, just heaters and a few other non-moving parts.

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

Can you write the important stuff to eeprom?  Use a voltage sensing circuit that will sense the impending low volts (while you still have some volts left) to interrupt your program and write the important stuff.  Then on power up and reset the first thing it does is grab the stuff from eeprom and go to the appropriate code.

RE: Keeping program STATUS in PIC

(OP)
eeprom - would work in this scenario, although I wouldn't know how to set it up (writing to the eeprom that is).  Has anyone ever tried that?

Nic Van Engen
Electrical Technician

RE: Keeping program STATUS in PIC

You need to talk to whoever designed or procured the PIC to find out what it's capable of and what hardware it has.  

TTFN



RE: Keeping program STATUS in PIC

(OP)
Let me rephrase:  Are there PIC's available with those capabilities?

Nic Van Engen
Electrical Technician

RE: Keeping program STATUS in PIC

Microchip also sells eeproms.  Try their website, www.microchip.com.  They have tons of application notes.

RE: Keeping program STATUS in PIC

No there is no PIC with that capability.

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

Write to an external battery backed ram. There's no limit to the write cycles with that. I used the ram in an IIC clock chip (DS1307) to hold non time related data in one project.

There are PICs with internal eeprom, such as the 16f84a etc.

RE: Keeping program STATUS in PIC

(OP)
This machine doesn't have any moving parts, and no matter what it does on power-up would not create a dangerous situation.  Not to mention, our systems runs unattended - no one even on the site - for weeks at a time.

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

In following this post I think an important point has been missed: a program can't just restart from memory from where it left off unless its processor internal status is also saved. This is because most processors are of dynamic internal construction, requiring everything to be refreshed with a clock (apart from a few types whose clock can go down to zero Hz, where provided it has a battery backup power to maintain the internal register states, it can resume from exactly where it left off).

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

Battery life is down to how often it gets used.

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

Run the uC from the rechargable battery, yoo. Every 10 minutes record the status etc and re-init the program.

Plesae read FAQ240-1032
My WEB: <http://geocities.com/nbucska/>

RE: Keeping program STATUS in PIC

you could write the variables to the ROM on the PIC in every step of the program...ie: after any change jump to a function which write ass the variables to rom and have the pic read them from the rom when it starts up (initialization)...well that is if you pic has rom. this will be labor intensive...but if you just controling heaters time should not be an issue...it's not like you're implementing a controller for a fighter jet.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close