Programmers and embedded circuit designers know that decimal is not the preferred number system for digital devices. Binary, octal, and hexadecimal numbers rule the day, so they’re comfortable using strange number systems. Clocks are essentially duodecimal, or base-12, devices. Devlin Gualtieri designed a two-digit clock that only an engineer would love (and know how to read).
In Circuit Cellar 294, Gualtieri writes:
Digital timekeeping has supplanted mechanical timekeeping not simply because it’s usually more accurate, but because it’s inexpensive. Digital alarm clocks are available everywhere for about $10. You can build the clock in this article for a few dollars more, but with a larger share of satisfaction.
Many years ago, I started designing with Microchip Technology PIC microcontrollers. Since I now have the necessary tools for PIC development, it would be hard for me to change. Fortunately, there’s no reason for change, since PIC microcontrollers are adequate for most embedded designs, and they’re quite inexpensive. This design uses the PIC16F630 microcontroller.
PIC microcontrollers have a built-in oscillator with about a percent accuracy, which is reasonable for many embedded applications. This accuracy comes from digitally trimming an internal resistor-capacitor oscillator on the chip. One percent accuracy is not adequate for a clock, since that would be a quarter of an hour’s error each day.
It is possible to use an inexpensive 32.768-kHz tuning fork crystal with a PIC. This frequency is useful for clocks, since a power of two will divide this frequency to 1 Hz. However, this slow clock rate prevents rapid computation and some useful functionality, so I didn’t use such a crystal in this circuit. Instead, I used a half-sized 10.000-MHz TTL canned oscillator. Canned oscillators are easy to use, highly accurate, and not too expensive.
Seven-segment LED displays are common circuit items, and this clock has a two-digit LED display. One digit is for hours, and the other digit is for the twelfth fraction of the hour. It’s straightforward to display the numbers, zero through nine, on a seven-segment display, but 10, 11, and 12 pose a slight problem. The problem of the twelfth hour disappears when we use zero for that digit. This convention is familiar to most technical people.
In the hexadecimal convention, 10 is represented by an “A,” and 11 is represented by a “B.” A capital letter “A” is easy to show on a seven-segment display, but a capital letter “B” looks just like an eight. As a compromise, we could use a lowercase “b,” instead.
We could also use a capital “E,” for 11, but having an “E” follow an “A” disturbs my hexadecimal sensibility. Although I’m not dyslexic, when I see a “b” on a seven-segment display, I think “six.” Another common notation, which I learned in my elementary school “new math” courses, is to use “t” for 10 and “e” for 11. Figure 1 shows possible number representations for ten and eleven, including the ones I chose for this clock.
Gualtieri goes on to describe the circuitry.
One way to minimize I/O pin count in a microcontroller circuit is to use multiplexing whenever possible. If we were to drive each seven-segment display and their decimal points individually, we would need 16 output pins. If we multiplex, we need just nine; that is, eight for the segments and decimal point, and one extra for the digit select.
The segments on the displays need a reasonably high current, and they also need about 4.5 V drive. That’s because they’re 1″ displays with two LEDs connected in series for each segment. For this reason, the display chips are driven from a 12-V supply, and the microcontroller interfaces with two 7406 TTL open-collector inverter/driver chips. Green displays were used, but other colors are available.
Digit select is easily accomplished with two transistors, also driven by sections of a 7406. The 5-V power for the PIC microcontroller and the clock oscillator is derived from a voltage regulator powered by the 12-V supply. A 12-V “wall wart” is a safe and convenient way to power this circuit, which is shown in Figure 2. The maximum current draw for my circuit was 250 mA. The circuit has two buttons for setting the clock by ramping the digits up or down.
The nearby photo shows the the clock mounted in a custom case. You can see an AM/PM dot and the seconds flashing dot. The time setting buttons are mounted at the rear of the enclosure, but you could place them anywhere. A green filter increases the digit contrast.
The complete article appears in Circuit Cellar 294 (January 2015).Become a Sponsor