My long hand clock

Rebuilt as a wall clock I began another microcontroller project using the Picaxe. I wanted a clock that would look highly technical but present the time in a old fashioned way. My aim was to display the time as just "Quarter past ten" on an LCD screen and then to occasionally show one of a series of strange comments on life just to spice things up.

I remembered seeing a whole series of strange sayings on the old cinemas around Times Square New York in the mid 1990ís. The seemed to offer a comment on everything that was happening around them but no one seemed to know anything about them. I asked in the working cinemas, the shops but no-one knew anything about them - I eventually found a girl in the ticket office of a soft porn cinema who gave me the answer "itís an art project". I even wrote a story on the sayings I saw.

The circuit here shows from the left the serial interface resistors, the picaxe 18X, there is a little micro switch for altering the time, the clock chip, the backup battery and the eeprom chip. The large box on the right is the battery box and the 16x2 LCD screen rests on top of the wiring.



Step 1: Start simple
As with any project you have to break everything down into discrete stages that you can test separately. I began with my standard blinking LED circuit to ensure the Picaxe worked and that the PC could talk with it. Itís good to start with a success before confronting the complete unknown of the serial LCD! Luckily it worked first time - I must be learning something.

Step 2: The LCD screen
I then added a serial LCD screen and tried to get something to show up. I tried printing "hello world" but the display seemed to be showing Chinese. I guessed it was the serial connection speeds or parity (what ever that is) that need changing. I thought about trying to translate the documentation into an English that I could understand but in the end figured it would be easier to simply try every possibility and see what worked.

When in doubt use brute force!

It turned out the LCD required 9600 baud but the Picaxe only went up to 4800. Luckily you could double the clock frequency in software so you could simulate 9600 but of course every other timing code would get upset by the change. Next I had to work out how to send special commands to the LCD to clear the screen etc. I managed to do this but, in the process, turned the backlight on and itís stayed on ever since! Hopefully Iíll workout how to turn this off soon or Iíll need new batteries every other day.

Step 3: Adding the clock chip
The time bit was working fine I added the clock chip (a DS1307) and a backup battery and everything started to work quite quickly. I managed to get this far and get all the software to show the time correctly in one evening. This was massive progress compared to my last project. The time goes a bit weird when it gets to 13:00 - Iíd hoped it would stay to a 12 hour clock but this should be easy to fix. Backlight still on.




Step 4: Adding the memory chip
now showing some sayings It didnít take long to wire in the eeprom chip. The only problem is I canít seem to be able to read or write to it! The big problem with micro-controllers, when things don't work first time, is trying to work out what is causing the issue - is it a programming error, a wiring error, problems with changing the speed of the picaxe, problems on the i2c bus between the chips ... it goes on.

I started copying simple programs that would read and write to the eeprom chip and everything seemed fine. That ruled out a wiring problem. I tried expanding it so it could write messages to LCD and again seemed fine. Then tried reading the clock and it all went wrong. At least I knew where the problem was now, it seemed that if I was accessing 2 i2c chips on the same circuit then I needed to reinitialise each chip before accessing it otherwise it thought it was still accessing the last chip initialised.

A working clock
A message being displayed The clock was now working fine and I had about 20 messages stored on the system. I guess I could store around 60 messages without requiring a separate program to do the initialisation of the eeprom but seeing as the LCD only displays 32 characters then I guess there are probably only that many messages that will fit. I also need to add an adjust the time button to allow people to alter the time when the hour changes etc.

The big problem left is how to display this project - I felt it was better to keep all the insides on show rather than hide them in a box. It would contrast more with the old fashioned method of displaying the time. I imight add a small blinking LED to show that the system is working and to draw attention to the unit but I'm undecided at the moment. I'm also unsure how long the batteries will last with the LCD permanently running - I guess only time will tell. I did manage to turn the backlight off though!

The initialisation message The time bit was working fine

Wall clock
The battery life turned out to be poor as I was refreshing the screen far too often. I decided to redo the code using picaxe's new basic (it now has proper loops and if-then-else structures etc) which made everything much more readable. I'm now only redrawing the screen every 5 minutes which greatly extends the battery life. The desk clock is now a wall clock in it's own little frame and this works far better - it is less likely to get knocked around and is more likely to be seen by guests etc. I also managed to change the time adjustment method so it's now much easier to change the time. Maybe I'll build a clock with just bells next time?
an example of the time Rebuilt as a wall clock an example of the time

Useful links