Professional Documents
Culture Documents
Project Report Digital Clock System: Digital Logic and Design - 3-B
Project Report Digital Clock System: Digital Logic and Design - 3-B
5/26/2015
ACKNOWLEDGEMENT
I truly express big thanks to my project guider, Sir Rizwan Ali, for advising me from the
beginning till successful completion of this project and being the part of this project, I always
tried to lead from the front. I appreciate the efforts made by my project mates for bringing out
this project which is full of information, if implemented, it will be great benefit to Computer
Science department for their co-operation and support throughout this project.
.
5/26/2015
ABSTRACT
The main purpose of this project is to build a digital clock and also to emphasize team working
experience among students. To design 12 hour digital clock, electronic devices such as ICs ,
resistors and LEDs are required that can be directly operated from a 230V main supply. The time
will be displayed on the LED display panel showing minutes and seconds function.
5/26/2015
Table of contents
Topics
Pages
Introduction-----------------------------------
Literature Review-----------------------------------
Methodology-------------------------------------------------
I.
Circuit diagram----------------------------
10
11-12
Coding ------------------------------------------
13
Conclusion--------------------------------------
14
5/26/2015
INTRODUCTION
A digital clock shows the time in numbers form on the lcd screen. It helps us to see the exact and
precise time. It is very expensive and accurate and it is very helpful for the buyer to buy this
instrument. We also build a digital clock on the breadboard that is also displays the time in
numbers form. The components we used in our circuit are as follows:
PIC 16F84A
Transistor BC548 (4)
10K,1K-Resistor (1k - 4)
LED
22pfCapacitor(2)
Push button (3)
Crystal 4MHz
Common cathode seven segment display (4)
5/26/2015
LITERATURE REVIEW
The first digital pocket watch was invented by Austrian engineer Josef Pallweber in 1883.It
shows the time in hours and minutes and it is available in the market yet. Another type of digital
clock called Plato clocks were invented by Ansonia Clock Company 1904. In 1970, the digital
wristwatch was invented by Hamilton Watch Company which now a days people are using these
types of watches. After that, many digital watches and digital clocks are developed.
5/26/2015
Objectives:
To construct and design circuit on breadboard and starts testing it that whether it is
working or not.
METHODOLOGY
WORKING:
PIC16f84A microchip is a main component of the circuit; its control and generates the seconds
clock through which the device run and its also control the 7 segment display. There are three
buttons are provided : reset button , hours button, and minute button . Reset button sets the time
to 0 while hours and minute button increment in hours and minutes to set the time from where
we want digital clock to start. By pressing these button you can easily set the hours and minutes .
5/26/2015
The main feature of this real time clock circuit is that this clock takes less current like its only
draws lees than 100mA.In this way you will also connect it with rechargeable batteries. By
increasing the value of resistors connected to the seven segment display you can decrease the
current gain. 24(international time clock) to 12 hour time conversion easily done by burning the
PIC microchip with the corresponding hex file.
CIRCUIT DIAGRAM:
5/26/2015
5/26/2015
10
5/26/2015
CODING
#define F_CPU 4000000UL
#include <avr/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#define SegDataPort
PORTB
#define SegDataPin
PINB
#define SegDataDDR
DDRB
PINC
#define SegCntrlDDR
DDRC
/*Function Declarations*/
/
*****************************************************************************/
/*Decimal Digit (0-9) to Seven Segment Values Encoder*/
unsigned char DigitTo7SegEncoder(unsigned char digit, unsigned char common);
11
5/26/2015
/*Main Program*/
/
*****************************************************************************/
int main(void)
{
SegDataDDR = 0xFF;
SegCntrlDDR = 0x3F;
SegCntrlPort = 0xFF;
TCCR1B = (1<<CS12|1<<WGM12);
OCR1A = 15625-1;
TIMSK = 1<<OCIE1A;
sei();
while(1)
{
/* Set Minutes when SegCntrl Pin 6 Switch is Pressed*/
if((SegCntrlPin & 0x40) == 0 )
{
_delay_ms(200);
if(minutes < 59)
minutes++;
else
minutes = 0;
12
5/26/2015
}
/* Set Hours when SegCntrl Pin 7 Switch is Pressed*/
if((SegCntrlPin & 0x80) == 0 )
{
_delay_ms(200);
if(hours < 23)
hours++;
else
hours = 0;
}
SegDataPort = DigitTo7SegEncoder(seconds%10,1);
SegCntrlPort = ~0x01;
SegDataPort = DigitTo7SegEncoder(seconds/10,1);
SegCntrlPort = ~0x02;
SegDataPort = DigitTo7SegEncoder(minutes%10,1);
SegCntrlPort = ~0x04;
SegDataPort = DigitTo7SegEncoder(minutes/10,1);
SegCntrlPort = ~0x08;
SegDataPort = DigitTo7SegEncoder(hours%10,1);
SegCntrlPort = ~0x10;
SegDataPort = DigitTo7SegEncoder(hours/10,1);
SegCntrlPort = ~0x20;
}
return 0;
}
/*
13
5/26/2015
* Function Description:
* Encode a Decimal Digit 0-9 to its Seven Segment Equivalent.
*
* Function Arguments:
* digit - Decimal Digit to be Encoded
* common - Common Anode (0), Common Cathode(1)
* SegVal - Encoded Seven Segment Value
*
* Connections:
* Encoded SegVal is return in the other G-F-E-D-C-B-A that is A is the least
* significant bit (bit 0) and G bit 6.
*/
unsigned char DigitTo7SegEncoder(unsigned char digit, unsigned char common)
{
unsigned char SegVal;
switch(digit)
{
case 0: if(common == 1) SegVal = 0b00111111;
else
SegVal = ~0b00111111;
break;
case 1: if(common == 1) SegVal = 0b00000110;
else
SegVal = ~0b00000110;
break;
case 2: if(common == 1) SegVal = 0b01011011;
else
SegVal = ~0b01011011;
break;
case 3: if(common == 1) SegVal = 0b01001111;
else
SegVal = ~0b01001111;
14
5/26/2015
break;
case 4: if(common == 1) SegVal = 0b01100110;
else
SegVal = ~0b01100110;
break;
case 5: if(common == 1) SegVal = 0b01101101;
else
SegVal = ~0b01101101;
break;
case 6: if(common == 1) SegVal = 0b01111101;
else
SegVal = ~0b01111101;
break;
case 7: if(common == 1) SegVal = 0b00000111;
else
SegVal = ~0b00000111;
break;
case 8: if(common == 1) SegVal = 0b01111111;
else
SegVal = ~0b01111111;
break;
case 9: if(common == 1) SegVal = 0b01101111;
else
SegVal = ~0b01101111;
}
return SegVal;
}
if(seconds == 60)
{
15
5/26/2015
seconds = 0;
minutes++;
}
if(minutes == 60)
{
minutes = 0;
hours++;
}
if(hours > 23)
hours = 0;
}
We use four common cathode seven segment displays which are connected in PORTB of
the PIC.
The seven inputs of seven segment displays are connected in parallel but it shows
different values it is done by continues scanning, that is if a value want display on the
first seven segment display activate the corresponding transistor then send the value to
through the port that is shown in circuit diagram.
To display a value on the second display activate the second transistor and send value
through PORTB.
16
5/26/2015
This scanning is continually done by PORTA and PORTB sends the display value.
Three push buttons are used one for reset the microcontroller and remaining two for set
minute and hour which connected in PORTB which scan to get a zero volt on the pins
RB6and RB7.
CONCLUSION
Summing up it is clear that we have successfully completed our task and it shows that digital
clock is very flexible and mostly useable and now days world is shifted toward digital clock
because it is easily be seen without any issues.
17
5/26/2015