Multifunction Rechargeable Digital Clock

Abhishek Kumar is B.Tech in electronics and instrumentation. His interests include embedded systems, software programming and instrumentation

6092
Advertisement

We have used a current-limited load switch to prevent the USB application from fast draining the digital clock battery. However, it is optional. Capacitor C7 is used for stability of the current limiter.

For USB charging applications, a female USB-A type jack is used. It receives power from the 500mA, 5V current-limited channel of the power unit.

Main controller clock circuit. Circuit of the microcontroller-based main clock circuit is shown in Fig. 5. Apart from general time display, it also enables alarm function and indication of date, month, year and temperature.

Main microcontroller digital clock circuit
Fig. 5: Main microcontroller clock circuit

The circuit is built around ATmega8 (IC8) microcontroller. IC8 is used to update the display, sense user inputs and take decisions. ATmega8 has 8kB of in-system programmable Flash with read-while-write capabilities, 512 bytes of EEPROM, 1kB of SRAM, 23 general-purpose input/output (I/O) lines, 32 general-purpose working registers, three flexible timers/counters with compare modes, internal and external interrupts, a serial programmable USART, a byte-oriented two-wire serial interface, a 6-channel analogue-to-digital converter (ADC) with 10-bit accuracy, a programmable watchdog timer with internal oscillator, an SPI serial port and five software-selectable power-saving modes, which are sufficient enough for this application.

A separate in-circuit serial programming port (CON12) is available for programming the microcontroller. Time keeping is done by RTC chip BQ32000 (IC7), which provides an automatic backup supply using a 3V battery. IC BQ32000 has a programmable calibration adjustment from –63ppm to +126ppm, so that it can also be used with low-quality crystals. It includes automatic leap-year compensation as well. The RTC chip is connected to the microcontroller via the I2C bus. This project uses a 3V CR2032 lithium cell for the backup supply.

For the internal oscillator functioning, a 32.768kHz crystal is used at OSC0 and OSC1 pins of IC7. IRQ pin on the RTC chip is connected to ATmega8 on port pin PD2 and is also responsible for seconds indication through the two LEDs (LED7 and LED8) that are located between the two 7-segment display pairs. Anodes of the two coloured LEDs (in parallel) are connected to IRQ pin, while the cathode is connected to ground on CON13. Three momentary push-to-on switches (S4 through S6) are connected to pins PD3, PC1 and PC2 of IC8, respectively.

Analogue temperature sensor LM35 (IC9) is used for room temperature sensing. The analogue signal output of IC LM35 is proportional to the temperature by the relationship 10mV/degree Celsius. It is interfaced to the ADC of the microcontroller. The sensor is connected to the ADC channel 3 (PC3) on ATmega8.

For display, four multiplexed common-cathode 7-segment displays (DIS1 through DIS4) are connected via CON10. Their individual cathode pins are connected to CON11, and driven by transistors T2 through T5. The RGB1 LED is connected to PB3, PB4 and PB5 pins of IC8. The active-low RESET pin on ATmega8 is pulled up by a 10-kilo-ohm resistor (R31) and also tied to a 10µF electrolytic capacitor (C12) to prevent the controller from regenerative resetting during supply transients. AVREF pin, reference in/out pin for the ADC, is tied to a 100nF ceramic capacitor (C13) for stability, while AVCC (pin 20) and AGND (pin 22) are power supply pins for the ADC circuitry on the microcontroller. VCC (7) and GND (8) are power pins for the rest of the circuitry on the microcontroller.

You need not connect any crystal to the microcontroller as its internal 1MHz R-C oscillator is used here. So it is important to set correct fuse bits on ATmega8 to configure it for the 1MHz internal R-C oscillator.

TPS73733 LDO IC (IC6) is used to power the clock circuit. It gets input from non-current-limited 5.2V rail of the power section. TPS73733 is a 3.3V, 1A regulator with a maximum input voltage of 5.5 volts. EN pin is used to enable the LDO, however here we have tied it directly to IN pin for continuous operation. Capacitors C8 through C11 are used for stability of the LDO. An external capacitor (C9) connected to NR/FB pin on the LDO bypasses noise generated by the internal bandgap, reducing LDO output noise to very low levels.

7-segment display unit. Circuit of the multiplexed 7-segment display unit is shown in Fig. 6.

 7-segment display unit
Fig. 6: 7-segment display unit

It comprises four 7-segment displays arranged in pairs of two: one pair (DIS1 and DIS2) on the left side to display variables like hours and date, and the other pair (DIS3 and DIS4) on the right side to display variables like minutes and month. CON14 through CON16 in the display unit are connected to display driving ports CON10, CON11 and CON13, respectively, in the main clock section (Fig. 5).

Software

The code for the ATmega8 microcontroller is written in BASIC language using BASCOM-AVR compiler. After initiating the code, allocate default values to the EEPROM from location one to four. The EEPROM is basically used to hold the user-settable alarm values. Starting from the first location, it holds alarm hours, then alarm minutes, then alarm PM and finally the alarm flag (which indicates whether alarm is on or not).

Advertisement


SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here