My binary clock

finished item I'm having a play with microcontrollers at the moment. They are like tiny computers with basic interpreters and IO ports that are shrunk onto an integrated circuit. Iím using these Picaxe processors which are as cheep as chips (3 GBP) and are programmed with your PC in Basic (very basic basic). You can have up to 600 line programs controlling lights and motors or reading switches and voltages etc. If you ever fancied building a robot then these things are definitely the way forward.

I should warn you that you are now getting into the twilight zone between software and hardware where every bug could have a hundred causes. As an example my first circuit to blink a little LED refused to work at all. I checked every wire to make sure they went to the right places on the bread board. I tested each component to ensure resistors etc were correct. I checked each wire for breaks. I double checked the software but how many bugs would you expect in 5 lines. Everything seemed fine. Then I found the voltage wasn't getting to the circuit. I tested the batteries, I tested the wires from the battery box - everything was fine. I was about to take the battery box to bits to look for some internal break when I discovered a tiny microswitch marked on/off. You can guess what position it was in.

The aim
I figured the robot might be beyond me at the moment but figured I could build an unusual binary clock. The idea was to show the hours and minutes as binary numbers. The end picture would be built of squares of colour (a little like a painting by Rothko or Mondrian) and each square would pulse with light to signify the time. The aim would be to hang the picture on the wall and people could read the time from the pulses of light or just (hopefully) admire the picture.

Step 1:blinking an LED
One small step for man I started with the simplest circuit I could build a little picaxe 08 chip to turn an LED on and off. Even though the circuit and program were simple I still had the devils job getting this to work (see above). Once the circuit was correct I found that I still had bugs in the simple program - I hadn't set the pins to output in the software, I was using the wrong pin (easy to do as the hardware pins don't match the numbers of the software pins). Then when I added a switch to the circuit I didn't use a resistor to tie the input low but there was definitely a buz when that little LED started to blink.

Step 2: The 4 LED clock
4 led clock on picaxe 08 I tried to write my clock program using various delays for the timing and displaying the time using 4 LEDís to show the numbers 1 to 12 which would indicate where the hour and minute hands were pointing. The first problem was that the time needed to be reset every time I turned the circuit off and if I left it on for any length of time it soon became very inaccurate. The major problem was simply reading the time - to work out the minutes you need to convert the binary number to a decimal number of 0 -11, then you need to multiply by 5 to get how many minutes past each hour - I think I need a bigger brain just to read the time.

I decided to use a DS1307 clock chip in the circuit with a battery backup so it will always have the time and hopefully it should be accurate. I then figured it would be better to use 6 LEDís so we can read the minutes exactly without having to multiply by 5, this also means Iíll need the next size up of processor to drive the 6 LEDís and read a switch which allows you to alter the time and be able to communicate with the clock chip using the i2c interface.

Step 3: The 6 LED clock with a DS1307
6 led clock, picaxe 18X and DS1307 clock chip The i2c interface between the Picaxe and the clock chip caused me a few problems. It requires 2 lines from the Picaxe to be connected to the clock and they need to be tied high using resistors else nothing is read. It also turned out the clock chip needed the backup battery otherwise you couldnít set the time and of course I misread the manual as to how to wire up the battery. You also need to put in pauses into your code to give the various chips time to talk to each other. Luckily I found a good internet forum on Yahoo for using these chips and they helped me sort it all out

I could now read the time using the breadboard but I still needed to build the picture around it. I set to work trying to measure everything and trying various shapes and colours until I found something that looked please to the eye. It was quite difficult to get all the electronics into the picture (including the batteries) and still have space for the colour squares to be arranged naturally. Thereís also a trade off with how long to show the pulses of light for - too long and the batteries will quickly run out, too short and then you wonít have enough time to actually work out the time.

6 led clock with picaxe 18X and DS1307 chip finished item

Finished article
I've sort of finished the project now but as allways there are a few things left to sort out (perhaps next weekend). There is a bug when converting 24 hour time to 12 hour binary time and it appears around lunchtime - luckily I'm usually eating my lunch so I've only just noticed it. I need to add better and smaller switches and then fix the electronics firmly inside the frame so the picture stands flush to the wall. I should move the batteries to the other side of the frame to counterbalance the weight of the circuit. Most importantly though I need to use a better material than tissue papper as it does look a bit cheap when viewed close up.

I finally ended up fixing a clear but slightly opaque piece of plastic across the front of the picture. It allows people to see the wood and colours behind the sheet but hides the cheapness of the tissue paper and shoddiness of the design! Overall I'm very pleased with the end result as it looks and performs pretty much how I wanted it to when I designed it. There is a small niggly problem in that no-one else can read the time on the thing - I think it takes a special type of mind to be able to read binary on the fly and convert this to a time. Do I care? not really:)

A small movie clip of it working.

Useful links

Improvements Iíd like for the Picaxe compiler

Despite the above I must admit I love using these little processors - it makes the idea of building complex projects quite straight forward and fun.