Daniel Parnell's Stuff

Somewhere where I can muse about the things that interest me

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.
8 comments

8 Comments so far

  1. "Dad" December 20th, 2010 10:10 pm

    Well done Daniel :)
    It looks good!
    Now to do “real” PCBs.

  2. daniel December 21st, 2010 12:06 am

    Yes indeed. The elder child has announced she wants one!

  3. [...] time each morning. The problem is the kid doesn’t know how to read a clock, so [Daniel] built him a clock. Yeah, doesn’t make much sense to us either, but we’ve used our own shaky premises for [...]

  4. Bill Porter December 22nd, 2010 11:11 am

    Daniel,

    I’m working on something that might interest you. It’s a cheap LED matrix backpack that is ‘chain-able’ to any length.

    http://www.billporter.info/arduquee-an-arduino-powered-marquee-design-log/

    But yours is definitely awesome, it shows the amount of work (and love) that when into it.

  5. daniel December 22nd, 2010 3:45 pm

    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

  6. Doug Jackson December 23rd, 2010 2:42 am

    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

  7. daniel December 23rd, 2010 2:57 am

    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

  8. [...] LED matrix clock - [Link] Tags: 18F4550, 74595, PIC 18F4550, ULQ2003 Filed in Led | 1 views No Comments [...]

Leave a reply