Every digital clock has a crystal inside it to keep track of time. This crystal is not only present in the clock but also present in all computing real-time systems. This crystal generates clock pulses, which is needed for timing calculations. Although there are some other ways to get clock pulses for higher accuracy and frequency, but the most preferred way is to use crystal to keep track of time. Here we will DS3231 RTC IC to build an Atmega16 based Digital Wall Clock. DS3231 RTC has a highly accurate crystal inside it, so no external Crystal oscillator is needed.
In this Digital Clock Project, ten common anode 7-segment displays of 0.8-inch are used to display time and date. Here seven segment displays are used to show hour, minute, date, month and year. Our PCB design also has options to display seconds and temperature, which can be displayed by adding more display units.
- ATmega16 AVR Microcontroller
- DS3231 RTC IC
- Common anode 0.8 inch Seven Segment display (its bigger then common size display (0.56 inch)
- Push button
- Button cell 3v
- 7805 voltage regulator
- 1000uf Capacitor
- Buzzer (optional)
- Transistors BC547 and BC557
- 10uf Capacitor
- 100 Ohm resistor
- 1k resistor
- 10k resistor
- PCB Board
- Jumper wires
- Power supply adaptor
User may also use Atmega32 it need to be configured in compiler before generating hex.
Circuit Diagram and Explanation
There are two parts of this Digital Wall Clock Circuit, one is display part which has 5 pairs of 7-segments on five different PCB boards and another is controlled Unit part which is responsible for fetching time from RTC chip and send that data and time to 7-segment display. As we have used 10 seven segment displays so we cannot connect each display with a separate IO port. So here multiplexing technique is used to connect multiple seven segments using fewer pins of microcontroller.
LED pins a,b,c,d,e,f,g,h of seven segment display is connected to PORTB of atmega16 parallel. Here we have used 10 seven segment displays so we need 10 control pins which are connected at PORTD, PORTA and PORTC.
RTC DS3231 having an internal crystal is connected to PORTC’s SDA and SCL pin because this chip works on I2C communication. Interfacing method of this chip is the same as DS1307. We have used DS1307 with Arduino, Raspberry Pi and 8051 MCU. Same code can be used for both DS3231 and DS1307.
Two 10k pull-up resistors are connected on SDA and SCL line. A 3v coin cell is used to power the RTC chip to keep track of time even when the main power supply is off. Whenever power comes back again time will start displaying on seven segment display. Now we have some push buttons for setting time at PORT A, complete process is explained in the video given at the end. A 5v voltage regulator is used to convert input voltage to 5v. All the connections are shown in the circuit diagram below:
For one display board, two seven segment displays and 2 LED are used. So here we have five different display boards to display Time in Hours and minute (HH-MM), and date in DD-MM-YY.
PCB Design and fabrication for the Digital Clock
For this Atmega16 based wall clock project, we have designed two PCBs. One is for Control unit which is used to control all the operations of the project and second part is for displaying the time and date on seven segment displays. Display part contains five pairs of 0.8 inches seven segment display. So by assembling 5 pieces we have the complete Digital Clock. To multiplex 7-segment displays, Data line of the 5 PCBs will be connected to the same port of control unit and control line is connected different pin of the control unit.
Below are the top and bottom views of PCB layouts of one Display board which consists two seven segment displays:
Below are the top and bottom views of Control Unit PCBs
Here we are attached Gerber file for both the boards:
Ordering the PCB using PCBGoGo
There are many PCB fabrication services are available online, but as I used PCBGoGo previously in one of my other projects, I found it cheap and hassle-free as compared to other vendors.
Here are the steps to order PCB from PCBGoGo:
Step 1: Get into www.pcbgogo.com, sign up if this is your first time. Then, in the PCB Prototype tab enter the dimensions of your PCB, the number of layers and the number of PCB you require.
Step 2: Proceed by clicking on the Quote Now button. You will be taken to a page where to set few additional parameters if required like the material used track spacing etc. But mostly the default values will work fine. The only thing that we have to consider here is the price and time. As you can see the Build Time is only 2-3 days and it just costs only $5 for our PSB. You can then select a preferred shipping method based on your requirement.
Step 3: The final step is to upload the Gerber file and proceed with the payment. To make sure the process is smooth PCBGOGO verifies if your Gerber file is valid before proceeding with the payment. This way you can sure that your PCB is fabrication friendly and will reach you as committed.
Now PCBGoGo will take some time around 10 min to 1 Hour to review your Gerber file. After completion of the review, you can proceed with the payment.
Assembling the PCB
After the board was ordered, it reached me after some days though courier in a neatly labeled well packed box and like always the quality of the PCB was awesome. I am sharing few pictures of the boards below for you to judge.
I turned on my soldering rod and started assembling the Board. Since the Footprints, pads, vias and silkscreen are perfectly of the right shape and size I had no problem assembling the board. The board was ready in just 10 minutes from the time of unpacking the box.
Few pictures of the board after soldering are shown below.
Testing the Digital Clock
Complete code is given at the end of this tutorial, just connect the PCBs as shown in the circuit diagram and upload the code into Atmega16. And you will see time and date appearing on the ten Seven segments displays.
The time and date can be set using the four push button on the control unit as demonstrated in the video given below.