aramok

aramok

Wednesday, May 14, 2014

CLACK



 Code HERE

I have wanted to build a clock from scratch for some time now. Building a digital clock is not terribly original even if it has original features, but as an Electrical Engineering student I felt the challenge would flex muscles in areas of display control, multiplexing, product design and programming. There are all kinds on silly, nutty, or future rich clocks made by makers all around the world, I see at least one new time keeping device on the web each day. This is my approach. Its flagship feature is an ancient LED display, made up of sixteen Hewlett Packard "Numeric Indicators" (1990-0330, similar to the 5082-7300 in this datasheet). Each has 8 pins; Vcc, GND, Enable, 1, 2, 4, 8, and Decimal Point. They have built in decoders, so the number you want to display can be selected by setting the parallel binary input pins HIGH or LOW, and toggling the "enable" pin LOW to except input, and setting it HIGH again to hold the number.

These little guys get HOT, almost too hot to hold your finger to. LED's? Hot? After some digging around I found an HP Journal from 1969 Describing these "Numeric Indicators" in detail. The LED as we know it was only invented 7 years prior. They are not the efficient LED's of today, 16 indicators consume 1125mA@4.7V (The thing loads down the 5v rail on my computers PSU). Turns out they go for about 15$ a piece but I acquired them from e-waste along with a load of 74 series logic chips. Somebody many years ago was planning on building a calculator I think.

To select which indicator to enable to except input, I use two shift registers. Shift Registers are a very useful IC in EE's arsenal for controlling many things (arrays of LED's, buttons, and other ins and outs) with only a few pins from a micro-controller. I can serially output a number like 1111,1111,1011,1111 (65471) into the two registers (which act like one 16bit register once two are connected in series) in order to select the 10th indicator. Then I can display my number, say 5, by applying [1,0,1,0] to the pins [1,2,4,8] of all 16 indicators, knowing only the 10th will change.

The format of the time display is,  YYYY MM DD   HH mm SS.ss (60.00 seconds has Deci' and Centi' seconds). The time keeping is done by a Real Time Clock board based on the DS3231 by Maxim, it has a high precision crystal with temperature compensation, a backup battery, and registers that can be polled by an I2C connection. The registers have all the year, month, ect., stored as their normal values and are compensated for leap year, and so forth, which makes programing a cinch. Time formatting can be a programers nightmare if done from scratch.

The RTC module dose not, however, report any unit of time smaller than a second. I needed to create a centisecond timer that would run between each second. [[go to paragraph 7 to skip problematic efforts]] Originally I wrote the Arduino's main loop so that the RTC was repeatedly polled as quickly as the Arduino could, and when the seconds place changed, the Arduino would start a timer from 00 - 99 to display centiseconds. The timer was based on an interrupt where every 100th of a second (based off the Arduino's crystal) the interrupt would interrupt the main loop and display the next 100th of a second. This would cause the main display to flicker annoyingly as the display update would be interrupted 100 times a second.

In an attempt to remedy this, I flipped it round. I had the interrupt fire once every second, poll the RTC and start the centisecond counter. However the Arduino's definition of a second differs from the RTC's second, so every so often the seconds place would skip. Sometimes the arduino would poll the RTC right at the beginning of the RTC's second, and then again at the end of the RTCs second, because the Arduino's second as to fast. The seconds place would appear to show a second for two seconds and then skip a second ahead, about once a minute.

Thank you! The RTC module has a square wave output pin than can be configured to be many different frequency's. I wanted to use a 1Hz wave to tell the Arduino that a new time is ready to be read from the RTC. A certain register inside the RTC has to be written LOW to enable this 1Hz output. In my Arduino's loop, I set a check to see if the square wave has gone high every 100th of a second while the centisecond loops. The end result is a very smooth clock display. It bugs the hell out of me when software clocks don't update the seconds place EXACTLY on the second.

To finalize the design, the clock will be split into a two layer board were only the display will sit in front with all the components sandwiched behind it. A few buttons in the ol' "4 arrow keys an select" configuration will sit in back. They will be used to set time, alarms and a death clock. I hope you learned something about something from this project that will be of use to you!

1 comment:

  1. That is a cool project!
    Have you done a schematic for this that you can post here?
    I wanted to do something similar with 6 digits (hours, minutes, seconds) but I realised that I totally suck at programming, can you help me with a 'slimmed down' version of your program?

    Thanks for any help!

    ReplyDelete