Tuesday, 4 December 2012

Word clock PCBs

These massive 16-pin 8x8 LED matrix modules are easy enough to work with - each row of LEDs has a common pin (so all 8 LEDs in a single row are potentially connected to the power supply) and you simply ground one of eight "column" pins to make the appropriate LED light up.



Although there are load of different driver chips for these display blocks, or we could use shift-registers and the like, we're going to do with the really simple direct-drive method. Basically this means choosing a microcontroller with loads of pins and connecting them directly to the pins on the LED matrix.

Word Clock Sch

To keep our final clock dimensions quite small, we're going to put the microcontroller on the back on the LEDs and use some IDE cable (which conveniently is 0.1" pitch spaced anyway) to connect the two boards:


Word Clock Pcb

Since these modules have a common anode, and you drive the appropriate pin(s) low to make the LEDs switch on, we've connected all the anodes on each "row" together. So each "row" output pin activates up to 16 LEDs at once.

This isn't an ideal way of driving these boards - using something like a Maxim MAX7219 constant current LED matrix driver would be better but two of those at a tenner each and the project starts to get a bit spend-y. Since we're only likely to actually light 3 or 4 LEDs (from a maximum of eight) at any one time, direct drive gives us a cheaper alternative to try out the design and check that everything works properly before committing to some rather expensive components.

We've gone for the PIC 16F877A chip, just because we've a few left over from years and years ago - they're the typical "starter" chip for people getting into PIC programming; loads of pins (it's a 40-pin DIP) and loads of peripherals (UART, SPI, I2C etc). It's probably a bit overkill, and there may be other, cheaper chips out there, but we're just using up what we've got.

We're going to be running the chip off a crystal and use this to keep time as well as provide the instruction clock cycle. We've some 4Mhz and some 20Mhz crystals knocking around - either will do. The idea is to keep an array of values representing the output state of each of the 16 vertical columns in the LED matrix. We'll create a timer interrupt every 1ms and use this for timekeeping (increase a seconds counter every second, when this rolls over to 60, increase a minute counter, when this rolls over to 60, incease an hours counter) as well as to drive the next column of LEDs.

By strobing all 16 columns once every millisecond, we're hoping to create an illusion of an always on display; depending on the results of this, we may strobe the columns every few milliseconds and try to find the optimum balance between the length of time each column remains lit and the "refresh rate": as each column stays on for longer, the LEDs may appear brighter, but the refresh rate (the number of times each column is "drawn" per second) reduces.