Shop OBEX P1 Docs P2 Docs Learn Events
Writing to BS2 EEPROM on power failure — Parallax Forums

Writing to BS2 EEPROM on power failure

Gerry ShandGerry Shand Posts: 45
edited 2010-10-24 01:20 in BASIC Stamp
Hi All:

Working on a project where I need to write 6 pieces of data to the EEPROM after a power failure is detected. Then when power returns, the BS2 restarts its program and reads the data from the EEPROM to carry on with its duties.

I have the software for this working on the test bench - that part was pretty easy.

Here is the challenge: I need a circuit to detect the power failure at the 12 VDC input level to the stamp. The problem is: the 12 VDC is regulated with a lot of capacitance so a power failure is tough to detect. By the time the 12 VDC level drops sufficiently low enough to trigger something like an optocoupler, the 5 VDC level also drops and I do not get the data to write into the EEPROM.

I have a fairly big program whose loop execution time is 0.25 seconds so what I really need is a power supply configuration that keeps the 5 VDC alive for about a second after the 12 VDC has completely died. Trying 1.5 F supercaps is not working. I have tried a bunch of different power supply circuit configurations including isoation diodes between the 12 VDC system and the 5 VDC regulator and not use the on board BS2 supply.

No luck so far. Does anyone have any further suggestions or ideas?

Thanks,

Gerry

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-10-23 09:25
    If you have/had a diode before the smoothing (stand-up) cap/s you could sample your unfiltered DC, albeit with ripple.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-23 10:18
    You could do this all sorts of ways including having an optoisolator with a large value resistor on the primary side of your power supply (110VAC). The output side would have a simple RC filter so that it would take maybe 1/10th of a second for the output to drop below the Stamp's switching threshold. Each time through your main loop, you'd check this input. If it's low, you've lost power.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-10-23 13:19
    Try this little curcuit out!
    '
    Its a jpeg so you'll have to resize it.
    1212 x 884 - 41K
  • MoskogMoskog Posts: 554
    edited 2010-10-24 01:20
    There are also other ways to avoid power failure problems. I am using the batteri backed General-Purpose RAM in a DS1302 timekeeping chip. In this chip you have 31 bytes of RAM available. If you write to this memory in each program loop you will be able to read the latest stored data once you restart the BS. Using a small 3V cell the data will be stored for years.
Sign In or Register to comment.