DS1307 problems

captnemo

New Member
I was wondering if anyone out there if could give me a hand with this.
I connected a picaxe 18m2 to a DS1307 module. Downloaded the program and ended up with nothing but 255's in all the memory locations. I read somewhere in the forum that the DS1307 might not be working, if that happens, so I checked all the wiring and it looked fine. I tried two more DS107 modules thinking that maybe the modules were defective, so I went out and bought just the DS1307 chip and wired that in, with the same results 255 in all the b memory locations. So at this point I'm
thinking it's the program, even though I've tried several versions. The 18M2 talks to an EEPROM chip fine, so it can't be the communications pins.
I've the attached the program. For some reason the forum won't allow me, to attach a JPG picture of the circuit.
 

Attachments

papaof2

Senior Member
' Initialise the clock - IS YOUR SET DATA IN CORRECT BCD?


hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte ' set to 100kbps CONFIGURE PICAXE AS MASTER.
'hi2cout $0,(seconds,mins,hour,day,date,month,year) ' used to set time only

'NOW READ THE CLOCK

hi2cin $0,(seconds,mins,hour,day,date,month,year) ' read time DS1307 THIS IS BCD. CAN YOU CONVERT?

---------

This is code from a clock that has been running for years.
 

PhilHornby

Senior Member
I connected a picaxe 18m2 to a DS1307 module. ...
I tried two more DS107 modules thinking that maybe the modules were defective, so I went out and bought just the DS1307 chip...
This could be related to the Battery Backup components. The backup battery (if present) should supply between 2.0 and 3.5V on the Vbat pin (3).
Or, "If a backup supply is not required, Vbat must be grounded". See DS1307 datasheet.

On the TinyRTC modules found on eBay, extra circuitry has been added, to allow backup via a rechargeable cell. Since this would be outside the 2.0~3.5V range, there is a voltage divider. I don't know why this was ever thought necessary (given that a non-rechargeable cell can maintain the clock for 10 years). Recently, a complication has arisen around shipping rechargeable lithium batteries - and it may not actually be included...

If it is just omitted, the clock will not run. If a CR2032 is substituted, then at least R4 (1.5M) needs removing, else its voltage will be too low. Probably no bad idea to bridge R6 (470K) as well.
 

Jack Burns

New Member
My experience with the TinyRTC which PhilHornby has mentioned...

I had problems with the date and time being corrupted whenever the power was cycled, even though the on-board battery was well charged. On investigation, I discovered the DS1307 Vbat pin was momentarily dropping below 2 volts due to it being powered from the on-board voltage divider and this was causing the corruption. Adding a 4.7uF capacitor (all I had to hand at the time) at this point solved the problem. In the end I removed the on-board charge circuit and resistors forming the voltage divider and rewired it so I could use a standard CR2032 battery as shown in the DS1307 datasheet.
PROBLEM SOLVED.
 

captnemo

New Member
I gave up on the TinyRTC module and I'm simply using a DS1307 chip and an external crystal. I still have the 255 going into all the b registers.
Now that I think about it, the only thing in common with the TinyRTC and theDS1307 chip is the fact that I have to kill the power to the chip, then start the download, as the software say's it connecting I turn the power back on to the chip and the download commences. Could this be what's effecting the chip. I do this because the DS1307 chip or TinyRTC gets hung up in it's program and won't look at it's serial i2c pins while it's powered up.
 

captnemo

New Member
OK. I left the power on the chip and then downloaded and the problem of 255 in the b registers is gone. Apparently I was so used to cycling the power before a download on the TinyRTC that I did it with the stand alone DS1307 chip and it wasn't required. I think the TinyRTC may be more difficult to download to because it has that additional memory chip (sharing the i2c?) on board. Anyway, the problem now is some of the clock data coming back in not correct.

Unit programed: b register value
seconds $00 incrementing (seems ok)
minutes $59 incrementing (seems ok)
hours $11 18 (wrong)
day $03 3 (ok)
date $25 37 (wrong)
month $12 18 (wrong)
year $03 3 (ok)

I'll try papaof2 program and see what happens.
 

Jack Burns

New Member
Your values are actually correct, as the RTC is returning hex values (well actually BCD) but PE6 is showing them as decimal.
Just click the $ sign to the right of where it says Debug at the top of the variable list, then the values returned will be displayed as hex, which will match the RTC.

Edit:
I forgot to say the additional memory chip on the TinyRTC makes no difference when downloading your existing code, as you need to specify a different address when accessing the memory chip.

hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte ' RTC addressing

hi2csetup i2cmaster, %10100000, i2cslow, i2cword ' EEPROM addressing
 
Last edited:

captnemo

New Member
Ok. I got it working on the "stand alone" DS1307 chip. When I get some time I'll try it on the DS1307 module.
Attached is the working program with the conversion. Now what to use it on, clock, data logger?
Thanks for all the help guy's
 

Attachments

Top