Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to save data on power failure

Status
Not open for further replies.

garg29

Advanced Member level 1
Joined
Nov 17, 2004
Messages
443
Helped
25
Reputation
50
Reaction score
10
Trophy points
1,298
Activity points
3,593
hi friends, i'm making a counter using 89c51 & 7-segment displays. i want to save the last value in eeprom on a power failure. i have the write routines required to write to eeprom. but i don't no how to create a interrupt on power failue. my idea is to have a big condensor 2200 uC and use it's power to write to eeprom. i'm using 24c02 eeprom.

thanks a lot
 

EEPROM retains its contents even when the power is turned off.

Do counter, 80c51, 7-segment displays, and eeprom share the same power source?

Probably you can save the value into eeprom each time the counter ticks. Possible?
 

As nicleo said you can save the data at each tick or if you want to preserve RW memory life cycle you could write when the power shut down, using a large capacitor, a diode and a small reset circuit which generate a hardware interrupt on power failure... Ofcourse this circuit is in amount of dioda...

Hope this help,
//a
 

You would have to create a signal to indicate the power supply has failed. This signal can be fed into the uP and this in turn cause the uP to write to the EEPROM. Also you would have to create an extra circuitry so that a momentarily pause occurs before the power fail in the uP i.e. RC delay or something in that line. This pause will give enough time for the data to be written into the EEPROM whilst the signal will initiate the writing process.
 

Thanks everyone for replying. aNdreiBuuu, as you said i need to put a large capacitor, a diode and a small reset circuit, i'm unfamiliar with the reset circuit. can you please explain it more. i tried with capacitor and a diode, taking a signal from input of the diode and fetching it to p3.2 (external interrupt pin of 8051), but it didn't worked coz i think the uC needs high to low pulse......please help me.
Thanks once again.
 

For the capacitor i would use something with a very low ESR you wont get much power out of it otherwise
You can also provide power to your whole assembly mcu included if you use a supercapacitor; they have esr in the range of tens of milliohms. Then all you need is a fet to charge it and a comparator to see when your power is gone. cap-xx has capacitors rated at 4.5v and 2.25; as well avx sells them rated at 5.5v although they are quite expensive
 

Check this link **broken link removed** for Full-Function µP Supervisor
 

I have the feeling that this big cap solution will not work at all.
Also remember that your CPU has its own reset input and you have to make sure that it is not trigged by power failure.
I would us small (100mAh or less) NI-MH battery and a combination of uP supervisory + memory supervisory circuits (DS1232 + DS1210).
(The DS1232 has both negative and positive pulses). DS 1210 switches with no interrupt from power to battery supply.
If you save results each thime a pulse is counted you will need this battery for the last result only.
The main thing is to maintain proper supply voltage for that period of time and in my oppinion capacitor is not good solution.
 

if you use a supercap:
dV=I*ESR+I*dt/C

trivial example:
dV=0.5V (allowable drop in voltage from vcc)
I=0.1A (current needed)
ESR supercap=0.080Ohm
C supercap=1F
0.5=0.008+0.1*dt
dt=4.92 seconds....that's enough time to erase+write 8K of flash

-if you place the cap in parallel with the powersupply before the mcu you can overcome the problem described by IanP, provided the power does not fail before you get a chance to charge the supercap
-the catch is to charge it up, limit the inrush current at chargeup and detection of the brownout event; use a LM comparator for 50 cents, a fet+resistor for charge up another 50 cents; the resistor must be able to handle 2-3W for like 10s...u're charging in current-limited mode, so the more charged the cap gets the less charge it accepts so it takes longer than a constant current method....
 

thanks everyone for replying. i tried out with a condensor of 2200 uF and it worked out. but the problem is sometimes on power up the data latches up.......can you guys please help me out...thanks
 

It takes time to charge the huge capacitor. You probably need voltage supervisory IC to issue proper reset signal during power up.
 

1) powerin--------a-------schottky--------b--------mcu

2) c-----charger---d----schottky-------e

3) gnd-------supercap-------f

Connect:
c to a
e to b
f to d

if you do this you wont have problems
the charger can be a mosfet+current limiting resistor
look at app notes at www.cap-xx.com in the library section
 

as nicleo said "You probably need voltage supervisory IC to issue proper reset signal during power up." The first reset Ic is for power fail, and activate IRQ (ofcourse it is powered from vcc above dioda) and the second one, for reset is powered from Vcap...

Hope this help,
//a
 

Yes , When power failure cause the best way is to build a small cheap DC UPS for
you MCU .
if your system consumes a lot of power only use this UPS for it's MCU & Memory Unit.

Another Solution is using AVR MCU EEPROM are Builtin .
[/img]
 

thanku friends for replying.
 

the solution provided by sunsina is very good; you have to replace B1 with your cap, to short R1 resistor, and feed your power supervisor IC which command IRQ, from the cap...
Thatz all.

Hope this help,
//a
 

thanks everyone for replying. i tried out with a condensor of 2200 uF and it worked out. but the problem is sometimes on power up the data latches up.......can you guys please help me out...thanks

hello dear how are you

i am bigner to eeprom i am also trying to save the data on power failure i don't have read and write rotine please help me and send me asm code example of save data thank you very much.

i will wait for your reply my e mail is naeem.bmc@gmail.com
 

hi friend i need code example can u show me your code that u hv write plzzzz. i am new to eeprom

i need at89c2051 to interface with 24c16 eeprom

$mod51
ORG 0h

mov p0,#11111111b

mov p2,#0b
mov p3,#0b
start:
mov p1,#11111111b
name: jb p0.0,name ;input 2 start
clr p1.0
acall was ;delay
clr p1.1 ;bit on
acall was ;delay
clr p1.2 ;bit on
acall was ;delay
clr p1.3 ;bit on
stop: jb p0.6,stop ;wait for input 3 restart
sjmp start

was: mov r0,#45
loop1: mov r1,#25
loop2: mov r2,#250
loop3: nop
djnz r2,loop3
DJNZ r1,loop2
djnz r0,loop1
ret
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;
i just want when i put input and port 0 bits start

to clear one by one till bit 3 if the power fail at bit

2 and when resume the power it should be start at bit2

till bit 3
hope understand my problem
thank u very much waiting ur reply:shock:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top