Start with a Concept
This was my goal. Create a clock that shows the time and day of week. My friend at work, Bob, had acquired some old 64 x 16 LED boards a renovation at the subway station. They are copyright 1985, which is the same time the subway system was built.
I also wanted the brightness of the screen to adapt to the room.
Create a Plan
This was the list of what needed to be done:
- Find out how to communicate with the LED board
- Determine how to keep time
- Create specification for both hardware and software
- Design a system and test it
- Make a clock
I looked up each part, and made a schematic of the system. I was then able to understand how to communicate to the board.
- Pins 2-4 (3 pins) chose which of 8 rows to control using binary decoders and transistors (2^3 = 8 options).
- Pin 5 chose which 8 rows would be controlled using a NAND gate (16 rows total).
- Pin 6 turned the chosen row on or off using the same NAND gate as pin 5.
- Pins 1 and 7 were used with shift registers and transistor arrays to load in 64 bits of data (for the 64 columns)
This is a simplified example of the communication structure with the LED board.
The communication process was then to turn the LEDs off, shift in 64 bits of data, pick a row, and turn the LEDs on. This then done for each of the 16 rows extremely fast to allow a visible screen of LEDs.
Clock speed error can be accounted for with a constant. Drift in clock error speed on the other hand can not. Clocks require very low drift, as even being 0.01% off over a year is almost an hour off in a year.
There were six options that I thought of looking into for this project:
Atomic clock – Just kidding.
Micro-controller internal oscillator – These are known to drift quite a bit.
External oscillator or RTC – After doing several week long tests, the drift for my Real Time Clock (RTC) was quite high. This could have been from using a cheap RTC (like $2.00 at DX). It may also have been from the 10ºC temperature changes in my house (too cheap to put on the heat at night).
Radio receiver for time – I did a bit of research on this once, and couldn’t find any time broadcasts that were in Vancouver.
Wireless receiver for time – This would be a project in itself.
Reading the mains AC line (60Hz) – I was opening up my bedside alarm clock in order to rewire the snooze button, and I decided to look into what it used for timekeeping. It turns out that the 60Hz line is wired directly to one of the pins. Wait, what? I did some research, and apparently the power station works really hard to maintain the correct number of pulses in a day. If the AC frequency is off for one day, they will compensate the next day. I did some tests and was satisfied with the result. I wasn’t planning on powering this with batteries anyway.
- The light sensor was something I wanted from the beginning, so that goes in.
- The input knob and input button are for editing time and brightness controls.
- I originally wanted to use an internal clock for running the programming, but the standard 8 MHz speed was not enough to keep all 16 rows on without flicker. A 16 MHz crystal was added to the spec.
- The AC line would provide power, and a timekeeping system via interrupt.
This gives a total requirement of 13 I/O.
I decided to wire up a connector that allows me to program my final product later. This allowed me to fix bugs, and give the board the ability for new purposes in the future.
This chart is a simplification of the actual code (posted here and poorly commented). I loaded the characters as arrays of shorts, because each 16 bit value corresponded to a column for the LED board.
The menu has 8 different pages:
- Edit seconds
- Edit minutes
- Edit hours
- Edit day
- Edit maximum display brightness
- Edit minimum display brightness
- Edit maximum measured light
- Edit minimum measured light
The software could then extrapolate the brightness to a user defined range. This made it possible to have constant brightness, alter brightness within a range, or even turn off below a threshold.
Finally Making the Clock
The clock ended up working pretty well. I tried doing a bit of a time lapse, but the light adjustment of my camera did not help show the dimming effectively.