Top‎ > ‎Atmel AVR stuff‎ > ‎

The big numerical display project

UPDATE: Here's a video of the end result:

Ever since I've been 11 years old and got my first digital watch back in the 70's, I've been a big fan of LEDs (Light Emitting Diodes).

Mine didn't look like this one, but you get the idea:

Back then LEDs seemed magical to me.  They made light without heat, which was unheard of, unless you counted weak effects like bio-luminescence (fireflies), fluorescence (Black Light), and phosphorescence (Glow-in-the-Dark).  Anything other light source got warm and used a lot of power.  I had known only of filament or fluorescent lights previously.  These LED things made a cool red glow that fascinated me, and still does.  I always get new LED products as soon as they become available.  I remember when Green, Blue, White, Ultra-violet LEDs came out.  I have tons of LED gadgets, lasers, flashlights, etc...

Today, when I build electronic projects I always include an LED or a little LED numerical display to indicate some sort of status.  Even this parallel port temperature sensor has a one-digit display which is totally superfluous (sorry about the poor image quality):

That's a free-running 555 with a thermistor, if you're curious.

When I re-kindled my love of micro-controllers a month ago, I realized that a perfect project using them would be some sort of display.  I had wanted to make one with very specific requirements for some time.  The display had to:

  • Be somewhat large.  I live in a studio apartment so it has to be readable from a distance.
  • Only emit RED light.  Any other color goes right through your eyelids and prevents sleep.
  • Have a brightness adjustment with at least 4 settings, including a very bright one for sunny days and a very dim one for sleep time.
  • Not use multiplexing or pulse-width-modulation that cause flashing, at any frequency.  When I move my head, any light source that flashes on and off attracts my attention annoyingly.
  • Only consist of numerical digits.  I don't like pixel matrices, or alpha-numeric displays.  The old 7 segment displays appeal to me.
  • Be able to display time in 24 hour format including the seconds.  Tenths are a plus.  Hundredths are pushing it.  So the minimum is 8 digits: HH-MM-SS
  • Serve multiple purposes.  It should be able to display other useful information.
  • Have the simplest electronic interface possible so it can be re-used in other projects.  A two-wire (clock&data) is preferable.
  • Have an interface to a computer.  Serial interface seems best since parallel ones have all but become extinct.  USB serial dongles are still popular.
  • Be fun.
I ruminated these requirements for a few weeks (I always plan my projects for long periods.  Measure twice, cut once,) and went shopping for parts.  First are the digits:
I found these 2.76" x 1.89" (70.10mm x 48.01mm) Lumex displays at Digikey here.  They go for $10 each so I got 10.  The big surprise I got when I started fiddling with them was that each segment doesn't consist of a single LED:
Yikes! Four LEDs per segment!  I stupidly didn't consult the datasheet before buying them.  I had intended to drive the segments directly from 5 volts but these suckers don't even start to light up at 5V.  Hmmm!  Ok, I put this problem aside and considered next how to drive them.

I chose the good old 74HC164 serial-in, parallel-out shift register so that I could drive the segments directly (it can handle the load,) have a simple interface (clock&data), and daisy chain easily:
That makes the circuit very simple: Tie each output to a digit's segment through a resistor, assert one of the serial inputs to Vcc (+), Tie Clear to Vcc to prevent it, feed the data bits one by one to the other serial input while toggling the clock input.  Do this 8 times real quick and presto! Your digit appears.  To daisy chain the digits together is simple too: just tie all the clocks together and feed the H output of one digit to the next's serial input.  Each time the data is fed to the first digit and the clock is toggled, the bits scroll into the next digits.  Repeat 8 times multiplied by the number of digits and hey presto! Your whole display is updated.  If you do this quickly enough (at mega-hertz speeds), the eye can't discern the segments rolling, they just all change seemingly instantly.

Lastly I needed something to feed those segments bits quickly, so I chose an 8Mhz micro-controller, the Atmel 8-bit ATTINY44:
That micro-controller has four kilo-bytes of Flash for program space, 512 bytes of ram which sounds pitiful but is plenty.  I originally had the project running with an ATTINY85 with the same specs except that it has only 8 pins.  It worked fine but required unplugging for re-programming, so I went with the 14 pin package instead.  Doesn't matter, they're really cheap at $2.80 each.

I finally fiddled with a single digit for a while, trying different solutions for the higher voltage needed to drive the segments and found how to solve the problem: ignore it.  I simply fed the digits +9 volts at their common anode and had the 74HC164s drive the cathodes through 200 ohm resistors.  You'd think the 4 volts difference coming from the 9 volt supply would pull the high outputs of the 74HC164s, but that 4 volts is eliminated in the segment's diode normal voltage drop; that's part of the nature of diodes.

