Saturday 22 December 2012

LED Clock Part 3 - Display Multiplexing

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Recently I've been looking at replacing the circuit in an old LED clock that finally gave up after 30 years faithful service. Previously, I've looked at a simple replacement and a teardown of the original clock.

Having now given up on CPC supplying the LED displays for the replacement circuit (I'm told they're due sometime in January), I've decided to look at reusing the original display. It's unusual as most LED displays these days are sealed units, where as this one has LED chips on a PCB with a white frame around that and a red diffuser on top.
You can just see the some of the segments are lit, they're just washed out by the camera flash. The method of driving is also unusual and is one of those circuits that I just don't think anyone would design like that these days.

Traditionally, you have two options to drive a 4x7 segment display, either directly drive each segment from an IO pin via a current limiting resistor, or multiplex the display digit by digit. The former option requires 4x7 = 28 IO pins and current limiting resistors and all segments are connected to ground. At 10mA per lit segment, it would use 280mA worse case. The later saves both pins and power, at the expense of more complicated software. The segments are all wired in parallel, but the grounds are switched per segment. So for example, although all the top bars (segment A) are driven from the same IO pin, only one of them will be switched to ground at any time. So the loop is:

  1. setup the output for the first digit, 
  2. turn the first digit on (the display now shows 1_:__) 
  3. wait a set time, 
  4. then turn off digit 1 
  5. setup for digit 2, 
  6. turn on digit 2 (the display now shows _2:__)
  7. wait...
  8. and so on
If you do this fast enough (usually > 50Hz), persistence of vision takes 1_:__, _2:__, __:3_ and __:_4 and merges them, so you see 12:34. This only need 4+7 = 11 IO pins, 7 with current limiting resistors for the segment anodes, and 4 with drive transistors to control the common cathodes. The power is also reduced as only one digit is ever on at a time, so the worst case is only 70mA.

The display on this clock was sort of an unorthodox mix of the two. Rather than 1 phase for each of the 4 digits, this has only 2 phases, each of which controls bits of each digit. There are no current limiting resistors as the IO pins of the TMS3450 are current limited at 18mA. The common cathode drive transistors are also missing as it makes use or a rather neat trick, but one as I said, I don't think anyone would come up with these days. What it does is use the ac from the transformer which already alternates at 50Hz, fed via diodes, so that on each cycle of the mains, one of the common cathodes sinks current as it's on the negative cycle. The other is on the positive cycle, so the diodes are reverse biased and therefore off. The flickering of the F segment on the hours I used to see occasionally must have been due the timing drifting slightly out and this being set before the phase cycle was complete.

I've slowed down the cycle. Here is phase 1:
And here is phase 2:
When switched fast enough, you get the combined result:
So, can I drive this from my microcontroller? Yes, it's just a case of providing 14 io pins for the segments and 2 drive transistors. I used MCP23008's for the segments, one for the hours and one for the minutes. The colon and the common cathode transistors were driven direct from the ATMega328P. I added a DS1307 real time clock, as per the simple version, and here it is, the slightly more complicated LED clock:
The next step is to build that up on veroboard and install it in the original case.

On to part 4, finishing the LED clock