Digital clock

Hi everybody,

Today I will show you, how I built my digital clock. Many years ago, when I didn’t know what the microcontroller is, and in the secondary school we learned about TTL logics, I couldn’t imagine how to build, for example a digital clock. Now I already have one 🙂

The hardware

It is based on a reused 3 and 3/4 digit, red LED display from an old, damaged digital clock. It has a type printed on it: FTTL 655S. It was originally driven dy an NLE2062 IC. I think this type is very common in the low quality/price alarm digital clocks, so you can easily find one usable display. So I desoldered it and started to find out the internal setup of the LEDs. Finally I found a pdf about a clock kit, and there was the same type of display.

The structure is not so understandable at first. The main thing is that, it has two common cathode, and many common anode, which are connected to two LEDs, one-one with the cathodes. So we will need to multiplex the displaying with the two cathodes, and remembering that, the anodes are controlling different segments when the other cathode is used. For the clock I needed 27 segments (3×7 for the full digits, and 6 for the first) in 24 hour mode, and the blinking colon. If we look at the schematic of the display, we count 15 anode pins for these 28 led segments. Ok, 15 pins on the controller. We need two more for the cathodes. The sum is 17. The atmega8 has 22 programmable IO pin, if we don’t count the RESET pin and using internal clock source. For the proper time, I wanted to use some kind of RTC (Read Time Clock) IC. The choice was the Dallas’s DS1307. It can handle two VCC, ideal for battery backup and it uses I²C. Because there are five free pins after the segments, and I²C costs other two, there are 3 more. I used two for buttons (hour and minute adjusting).

The software

The last difficult thing was the software. There were too many entities about the segments’ place and the numbers… So I made two different group.

First is the characters look, what I wanted to use. It has no connection with the digits on the display, it just describes the lighting segments of a digit. I’ve put the data in an array:

I made hexa letters as well.

The second thing is the connection between the segments physical (which digit’s which segment is it) and logical place (which cathode and which AVR pin is connected to it). Then to handle the segments differently, they has to got some ID, practically a number. So I added a number to all the physical segments:

Now I could index an array by these numbers, and the array itself stored the logical properties of the segment, such as:

  • the port on the AVR (2 bits to indicate PORTB,C or D)
  • the pin of the port (3 bits to indicate the PIN 0-7)
  • the cathode ID (1 bit: 0 or 1)

That is 6 bits at all, so one byte is enough. So I soldered the pieces together and I didn’t have to mind the exact IO pin for each segment, because I will map them by this array… I just left the I²C and two pins for the cathodes free, then just soldered the anodes in randomly (also the colon). After it, I wrote a program which was set one bit on one PORT to true, and by pressing the button it changed to an other (one cathode was turned on as well of course). By this, I could identify all the LEDs place, cathode and the PORTs connection. I made tables of the pins and the segment ID relations, two for the two cathodes. Based on this, I could make the character array:

Based on this array, I could draw the schematic:

Now we need only the algorithm to draw different characters on different digits. We need to change the used cathode periodically, so we will draw the half of the ‘frame’ at once (for this, a timer interrupt was used, to keep the period time). An other thing is to find a segment. Because they have ID, and they are in logical order, we know that the first digits ‘a’ segment the 0th, the second’s is the 7th, the ‘g’ of the last digit is the last (27th) and so on.

Other tasks of the AVR:

  • reading the time on the i2c bus is the only task of the main() function
  • to modify the time with the buttons, I used the two external interrupt pins, INT0 and INT1
  • a little fun stuff was implemented into it, to make my clock different :). This is a little animation when the minute is changing. The display fills up from the top, then become empty before the changed time appears.

Some pictures of the result:

Here are the code and the schematic

Here is the binary hex if you don’t want to compile the project. AVR clock speed shall be set to 8MHz.


Comment Pages

There are 9 Comments to "Digital clock"

  • Joao says:

    Amazing. I was looking for some information on the fttl 655. I don’t know much about electronics and obviously I couldn’t make this display work properly. I’m trying to build a kitchen timer with this display and a scroll wheel from a used computer mouse. Your post helped me to get a little bit forward. Thank you.

  • martin says:

    Thank you man! My digital clock is broken and Im going to use a display. This helped me a much. Really many thanks!

  • Nichol says:

    I am truly thankful to the owner of this site who has shared this
    impressive paragraph at at this place.

  • Best Wishes says:

    I have one of these and I kept looking at it hoping that I would eventually see a pattern but no! I appreciate your clever solution.
    Here is food for thought, looking at the NTE2062, they manage it using only 14 pins!

  • Valentin says:

    Hello! Can you post the code in hex format and fuses values for uC? Thank you in advance.

    • libesz says:

      I’ve added the downloadable hex to the end of the post. The fuses shall be in somewhat the factory state (internal clock, 8MHz, nothing specific).

  • Jake says:

    New to electronics can you point me in the right direction to figure out how to get this wired to a Arduino?

    • libesz says:

      It depends on the arduino board what you are using. I think if you use one with the ATmega328, it will be pin compatible with whih I used. Note you have to recompile the code for it. So it will have all the pins available through the headers of the Arduino board. Or if not, another option might be to use the Arduino board to program the MCU and (if it is DIP packaged) then pull out the AVR and wire directly to the display without the Arduino board itself. Hope this helps!

Cancel Reply

Write a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">