back up time 1-2 seconds for ardunio uno

I have no idea what you are talking about.

When the main power is off, i want the eeprom to record of some datas. I will be need a second or less to do that. How can I simply do.

To save to the EEPROM you probably needs less time (<2ms if you erase the EEPROM previously). Use some "early warning" circuit for the main power source so you notice when its voltage starts falling. Shut off everything possible powered from the 12V and the smoothing caps may be enough for the EEPROM write.

Wouldn't it work if I put a 2200uf 16V capacitor between 5 volts pin and GND on board? or ( 3.3V pins - GND )

i think that use a voltage divider and i can read this value in analog input. i dont know is it work? (without any capacitor)

Adding a huge capacitor would surely work. You also need to add a diode between 12V and the Arduino's regulator to prevent backfeeding of the external circuit from the huge cap. But for normal Arduino Uno you need really huge cap. 2200uF may be enough if you react quickly a write only a few bytes. Hard to say without much more detail.

Smajdalf:
To save to the EEPROM you probably needs less time (<2ms if you erase the EEPROM previously).

Takes 3,3ms per byte according to the datasheet (and my measurement ):slight_smile:

If connected to to 5V line you need a pretty big capacitor for an acceptable time.

I did some tests one moth ago. A Pro Mini without a LED and not powering anything (significant, which isn't that hard to design but you do need to think about it) can run for 170ms on a 470uF cap if that cap is charged to 12V and fed to Vin. Used 4,3V (settable BOD voltage) as lower limit of Vcc. Witch LED it's 130ms.

Is the attached circuit enough? or should i add a 2200uf cap. between 5V pin and GND on UNO?

What is the diode doing there?
Resistors should at least be an order of magnitude larger. But you can also just use a 100k to pin and detect it digital. Can even be an interrupt pin.

I assume BAT1 is the external supply you're talking about?

And of course you need a buffer cap if you want to do something if you loose power. You can connect it between Vin and GND and use the diode inline with the barrel plug to decouple the Arduino from the power supply. Also, be sure to not power anything from the Arduino (including IO) or at least turn it off as quick as possible.

1. The following circuit could be exercised to see that the MCU does save data in its internal EEPROM during power fail/switch OFF. The power failure/switch OFF condition could be detected either by polling the PD2-pin or being interrupted.
pwrF.png

2. However, another issue is to keep in mind that the EEPROM is prone to get erratically written at random locations when the Vcc supply goes below about 3.4V. Brown out detection level could be properly chosen via fuse bit setting of the MCU so that the MCU enters into reset condition when the Vcc supply falls below 3.4V and thus prevents the EEPROM from getting written erratically.

Wow, that is a whopping overcomplicated circuit for it!

And the buffer cap is connected to Vcc, aka you have a range from 4,5V to 4,3 volt to do your thing... Not very appealing.

i think Just analog read and (2200uf cap. 5V-GND pins ) is enough to to save of eeprom. i will test this circuit and
share with you.

septillion:
Takes 3,3ms per byte according to the datasheet (and my measurement ):slight_smile:

1.8ms if you are prepared:

1.8ms a wonderful value. maybe it does not need any capacitor, i use a switch mode power supply, surely it has a capacitor in the out of DC :))

septillion:
Wow, that is a whopping overcomplicated circuit for it!

But, we need a mechanism to inform the MCU that there is a failure in the DC power system and then the MCU will save the critical data into its internal EEPROM. The posted circuit is not the only available design, there could be and there are many alternatives in the web some of which are not less complicated than the posted one.

You also need to check what the power consumption is while writing EEPROM - this will be more than
normal as the on-chip inverter has to be powered up to generate programming voltages. If the chip
runs for 0.17s on 470uF normally, it might not while actively writing EEPROM.

@Smajdalf, missed that. But I guess you have to write your own routine for that I guess?

GolamMostafa:
But, we need a mechanism to inform the MCU that there is a failure in the DC power system and then the MCU will save the critical data into its internal EEPROM. The posted circuit is not the only available design, there could be and there are many alternatives in the web some of which are not less complicated than the posted one.

Correct. But how about 100k to an interrupt pin :slight_smile: Or, if you want to have a bit more control, a voltage divider in that order of magnitude :slight_smile:

@MarkT You are correct, I should repeat the rests while doing some writing once

Hey all,

The result is possitive! as i think swich mode power say has a few capacitors on output of DC. When the main power is off, ardunio is going to work for 2-3 seconds and the eeprom can record!

Thanks a lot for your help
Ali

alio1984:
Hey all,

The result is possitive! as i think swich mode power say has a few capacitors on output of DC. When the main power is off, ardunio is going to work for 2-3 seconds and the eeprom can record!

What mechanism have you employed to inform the Arduino/MCU about power failure? Are you detecting the zero crossings of the mains or detecting DC power failure? If possible, post the circuits.

i follow the output of 12V DC power with simple voltage divider from Analog input. I took the wrong measurement first. I solved the noise problem with a few diodes( for relay bobins) and 100nf capacitors (for voltage divider)