The Funky Clock

We have a problem in our house.  The youngest has a habit of waking the whole house at a time that is not pleasing to the rest of us.  We put a clock in his room, but that didn’t help much because the monster child can’t read yet.

As with everything I decided a technological solution MUST be the best, so I present, the funky clock.
The dual colour LED array is from Sparkfun.  It is driven using two 74595 chips for the columns and a pair of ULQ2003 chips for the rows (because I didn’t have a ULM2008 chip).  The brain of the thing is a PIC18F4550 running my native code compiling forth which I control over USB.  I plan to produce a screen cast showing this in action at some stage.
I wanted to make the whole thing fit behind the display, so I was forced to put the processor and the LED driver hardware on their own boards.
The top of the processor board.
The bottom of the processor board.
The LED driver board.  I was really pleased with this one.  The 74595s are positioned so that they line up with the correct pins on the LED matrix so I didn’t need to run as many wires.  This meant that I had to rotate one of them 180 .
The bottom of the LED driver board.
The power board plugs into the processor board using the same connector as the PICkit 3.
All four parts of the clock fit together nicely πŸ™‚
I’ve set it up to display the hour in the main display area.  Blink the bottom left LED every second to let me know it is working, and display the minute in binary on the bottom row.  When it is bed time the hour is displayed in red, and when it is time to get up the hour is green.
I doubt it will make any difference, but I had fun making the funky clock πŸ™‚
It is amazing how easy it is to develop on the thing using forth on the actual hardware.

: CLOCK-TASK ( -- )
    HOURS C@ RED-TIME IF
	HOUR-PATTERN RED-LEDS LEDS!
	BLANK-PATTERN GREEN-LEDS LEDS!
    ELSE
        HOUR-PATTERN GREEN-LEDS LEDS!
	BLANK-PATTERN RED-LEDS LEDS!
    THEN

    SECONDS C@ 1 AND IF
        7 GREEN C@ 80 OR  MINUTES C@ OR 7 GREEN C!
    ELSE
        7 GREEN C@ 7F AND MINUTES C@ OR 7 GREEN C!
    THEN
;

It was so much fun making a forth from scratch.  It is based very loosely on jonesforth in that it implements many of the same kernel words, however it differs in that it generates subroutine threaded code instead of being token threaded.  I have also implemented a very simple co-operative task switcher.  The above task is responsible for setting up the display.  I have two other tasks running, one that drives the LEDs and another that updates the time.  While these tasks are running I am also still able to interact with the forth system via the virtual serial port over USB.
I want to thank my Dad again for all his help with the hardware.

Join the Conversation

8 Comments

  1. Hi Bill,

    those look really cool! I want to make some boards for a real one at some stage. This one, while a lot of fun to make, is not as neat as I would like πŸ˜‰
    It seems to be working as intended however as the boy seems to be taking notice of the thing πŸ™‚

    Daniel

  2. Wow

    Another Forth programmer! – That is awesome – Have you seen flashforth (for the PIC 18F and DSPIC33 series parts – it is pretty neat.

    Are you interested in sharing your Forth implementation?

    Doug

  3. Hi Doug,

    I saw flashforth, from what I recall, the development has moved on to the DSPIC chips and the PIC18 side of things is no longer developed/maintained. While there were some things I liked about it, there were others that I didn’t, but mostly I wanted to see if I could get a forth going on the PIC myself πŸ˜‰
    As for releasing it, I am thinking about it. I have released a lot of stuff online over the years, so I probably will.

    Daniel

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.