My question is, I've been trying to add the RTC-1307 to my Nixie clock project. I have the clock running on a Nano and my redesign of the Arduinix driver board, I have designs several different Nixie display board that plug & play onto the driver.
It all seems to be working fine displaying Time, Date and a cathode poisoning prevention routine, but I want to add a RTC function so that the time is kept when the power is removed.
Can anyone help in adding the code for the RTC-1307 and which libraries do I need.
Can anyone help in adding the code for the RTC-1307 and which libraries do I need.
You need to go first. Which RTC do you have? How is it connected? Is it an I2C interface? A SPI interface? A serial interface? Or, something else? I2C is the most common.
I want to use a DS1307 using I2C does that help. And how can a RTC lose a few seconds a day!!! If so what's the point in using one?
Nothing is perfect in the real world, including the crystal and oscillator responsible for timing an RTC. Typical DS1307 RTCs will have 20-30ppm accuracy. Others (like the Maxim DS323x with TCXO) are better, but still not perfect. Generally more accuracy will correlate to more cost.
I want to use a DS1307 using I2C does that help. And how can a RTC lose a few seconds a day!!! If so what's the point in using one?
It's a real pain, for this reason I just got me a Sparkfun DS3234. It should lose only a few seconds per month, which is good enough for me. It uses SPI.
I would convert the code to use the Arduino Time library.
Get that working.
Then you can dd a synchronization routine to the Time library that will periodically
grab the time from the RTC chip using an RTC library and keep the time in sync with the time in the RTC.
You can then use a 1307 or DS3231/DS3232 library & corresponding module for the RTC.
The Time library has an example of how to do this.
I want to use a DS1307 using I2C does that help. And how can a RTC lose a few seconds a day!!! If so what's the point in using one?
It's more accurate than the arduino's clock and will retain the time if you loose power (assuming you have a battery.) If those aren't worth it to you then there is no point in using one.
If you need more accuracy, you can get more accurate clock chips, as others have mentioned. If you need more accuracy than those provide, get an Ethernet shield and sync with a clock server. You have to figure out how accurate you need to be and how much it's worth to you to increase the accuracy.
I had a DS1307 and I hated it. Something wrong with the battery and the chip knowing when to charge it. Thus it would always loose charge/time set. I spent weeks trying to get that thing to work. No I have a DS3231 and it works perfectly. Worth the extra $10 or so I think.
syphex,
It isn't really an issue with the 1307 chip. There are many i2c RTC modules out there on ebay
that were poorly designed. Many were designed for a rechargeable battery and then have
done a poor job on the charging circuit, this includes many of the DS3231 modules as well.
There are also a few designs that put a resistor on the clock crystal. This is really dumb
and needs to be removed.
You can fix them to work properly and use a standard 2032 battery.
For fixing the bogus charging circuit, it involves just cutting a single trace on the board.
In some cases it is two or three depending on the other issues with the particular module.
Its all pretty simple.
I have fixed both my 1307 and DS3231 modules.
I buy pre-built modules since you can get them for just a few dollars
including the 3231 modules and then simply fix them to work properly.
You can't build them yourself for what you buy them for on Ebay.
IME the chip is fine and works as designed, within it's limitations as discussed above.
I had a floating ground due to a cold solder joint that made mine work intermittently. I almost ditched it for a 3231 before I finally found the problem. (I probably would have been better off getting it in the first place and saving the time!) There were also some shipped by Sparkfun that had a short caused by the battery touching two solder connections.
My point is it doesn't matter how good a chip is, if the hardware around it is bad, it might as well be junk.