The real time
clock offers three things to this project. Generally my astronomy is
fitted in around other things so I like to track the time and this
allows a clock display on the screen. Secondly the DS1307 RTC chip has
the ability to generate a square wave out that is programmable.
Initially I will run this at 1hz ie one cycle high and low per second
and use it to trigger the clock update on the screen. Thirdly, to
accurately point the telescope you need to know the time. It is part of
the calculations.

This clock requres a watch
chrystal running at 32.768khz with a
capacitance of 12.5pf. This connects across X1 and X2. It
uses an I2C bus - SCL or clock and SDA or data lines. It also has
battery backup - add a 3 volt lithium cell to the Vbat pin. The SQW/Out
can be used as a square wave source at 1Hz, 4, 8 or 32khz.
These chips are widely available. If you have a picaxe reseller that
stocks the Revolution Education kits I believe that AXE034 clock
upgrade kit includes the DS1307, chrystal and the battery and holder.
However I bought mine piece meal so you should check with the reseller
that it includes everything. If not they might have the things you
require anyway.

All
three of the x series picaxes support I2C. You need to create an
I2C bus and then connect I2C devices to that bus. Using these devices
is then reasonably easy. All the hard work is done in the picaxe
firmware.
For ease of use, I expect over time to have lots of these devices, I
dedicated four strips along one edge of my vero board to +5v, 0v, SCLK
and SDA. Both have to be pulled high via a 4k7 pullup resister.
The SQW/OUT pin is a little harder to understand. It works by "sinking"
current ie current flows into the chip and is swallowed. So when the
pin is active it pulls the circuit low. You need a pullup resister to
make the circuit high when the pin isn't active. When I looked for the
value I saw all sorts of resisters in use - 180ohm, 1k, 4k7
and 10k - depending on specific use. People trying to use this as a
tick into a picaxe seem to use 10K so this is what I used.
Components:
| DS1307 |
| 8 pin socket |
| 32.768khz chrystal at 12.5pf |
| 2x 4k7 resister |
| 1x 10K resister |
| 3v Lithium battery |
| Battery holder |
| hookup wire, solder |
Here is the specific
schematic.
Testing
I finished the build and fired it up. All I got back from the chip in
the first test program was 0xFF for each value. I checked the
wiring over and over. I found that the two pullup resisters
for
the bus - the two 4k7s - were touching. I separated them and tried
again with the same result. Seems you get 0xFF for at least two reasons
- if the ch bit - bit seven of register 0 is 1 and if the bus
has
problems. CH is actually bit seven of the seconds register. Since
seconds were set to 0 this should be ok. I looked again and found the
real problem - a drop of solder at the other end of the board bridging
sda and scl. I Removed that and it worked perfectly. To avoid future
problems, I also moved one of the pullup resisters on the bus to ensure
it couldn't touch the other one.
I have included two test programs. I used these without the battery
installed. The
first program
sets the time and date and then reads it back in a loop. You will be
able to see the seconds change. The
second
programs the SQW/OUT pin and uses it to drive an interrupt routine.