THE P-COMP LAB CLOCK
It was about time someone thought about putting a clock in the P comp lab...
here's the description of the project:
November 1, 2006
Robert Faludi
Leif Mangelsen
Benedetta Piantella Simeonidis
PROJECT DESCRIPTION
Our project is a clock for the physical computing lab that can be read from a distance. The clock will display the hour, minute and seconds, along with the day, month and year, if practical. This clock will run on a DS1307 real-time clock chip that can retain the time of day even when the rest of the project is powered off.
The time will be displayed on a 28 x 40 dot matrix LED display sized about 12" by 9". Every four 5x7 LED displays will be driven by a MAX6953 driver chip, which in turn will be controlled by a PIC18F2520. Animations will be loaded on a SD Card or from a computer.
We would like to intersperse the time of day display with dynamic animations. If there's time we'd also like to describe a protocol by which others could upload their own animations to the display.
The clock will contain a unique time-sharing feature. It will broadcast a time signal to the entire ITP floor, using an inexpensive ZigBee radio. The time of day will be available to any project that uses ZigBee. For example any project that needs to behave differently during the night can know when evening comes. Projects that need to perform actions on an hourly basis will be able to take advantage of the time signal to stay on schedule. Any project needing synchronized actions between disconnected objects could use time of day to link actions together. None of these objects would need to be continuously powered on, or need local code or real time clock. All that would be required is a ZigBee radio attached to its serial port, something that many projects already include this semester.
Inspired by the Sparkfun Huge Seven Segment clock.

Here is the basic module for Seven Segment LEDs:

A closer view:

A detail:

This is the LED matrixes that we are using as digits:

A better look:

And here's the Zigbee clock with exact time:

And some fun video:
Download file
Here's some unpolished piece of code for the MAXIM 719'
' This Program demonstrates the basic functions of the MAX7219
'
Include "Modedefs.bas"
' ** Set Xtal Value in Mhz **
Define OSC 4 ' Set Xtal Frequency
i VAR byte 'for loop counter
' ** Declare Pins Used **
Clk Var PortC.4 ' Data is clocked on rising edge of this pin
Din Var PortC.3 ' Bits are shifted out of this pin
Load Var PortC.2 ' Transfers data to LEDs when Pulsed
' ** Declare Constants **
Decode_Reg Con 9 ' Decode register, a 1 turns on BCD decoding for each digit.
Lum_Reg Con 10 ' Intensity register.
Scan_Reg Con 11 ' Scan-limit register.
Switch_Reg Con 12 ' On/Off Register.
Test_Reg Con 15 ' Test mode register (all digits on, 100% bright)
' Max_Digit Con 5 ' Amount of LED Displays being used.
' ** Declare Variables **
Counter Var Word ' Variable used for the Counting routine
Max_Disp Var Word ' 16 bit value to be displayed by the MAX7219
Register Var Byte ' Pointer to the Internal Registers of the MAX7219
Value Var Byte ' Data placed in Each Register
Digit Var Byte ' Position of individual numbers within MAX_Disp (0-3)
Position Var Byte ' Position of each LED display (1-4)
LEDpin VAR PORTB.7
b var byte
GOSUB blinkie 'blink led
' ** Initialize the MAX7219 **
' Each register address is sent along with its setting data,
' because the MAX7219 expects to see a packet of 16 bits, then the LOAD pin is pulsed
' First set the scan limit to 3 (4 digits, numbered 0-3)
' then set the Brightness to 5
' BCD decoding to all digits (just in case more displays are added later)
' Turn Off test mode
' Switch the display on.
Register=Scan_Reg ' Point to the Scan Register
Value=2 ' send 3, (Four LED Displays 0-3) lk sent a 2 10-30-06
Gosub Transfer ' Transfer this 16-bit Word to the MAX7219
Register=Lum_Reg ' Point to the Luminance Register
Value=3 ' Send 5, (Value for Brightness)
Gosub Transfer ' Transfer this 16-bit Word to the MAX7219
Register=Decode_Reg ' Point to BCD Decode Register
Value=%11111111 ' Decode all the digits (just in case more are added later)
Gosub Transfer ' Transfer this 16-bit Word to the MAX7219
Register=Test_Reg ' Point to the Test Register
Value=0 ' Reset to Zero, (turns off Test mode)
Gosub Transfer ' Transfer this 16-bit Word to the MAX7219
Register=Switch_Reg ' Point to the Switch Register
Value=1 ' Set to One, (switches the display ON)
Gosub Transfer ' Transfer this 16-bit Word to the MAX7219
' ***** MAIN PROGRAM *****
' This loop, increments, and then decrements a 16-bit number held in "COUNTER"
' And displays it on Four led Displays
' The value to be displayed is placed in the variable "MAX_DISP"
counter = 0
main:
'For Counter=1 to 999 ' Increment Counter
' Max_Disp=Counter ' Load Max_Disp with Value of Counter
' Gosub Display ' Display the Value of Counter
' Pause 50 ' Delay, so we can see whats happening
'Next ' Close the Loop
'For Counter=999 to 1 step -1 ' Decrement Counter
' Max_Disp=Counter ' Load Max_Disp with Value of Counter
' Gosub Display ' Display the Value of Counter
' Pause 50 ' Delay, so we can see whats happening
'Next ' Close the Loop
Counter = counter + 1
if Counter > 999 then
Counter = 0
ENDif
for i = 1 to 3
Value = Counter DiG (i-1)
Register = i
'Value = i
goSUB transfer
pause 50
next i
Goto main ' Do it Indefinately
' ** Subroutines **
' Display the Value held in the Variable "Max_Disp" on the four LED's
' With zero supression
Display:
Digit=0 ' Start at Digit 0 of Max_Disp Variable
For Position=2 to 0 step -1 ' Start at Farthest Right led Display
Register=Position ' Place the Position into Register
Value=Max_Disp Dig Digit ' Extract the individual numbers from Max_Disp
If Max_Disp<10 and Position=2 then Value=15 ' Zero Suppression for the second digit
If Max_Disp<100 and Position=1 then Value=15 ' Zero Suppression for the Third digit
If Max_Disp<1000 and Position=0 then Value=15 ' Zero Suppression for the Forth digit
If Max_Disp<10000 and Position=4 then Value=15 ' Zero Suppression for the Fifth digit
Gosub Transfer ' Transfer the 16-bit Word to the MAX7219
'If Digit>=2 then Digit=0 ' We only need the first four digits
Digit=Digit+1 ' Point to next Digit within Max_Disp
Next Position ' Close the Loop
Return ' Exit from subroutine
' Send a 16-bit word to the MAX7219 and then pulse the Load pin
Transfer:
Shiftout Din,Clk,msbfirst,[Register,Value] ' Shift Out the Register first, then the data
High Load ' The data is now acted upon
@ Nop
@ Nop ' A small delay to ensure correct clocking times
Low Load ' Disable the MAX7219
Return ' Exit from Subroutine
blinkie:
For b = 0 to 3
HIGH LEDpin
pause 250
Low LEDpin
pause 250
next b
RETURN
And here's the link to The Zigbee code for the Clock:
http://itp.nyu.edu/~raf275/blog/archives/2006/10/zigbee_clock.html