The circuit is so simple I didn't even draw a schematic.  PA0 is data, PA1 is clock, PA2 & PA3 drive two relays directly (they're rated for TTL, use only 25 milli-amps each and include a clamping diode) for brightness regulation.  The 9 volt supply goes to a 7805 5 volt supply regulator to feed the 74HC164s.  I actually put one in for each digit in case I wanted to break them apart later.  Heck, 7805s are cheap.  The 9 volt supply also goes through 3 little signal diodes which drop the voltage to the digits so that minimum brightness is achieved.  One relay shorts two diodes, the other shorts one giving the circuit four choices of brightness: 0, 1, 2, 3 diodes.  it works very well as you'll see.

Ok, so what does it look like?  First, let me apologize for the quality of the pictures.  I've got really good photo gear, but most of it is film, not digital.  So most of the pictures that follow are captured from a webcam in low-light.

Full flash of the display:

I've temporarily glued the digits together using tiny quantities of cyanoacrylate (Crazy Glue) and little tabs of plastic so they can be easily broken apart later to put them in a proper cabinet.

Without the flash:
The camera sees yellow but it's perfectly red in real life.

No light at all:

Back of the display:

Here you can see that I didn't even bother with perforated boards to hold the components.  The 74HC164s are held in pace because they're tugged-of-warred by the resistors, which are soldered to the digit modules' pins at the top and bottom.  The 7805s TO220 hanging down are held in place by a little dab of hot glue.  Notice that I didn't bother with the last two digits' 7805s.  If I ever break the digits I may not need them, so screw it!  :)

On the third module from the left, the micro-controller board is hot-glued in place.  You can see it has its own little LED which shows serial data activity from the computer interface.  There's a gray wire pair coming from the left which plugs into a connector (also hot glued) at the fourth module.  That's the 9 volt power.  On the fifth module you can see a black cable plugged into a connector, using a standard 1/4 jack; that's the serial line coming in from the computer.  Since it's a single wire thing, it only carries Ground and Data.  It's bi-directional though, see my other project.

Little close-up of the mcu board and a module:
From the left on the mcu board you can see two orange relays,  at top-left is a 5 pin socket header for re-programming the mcu.  The ATTINY44 mcu is sitting in a low-force socket.

I love those relays.  No need for power transistors to drive them, no need for clamping diodes (although I put two in anyway because I'm paranoid).

From here on out, I'm switching to a webcam in low-light conditions.

7-segment display are made to display numerical digits.  But with a bit of imagination, you can display letters too:
Here you see an MPlayer window over-lapped by an xterm window.  In the xterm I'm running "cu -l ttyUSB0 -s 19200" (that's like HyperTerminal) to talk to the micro-controller's firmware program.  You can see the menu of four visible options which are accessed by typing P, D, C, or N.  Here I'm going into the "Doodle" mode, where any character I type is echoed on the display.  You can see the first 10 characters of the alphabet.  Very readable.

For the next set of 10 characters, you have to use a bit of imagination:

The first letter-in-7-segment real problem appears with K.  Here it's represented by a T on its side.  The funny thing is that after reading a bunch of things on this display, I've gotten used to the funny way the letters appear.  So much so that I can read full speed, that tiny R doesn't bother me, neither does the the fact that S is a re-used 5 or that the T has survived a horrible accident in which he lost an arm. Alright, it's a seven.

The rest of the letters take a LOT of imagination:
There's that T again, followed by a U, small in order to differentiate from the following V.  Next, it gets real ugly. That small underlined U is supposed to be a W.  Just trust me.  Y's looking good!  Z is just another 2.

Punctuation? A few:
Here's an apostrophe in the middle of the word.  Oh well.

More imagination:
Oh well, those suffice for now.

Here's a couple of images to give you an idea of how large the whole thing is:
That's my big fat hand in front of the 480 mm X 70 mm (18.9' X 2.76')

Here's a comparison with a regular-sized radio alarm clock:

Here are the four brightness settings:

In absolute darkness, that last one is still very readable.

As you may have noticed, I'm using a daemon called "displayd" which communicates with the display.  From the command line, I can then use the program called "disp" to send displayd commands like DX to set the brightness, or Ttext to display text, and a few other doohickeys.

Did I mention that the firmware I wrote in the micro-controller also includes a game playable on a vt220 compatible terminal?
It's the old square-puzzle game where you have to move numbered squares with one replaced by a hole (black spot here.)  The number of moves is displayed on the terminal and the big display.

On the computer side, the displayd daemon displays the time as a default.  But any number of clients can connect to the daemon in order to display other information.  When they stop sending updates, the daemon reverts to the time.  Here's one that displays my current incoming network bandwith:
Current: 132 KB/s, total: 49 MB.

The fun part: I control the display using my TV remote control by way of the Linux Infra-Red Control (lirc) daemon.

It's an ongoing project, so I'm not finished writing a bunch of utilities for it.  When I'm satisfied I'll also post a schematic and all sources.

Danny Chouinard.