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.
Components Required
- 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
- Burgstips
- 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.
Comments
Hello friends, this is the…
Hello friends, this is the microcontroller hex file
:100000000C9434000C9451000C9451000C94510049
:100010000C9451000C9451000C9451000C9451001C
:100020000C94AD010C9451000C9451000C945100AF
:100030000C9451000C9451000C9451000C945100FC
:100040000C9451000C9451000C9451000C945100EC
:100050000C945100EF000201150128013B014E01F3
:100060006101740187019A0111241FBECFE5D4E01C
:10007000DEBFCDBF10E0A0E6B0E0E0EEF9E002C0E8
:1000800005900D92AC38B107D9F720E0ACE8B0E0AC
:1000900001C01D92A83AB207E1F70E9488040C94AF
:1000A000EE040C940000853091057CF4DF9825B3B4
:1000B000237025BB22B3237822BB22B3FC01E05A74
:1000C000FF4F8081822B82BB08958530910561F4BA
:1000D0009BB380916500892B8BBB85B3837085BBF7
:1000E00082B3837882BB08958F3F2FEF920741F44C
:1000F000DF9885B3837085BB82B3837882BB089514
:10010000DF9825B3237025BB22B3237822BB25B308
:10011000FC01E05AFF4F8081822B85BB089520911E
:10012000950030E02617370761F420918C002223D8
:1001300029F08FEF9FEF0E94530008950E94530013
:1001400008950E94530008958091A2009091A30009
:1001500001969093A3008093A2008091A2009091B9
:10016000A3008139914058F01092A3001092A20090
:1001700090918C0081E0911180E080938C008091BF
:100180009E0090919F00019690939F0080939E0007
:1001900080919E0090919F000E9720F010929F00FA
:1001A00010929E00E0919E00F0919F009F01A5ECAF
:1001B000BEE40E94CB0496958795969587954DE071
:1001C000489F9001499F300D1124E21BF30BEA3048
:1001D000F10508F0C1C0E65DFF4F0C94C5048091A5
:1001E0009E0090919F0062E070E00E948F00E0917D
:1001F0009800F0919900EE0FFF1FE858FF4F8081A3
:1002000088BB089580919E0090919F0062E070E00D
:100210000E948F00E0918F00F0919000EE0FFF1F81
:10022000E858FF4F808188BB089580919E0090918F
:100230009F0061E070E00E948F00E0919600F091D5
:100240009700EE0FFF1FE858FF4F808188BB08958D
:1002500080919E0090919F0061E070E00E948F006D
:10026000E091A600F091A700EE0FFF1FE858FF4FA6
:10027000808188BB089580919E0090919F0063E0EB
:1002800070E00E948F00E0919C00F0919D00EE0FC5
:10029000FF1FE858FF4F808188BB089580919E0022
:1002A00090919F0063E070E00E948F00E0919A00BF
:1002B000F0919B00EE0FFF1FE858FF4F808188BB35
:1002C000089580919E0090919F0064E070E00E94EC
:1002D0008F00E091A400F091A500EE0FFF1FE858F9
:1002E000FF4F808188BB089580919E0090919F0070
:1002F00064E070E00E948F00E0919300F091940020
:10030000EE0FFF1FE858FF4F808188BB0895809152
:100310009E0090919F0065E070E00E948F00E09148
:100320008D00F0918E00EE0FFF1FE858FF4F808187
:1003300088BB089580919E0090919F0065E070E0D9
:100340000E948F00E0919100F0919200EE0FFF1F4C
:10035000E858FF4F808188BB08951F920F920FB617
:100360000F9211242F933F934F935F936F937F933B
:100370008F939F93AF93BF93EF93FF930E94A4003B
:1003800080E09AEF9DBD8CBDFF91EF91BF91AF9141
:100390009F918F917F916F915F914F913F912F919D
:1003A0000F900FBE0F901F9018958EB582608EBD76
:1003B0008CE098EF9DBD8CBD89B7846089BF78942F
:1003C0000895282F22952F7030E0A901440F551F62
:1003D000220F331F220F331F220F331F240F351F0D
:1003E0008F70A901480F511DCA0108952DEC829FFD
:1003F000212D1124269526952695322F330F932FE4
:10040000990F990F930F891B90E030E1239F800D86
:10041000911D1124089584EA86BF06B607FEFDCF1C
:10042000089580ED83B984E886BF06B607FEFDCF48
:1004300013B884E886BF06B607FEFDCF089584EAA8
:1004400086BF06B607FEFDCF80ED83B984E886BF80
:1004500006B607FEFDCF13B884E886BF06B607FED2
:10046000FDCF84EA86BF06B607FEFDCF81ED83B9D6
:1004700084E886BF06B607FEFDCF089583B984E8F9
:1004800086BF06B607FEFDCF089583B984E886BF10
:1004900006B607FEFDCF089583B984E886BF06B689
:1004A00007FEFDCF089583B984E886BF06B607FE30
:1004B000FDCF089583B984E886BF06B607FEFDCF59
:1004C000089583B984E886BF06B607FEFDCF089578
:1004D00083B984E886BF06B607FEFDCF089586B7C8
:1004E000806C86BF06B607FEFDCF83B10E94E10196
:1004F000089586B7806886BF86B7806486BF06B6D3
:1005000007FEFDCF83B10E94E101089586B7806C9C
:1005100086BF06B607FEFDCF83B10E94E1010895B4
:1005200086B7806C86BF06B607FEFDCF83B10E94FA
:10053000E101089586B7806C86BF06B607FEFDCF41
:1005400083B10E94E101089586B7806C86BF06B62C
:1005500007FEFDCF83B10E94E101089586B7806850
:1005600086BF86B78F7B86BF06B607FEFDCF83B1F9
:100570000E94E10108950E940B020E94110280E096
:100580000E943E0280916E000E94F6010E94450288
:1005900080916C000E94F6010E944C0280917600CE
:1005A0000E94F6010E945302809174000E94F6019D
:1005B0000E945A02809172000E94F6010E9461021C
:1005C000809170000E94F6010E94680284E986BF53
:1005D00008950E941F020E946F029093A1008093D1
:1005E000A0000E94790290936F0080936E000E9499
:1005F000860290936D0080936C000E94900290930D
:100600007700809376000E949A0290937500809301
:1006100074000E94A40290937300809372000E9461
:10062000AE02909371008093700084E986BF0895B4
:1006300040916E0050916F009A01ADECBCEC0E94AD
:10064000CB049695879596958795969587959C0169
:10065000220F331F880F991F880F991F880F991F2A
:10066000820F931F9A01281B390B30939900209316
:1006700098009A010E94CB04969587959695879548
:10068000969587959093900080938F0040916C0091
:1006900050916D009A010E94CB049695879596958E
:1006A0008795969587959C01220F331F880F991F78
:1006B000880F991F880F991F820F931F9A01281B7B
:1006C000390B30939700209396009A010E94CB0437
:1006D0009695879596958795969587959093A7007B
:1006E0008093A60080917400909175002AE030E01C
:1006F000B9010E94B10490939D0080939C00709377
:100700009B0060939A008091720090917300B901F0
:100710000E94B1049093A5008093A400709394006C
:10072000609393008091700090917100B9010E94D4
:10073000B10490938E0080938D007093920060932B
:1007400091000895CF93C82F0E941803CA997EC0C4
:100750001092A3001092A20010928C00CF5F8091A3
:100760009500813051F4C83108F0C0E08C2F90E042
:1007700090936D0080936C005FC0823051F4CC3355
:1007800008F0C0E08C2F90E090936F0080936E0093
:1007900053C0843051F4CD3008F0C1E08C2F90E08C
:1007A000909373008093720047C08330D1F52091FD
:1007B000720030917300C9018D7F8430910519F06A
:1007C0008930910521F4CF3128F1C1E023C0019790
:1007D00069F02530310551F0C9010797029730F0D3
:1007E0002A30310519F02C30310521F4C03290F057
:1007F000C1E010C080917000909171008453984FB7
:10080000893F9F4F20F0CE3128F0C1E003C0CD31A9
:1008100008F0C1E08C2F90E09093750080937400F5
:100820000BC0853049F4C43608F0C0E08C2F90E04E
:1008300090937100809370008FEF91EE24E08150CF
:1008400090402040E1F700C000007ECFC9990BC066
:10085000C1508FEF90E722E0815090402040E1F7B7
:1008600000C0000071CFCB996FCF8FEF99E628E1E0
:10087000815090402040E1F700C000008C2FCF91C4
:10088000089581E08093950080916C000E94A203FE
:1008900090E090936D0080936C00809195008F5F45
:1008A0008093950080916E000E94A20390E0909347
:1008B0006F0080936E00809195008F5F809395000C
:1008C000809174000E94A20390E090937500809341
:1008D0007400809195008F5F8093950080917200E5
:1008E0000E94A20390E09093730080937200809125
:1008F00095008F5F80939500809170000E94A20305
:1009000090E090937100809370001092950008958C
:100910008FEF87BB90EE9ABB9EE19BBB81BB84BBF4
:100920000E94D5010E94E9020E9418032FEF84E380
:100930009CE0215080409040E1F700C00000DD9A2B
:100940002FEF84E39CE0215080409040E1F700C00D
:100950000000DD98CC99E6CF0E9441040E94BB02C2
:10096000E1CF97FB072E16F4009407D077FD09D04E
:100970000E94DA0407FC05D03EF4909581959F4FC4
:100980000895709561957F4F0895EE0FFF1F0590B4
:10099000F491E02D0994A29FB001B39FC001A39FE1
:1009A000700D811D1124911DB29F700D811D1124A8
:1009B000911D0895AA1BBB1B51E107C0AA1FBB1FB5
:1009C000A617B70710F0A61BB70B881F991F5A95DB
:1009D000A9F780959095BC01CD010895F894FFCFBB
:1009E00004081020408040801020040804000D00FE
:1009F00013000300010006004000790024003000CD
:0C0A000019001200020078000000100035
:00000001FF
Hello. When programming the…
Hello. When programming the Atmelstudio processor, the message Unable to parse objectfile C: file.hex: Unsupported format appears. Please help
Hello. Can you send a hex…
Hello. Can you send a hex file to an email address?
Can you send a hex file to…
Can you send a hex file to your email address? I'll give you the address when I get a reply
PORTA=0x1E; NOT DECLEAR IN THISH SCOPE PROBLEM
PLEASE SOLVE THISH PROBLEM