Digital LCD Clock

By Brentton P.

Overview

In this Project I have designed a Digital Clock with a LCD Display. The clock features functions to save power, including a low power mode that saves power when the clock is unplugged from the wall and running on battery power. The clock is able to display time and date or temperature. There are functions to set the time and date, and set one alarm. The alarm comes with a snooze function. The top line of the display shows the current time and the bottom line shows wither the temperature (in °C) or the date in dd/mm/yy format.

Hardware

In the heart of this project is a SiLabs C8051F986 Microcontroller. We chose this because it has the perfect amount of pins for our project, and all of the required functionality. We use every pin, and one pin takes the input from 3 different buttons using the on-board ADC (Analogue-to-Digital Converter.)

Schematic Top view

The time is stored and the clock updating is all done by a RTC (Real Time Clock) which is a DS1337. And the Temperature is gotten from a Temperature sensor connected by a mouse cord. These two chips are used by the Microcontroller with an I2C interface.

The unit is powered by a 6.5V Wall Adapter and an on-board power regulator converts this down to 3.3V for all applications that require 3.3V. The unit can also run from two AAA batteries.

PCB bottom Sensor board

The display is an 8 Character X 2 Line Display. And has a back-light that we control with the microcontroller, to provide a dimmer function and to turn it off to conserve power.

Software

Every 10 ms we check the buttons current state. The alarm button (button 0) is hooked directly to a pin, while buttons 1-3 all share one connection. In order to tell what button is pressed we look at the voltage over that pin using an ADC. The ADC outputs a fraction value out of 255. We divide this range into 3 parts, and we only say that the one button whose value falls into is being pressed. We then use a set of 4 shift registers to debounce all 4 buttons. Once we figure out that a button has been pressed we jump to its handler procedure each button just changes a small amount of data in the chip then the device returns to checking buttons.

Every minute the device receives an interrupt from the RTC. This happens every minute when the seconds are reset to 0. We use this interrupt to update the time, and if the time is 12:00 midnight, we update the date too. Then we display the time if we are in idle mode or alarm set mode, and if we are in idle mode we display either date or temperature on the second line. This is also where we check if we have received a notification from the RTC that an alarm has occurred. If it has we turn on the buzzer and wait for either the alarm or snooze button to be pressed.

Downloads


Last modified:Mon, Jan 23, 2023.

00895