Finding the correct size for a power backup capacitor was a bit more involved than I expected. Worst case is that the power is removed just as a clock tick has started. In that case we need to be able to finish the tick and then write the state of the clock to EEPROM with a checksum so we know if its valid or not.
First we have to determine how much current we need. From testing I found that a clicking the clock draws approx. 3ma for the duration of the tick, typically about 32ms. Then it takes 3.4ms per byte written to the EEPROM. We have 8 bytes, 2 for the clock position, and 2 for the clock tick and enable state so thats about 28ms. With the ATtiny85 active running with a 1mhz clock it draws about 0.5ma. So we need to last for a minimum of 65ms drawing an average of 2ma, using slightly rounded values.
Next we need to know the starting and ending voltages required from the capacitor. The Starting voltage is the highest voltage that the DS3231 will use for signaling a power loss, the data sheet says thats 2.45 volts. But we are charging the capacitor thru a schottky diode with a maximum voltage drop of 0.3 volts making our starting voltage 2.15. On the low side we need to know the maximum voltage that the brown out detection on the ATtiny85 will kick in. I have the fuses set to 1.8 volts and the data sheet says that it could kick in as high as 2.0 volts.
Then we can use a handy calculator here, plug in the starting and ending voltages and the current draw, and play with the capacitor value until we get a duration we like. To be conservative I'd like a value that is at least 2 times my computed value.
I've chosen 2200uf as even with a 20% its 1780uf and that will last ~ 133ms.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.