A digital clock with a LED display should be designed for being powered from a wall power supply, as the display draws a lot of current. However, such clock needs a reset after every power outage if no backup battery is provided. Usually commercial clocks use a 9V backup battery. Such batteries take a lot of space and are relatively expensive. If the clock electronics works from 3-5V, a lot of battery energy is dissipating for nothing.
This clock uses a cheaper and much smaller CR2032 battery as a backup. It is based on a Texas Instruments MSP430F2101 16-bit microcontroller, which can be purchased just for $1.50. If the display is off, the microcontroller itself draws about 14 μA in average due to being kept in sleep mode for most of the time. The input voltage in the range 5 - 15V is converted into a 3.6V by a linear voltage regulator MIC5209-3.6. The average current drawn from an external power supply is about 35 mA, depending on the digits shown on the display.
Front view | Back view | |
Switching from a wall power supply to a battery and back is controlled by DS1836C 3.3/5V micro-manager IC manufactured by Maxim. As the power voltage drops below 3.1V (depends on R1 and R2) the output at pin NMI becomes 0 which forces Q1 to close and disconnect the display. This process is completed within 1 μsec. As the voltage keeps falling below 2.8V, DS1836 switches to the backup battery in a 2 μsec. After the power outage the switching process is reversed: first the external power source is selected as primary one and after a 350 msec delay needed for this voltage to stabilize the output at pin RST becomes 3.5V which leads to turning the display on. This way it is guaranteed that the display is off when the circuit is powered from the battery.
It is important to keep in mind the following two features of DS1836. First, there is some voltage drop introduced by this IC, which depends on the current drawn from its output. The data-sheet specifies the maximum drop of 0.3V. In my case it is about 0.12V between the pins Vcc and Vout and close to 0 between Vbat and Vout due to a much smaller current consumed from the battery. Second, DS1836 has a non-zero operating current, which is about 29 μA in my case. When powered from a battery this exceeds the current drawing by the rest of the circuit in a factor of 2. Additionally, there is certain current through R1 and R2 even if no load is connected (to get rid of this current when the circuit is powered from battery, the upper end of R1 should be rather connected to pin 1 of DS1836). For the values specified on the schematic it is about 15 μA, resulting in total drawing no-load current of 44 μA. Therefore, the total average current consumption from the battery is about 58 μA. The selected backup battery is capable to power the clock for about 6 month non-stop. It is assumed that the power outages are rare and not for a very long time.
Schematic | PCB layout | |
The microcontroller is kept in sleep mode for most of the time and is activated by an interrupt provided by Timer_A. The timer runs from a watch crystal and requests interrupts every (1000/32768)·64 ≈ 1.95 msec. During the interrupt processing the microcontroller opens one of the switches Q2 - Q6 to lit one of 4 digits or the colon on the display. Hence, the display refresh frequency is 32768 / (5·64) = 102.4 Hz, which eliminates any digits flickering.
Upon counting 512 timer interrupts (which happens every second), the time represented internally is updated on 1 minute and the display is updated. To compute the time update the microcontroller is active for at most 172 μsec during each 1.95 msec interval, which leads to a low power consumption when powered from the battery. During this time it runs from internal DCO providing about 1 MHz clock frequency.
It order to set up time the button right ends (on schematic) are pulled up with internal resistors within the microcontroller. The button debouncing is accomplished by applying the shift register technique and this is the best approach that I have seen. The time is represented in 4 bytes, each stores a digit on the display. To increment time on 1 minute we first add 1 to the rightmost digit. If the result is below 10 the computations are over. Otherwise, we reset the rightmost digit to 0 and increment the next one. Similarly other digits on the display are updated, if needed. The digit value is used as an offset in the 7-segment code table to extract the corresponding code to be output to port 1.
Top view | Bottom view | Assembled PCB | ||
The clock is assembled on a one-sided PCB of size 76.2x43.2 mm. The bluish IC is the resistor network consisting of 7 isolated resistor of 150 Ohm each. The 7-pin connector right above the microcontroller (Sullins LPPB071NFSC-RC) is the JTAG interface with the programmer. The crystal is Abracon model ABS07-32.768KHZ-1-T, the buttons are C&K model KSC201GLFS. MOSFETS Q1 - Q6 are grouped in pairs in FDC6305N. The project box is Hammond 1591-A.
Last modified:Mon, Jan 23, 2023.