Perfecting The TC54 Brownout Detector To Backup Variables In The EEPROM
Mahonroy
Posts: 175
Hey guys,
I have a project circuit setup that is similar to the education kit tutorial setup, here is a photo for reference:
http://www.parallax.com/sites/default/files/styles/full-size-product/public/32305a.png?itok=J6DWZOG0
I am also using a 12V voltage regulator, which is in parallel with the 5V voltage regulator. The 3.3V voltage regulator is powered from the 5V voltage regulator (similar to the education kit).
I have the brownout detector connected to the 12V output, and will activate at 8.6V (I'm using the 4.3V brownout detector, and using a voltage divider of 2x 50K resistors so I can read 8.6V instead.). I am using a pullup resistor, and a diode, and have this connected to a propeller pin.
I also have some capacitors surrounding the input and output of all the voltage regulators.
In the propeller spin program, I am monitoring a pin, and as soon as it goes low, the propeller chip saves all of the data I want to the EEPROM. So far this works great, but I have a couple questions.
I have a 1000uf capacitor on the output of the 5V voltage regulator. This does not give the program enough time to save data to the EEPROM before loosing power. Using 2x of these capacitors in parallel (2000uf equivalent) also is not enough time. But 3x capacitors (3000uf equivalent) and it works every time.
So my question is, should I use a single 5000uf capacitor to be on the safe side? Would a 0.01f capacitor be overkill? What do you guys think is the best way to handle this? Or has anyone hooked this up differently?
Thanks and any help/advice is greatly appreciated!
I have a project circuit setup that is similar to the education kit tutorial setup, here is a photo for reference:
http://www.parallax.com/sites/default/files/styles/full-size-product/public/32305a.png?itok=J6DWZOG0
I am also using a 12V voltage regulator, which is in parallel with the 5V voltage regulator. The 3.3V voltage regulator is powered from the 5V voltage regulator (similar to the education kit).
I have the brownout detector connected to the 12V output, and will activate at 8.6V (I'm using the 4.3V brownout detector, and using a voltage divider of 2x 50K resistors so I can read 8.6V instead.). I am using a pullup resistor, and a diode, and have this connected to a propeller pin.
I also have some capacitors surrounding the input and output of all the voltage regulators.
In the propeller spin program, I am monitoring a pin, and as soon as it goes low, the propeller chip saves all of the data I want to the EEPROM. So far this works great, but I have a couple questions.
I have a 1000uf capacitor on the output of the 5V voltage regulator. This does not give the program enough time to save data to the EEPROM before loosing power. Using 2x of these capacitors in parallel (2000uf equivalent) also is not enough time. But 3x capacitors (3000uf equivalent) and it works every time.
So my question is, should I use a single 5000uf capacitor to be on the safe side? Would a 0.01f capacitor be overkill? What do you guys think is the best way to handle this? Or has anyone hooked this up differently?
Thanks and any help/advice is greatly appreciated!
Comments
Also, what are you using for your 3.3V regulator? With only a 5V input, it needs to be of the low-dropout variety.
-Phil
Thanks for the reply!
Here are the links for the regulators I'm using:
12v: http://www.mouser.com/ProductDetail/ON-Semiconductor/MC7812CDTG/?qs=%2fha2pyFaduirlRo6%2b6i1uL%2baN6Q8hIO%2b37J7F9kx%2bQa%2bV6TblXtdrw%3d%3d
5v: http://www.mouser.com/ProductDetail/STMicroelectronics/L7805ACD2T-TR/?qs=%2fha2pyFadujE9KQ1BxQHaJhNdIfs376LTVhKKFHwq0HqIltLh27UEg%3d%3d
3.3v: http://www.mouser.com/ProductDetail/Diodes-Incorporated/AZ1117D-33TRE1/?qs=%2fha2pyFaduhVsYvw8V7yKDVonnmFlWxloYdZVlYmAhphETUXqM7LuCqNMsjCu5K%2f
I attached a diagram showing how everything is currently connected, as well as the caps that I have in there so far.
This way, when the 12V supply starts to go low, the 47uF cap will discharge, letting the voltage detector see the brownout condition. But the diode will be reverse-biased at this point, so the voltage on the 1000uF cap can only discharge into the 5V regulator and circuitry further downstream, allowing more time for the backup.
Yes, that's what you would need to do.
Power fail detection used to be quite common but most systems these days are designed so that it just works without it. For instance, if you have variables that need to be backed up into EEPROM then depending upon what that is you can use a method which just checks for changes every few seconds or so and writes it to the EEPROM. But with this simple scheme the EEPROM will wear out some may exclaim yet simple maths tells you that 1 million MINIMUM guaranteed writes to the same location every 5 minutes of every day would still be fine after 10 years. If you are logging then normally the location changes so that is even less of a problem.
BTW, looking at the project board picture with the 9V battery I always wonder why the PropPlugs don't provide 5V out and just jolly well power the whole board anyway.
Ok so I gave this a try and wired everything up like you described, and here are my results.
Before change:
1 capacitor: 10ms of time before power loss
2 capacitors: 13ms
3 capacitors: 16ms
After change:
1 capacitor: 13ms
2 capacitors: 16ms
3 capacitors: 20ms
So it did allow for more time this way. Do you think this is enough though? It seems like its taking 14-16ms to save the data.
Peter, my old design worked by just saving the data to the EEPROM every time it changed. While this did work perfectly fine, it just seemed like a better design to save the data when the user is done with it (e.g. at power down), so I figured I would get a voltage detector to work. This also frees up some time that it takes to write the data every time.
It takes 5 to 10ms to write a byte to EEPROM and it takes 5 to 10ms to write a page of 64 bytes as well. However there is no need for your software to sit and wait for it to be done, all it needs to do is perform the sequential write and issue an I2C stop after which the EEPROM will look after itself, it doesn't need the Prop to hold its hand. But this means that if you try to do this again too soon that it will still be busy but this is normally taken care of by the EEPROM addressing as it should keep trying if it doesn't get an ack because of the chip being busy. Still, I doubt very much that this would ever be the case so if you can try this then good.
Power fail methods are way too dependant not only upon the discharge rate but also the response time and so normally this is tied to a non-maskable interrupt and the equivalent in the Prop is to dedicate a cog to this function, once it detects a power fail it should stop all other cogs to conserve power before attempting any backup and then not waiting for the EEPROM to finish but also shut down the power-fail cog too. That is if you really feel you should do it this way though I would avoid it.
BTW, change the 47uF to the minimum or 10uF as you need it to react almost immediately. Normally I would have put the PF detect before the +12V to catch the input supply droop. What is you input supply?
-Phil
You can buy more time, with a minor change :
Move the Diode + to the Power In, so the 5V Reg has full Vin applied.
You can move the Fail sense to the 12V reg in, and set to 10-12V, and use the smallest cap on the 12V reg you can.
That means the Vin and 12V fall quickly, and the 5V/3V chain has the longest decay time, and higher voltage change.
Change of the ancient 7805 to a lower power, lower drop LDO like LP2951, will buy more ms too.
The LP2951 also has a PGOOD pin, you can test to verify you did make the save in time.
The Switching regulator has a higher efficiency than the 7805 and gives you more backup time for the same capacitance. If possible, connect the diode to the main power input if it's below 28V (C1 has to be >16V then). This also has the benfit that you get reverse polarity protection for free.
But what happens if the power fails during a write sequence? Mightn't the FRAM/EEPROM contents be corrupted?
-Phil
Besides meteorite and lightning strikes and including Vogons destroying the Earth to make way for an intergalactic highway, there are millions of other things that can happen in this universe Phil .
So it is possible that just as the power is failing that the user jumps on the unit and changes a variable and how long will it take to write this information? On EEPROM around 5ms, on FRAM it's just like RAM, around 150ns.
EDIT: even so, it is possible to handle power failure and EEPROM simply in software using redundant methods.
-Phil
If you anyway add a resistor you can add also 2 resistors and make a voltage divider to a Prop pin. So you need no brownout detector chip anymore.
With the 10k/1.8k resistors in the proposed circuit the Prop pin goes Low when the voltage at the 12V regulator is under ~ 9.3V.
Andy
-Phil