8051 Based Simple Digital Clock

Embed Size (px)

Citation preview

  • 8/4/2019 8051 Based Simple Digital Clock

    1/7

    SIM PLE DIGITAL CLOCK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    DIGITAL CLOCKUS ING 80511 lCCONTENTS:-03" SUMMARY.03" CIRCUIT DIAGRAM.03" DISCRIPTION.03" BLOCK DIAGRAM.03" SORCECODE (PROGRAMMING).03" COMPONANTS.

    TRANSISTOR BC 547SEVEN SEGMENT DISPLAYAT89C51 MICROCONTROLLER

    MICROCONTROLLER PROJECTSANKDASARIYA SHAILESH B.ENRL NO-090760111025KHATRANI PRAYAGK.ENRL NO-090760111030SSASIT (E.C. DEPARTMENT)

    ENRLNO.090760111025,090760111030

  • 8/4/2019 8051 Based Simple Digital Clock

    2/7

    SIM PLE DIGITAL CLOCK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    SIMPLE DIGITAL CLOCK USING 8051 MICROCONTROLLER (AT89C51)~SUMMARY:-A digital clock is one that displays time digitally. The circuit explained here displaystime with two 'minutes' digits and two 'seconds' digits on four seven segmentdisplays. The seven segment and switches are interfaced with 8051 microcontrollerAT89C51. This circuit can be used in cars, houses, offices etc ..

    ~CKT DIAGRAM:-

    5 v s u p p ly d e< T E X T >

    P O O I A D O ~ - - : -P O . 1 I A D 1 . . . . . . . . . .- - = -P 0 . 2 IA D 2 ~ - -: -P 0 . 3 I A D 3 . . .. . .. . ..- - = -P 0 . 4 I A D 4 1 - ? " - - - : -P O S I A D 5 . .. .. .. .. --=-P 0 . 6 I A D 6 ~ - ' ; ; "P 0 . 7 I A D 7P 2 0 l A 8~-----...IP 2 . 1 1 A 91-""--------'

    P 2 . 2 I A 1 0~------....IP 2 . 3 IA 1 1 ~ - -- -- -_ _ _ ,P 2 . 4 I A 1 2~-------....IP 2 S I A 1 3 1 - ' " ' - - - - - - - - - - ,P 2 . 6 I A 1 4~--------....IP 2 . 7 I A 1 5P 3 0 I R X D~-------------++++++-JP 3 1 ! T X D 1-""'---------------'P 3 2 J N T O~----------------IP 3 . 3 J N T 11-"'----------------'

    P 3 . 4 ! T O~-----------------IP 3 5 ! T 11-"'----------------'

    P 3 . 6 ! / I I R ~------------------IP 3 7 I R D

    ENRLNO.090760111025,090760111030

  • 8/4/2019 8051 Based Simple Digital Clock

    3/7

    SIMPLE DIGITAL CLOCK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    ~DISCRIPTION:-As soon as the Vee supply is provided to th is ci rcu it, the clock starts from 00: 00. Thetime is displayed on four seven segments (in common anode configuration) by usingthe concept of multiplexing. This is achieved by using timer interrupt (TimerO) ofAT89C51which is configured to refresh seven segments. The segments are refreshed manytimes in a second for simultaneous display. The clock runs with a delay of exactlyone second. Timer1 has been used to produce a time delay of one second. The datapins (a-h) of all the segments are interconnected and receive signal from port P2 ofthe microcontroller. The control or enable pins (common anode) are connected topins 1-4 of port P1 (P1AO - P1A3).The number on 4th segment (displaying the unit digit of second) is incremented oncein a second as it goes from 0 to 9. The number on 3rd segment is incremented afterevery 10 seconds from 0 to 5. Thus seconds are displayed varying from 00 to 59.The digit on the 2nd segment changes after every 60 seconds (a minute) from 0 to 9and so on. Thus the clock runs for an hour and after that it resets to zero again.

    ~BLOCK DIAGRAM:-

    P 1 .0 - P 1 .3I

    ~. 1 ~2 ~.3 ~ ...48 0 5 1 8 8 8 8 8 8 1 8 8I CROCONTROOLER

    ~ QJ. QJ. ~8 _ . 8 _ 8 8 8 _ 8 - 8 _ . 8 _~@) ~ ~. ~@)I < J2.0 P 2.7 AS A DATA BUS FO R 7 SEG MEN T DISPLAYS

    D IS P 1 =M IN U TED ISP 2=M INUTED IS P 3 =SECONDD ISP 4 =SECOND

    ENRLNO.090760111025,090760111030

  • 8/4/2019 8051 Based Simple Digital Clock

    4/7

    SIM PLE DIG ITAL CLO CK8051 MICROCONTROLLER

    S.SAS.I.T.(E.C. DEPT)

    ~LOGIC TABLE FOR D ISPLAYING DIG IT IN SEVEN SEGM ENT D ISPLAYDIGIT a b c d e f g HEXValue0 0 0 0 0 0 0 1 Ox401 1 0 0 1 1 1 1 OxF92 0 0 1 0 0 1 0 Ox243 0 0 0 0 1 1 0 Ox304 1 0 0 1 1 0 0 Ox195 0 1 0 0 1 0 0 Ox126 0 1 0 0 0 0 0 Ox027 0 0 0 1 1 1 1 OxF88 0 0 0 0 0 0 0 OxOO9 0 0 0 1 1 0 0 OxlO

    ~SOURCE CODE:- Program to demonstrate the principle of digital clock.this digital clock displays two minute digits and two second digits#includeunsigned char val[]={Ox40,OxF9,Ox24,Ox30,Ox19,Ox12,Ox02,OxF8,OxOO,OxlO};void delay() //Function to provide a time delay of approx. 1 second.{

    int i,j;for(i=O;i

  • 8/4/2019 8051 Based Simple Digital Clock

    5/7

    SIMPLE DIGITAL CLOCK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    ~COMPONANT:-~SEVEN S EGMENT D IS PL AY :-

    E9 f 8. b

    A seven segment display is the most basic electronicdisplay device that can display digits from 0-9. They findwide application in devices that display numericinformation like digital clocks, radio, microwave ovens,electronic meters etc. The most common configuration hasan array of eight LEDs arranged in a special pattern todisplay these digits. They are laid out as a squared-offfigure '8'. Every LED is assigned a name from 'a' to 'h' andis identified by its name. Seven LEDs 'a' to 'g' are used todisplay the numerals while eighth LED 'h' is used todisplay the dot/decimal.

    A seven segment is generally available in ten pinpackage. While eight pins correspond to the eight LEDs,the remaining two pins (at middle) are common andinternally shorted. These segments come in twoconfigurations, namely, Common cathode (CC) andCommon anode (CA). In CC configuration, the negativeterminals of all LEDs are connected to the common pins.The common is connected to ground and a particular LEDglows when its corresponding pin is given high. In CAarrangement, the common pin is given a high logic andthe LED pins are given low to display a number.

    ~AT89C51 MICROCONTROLLER : -

    AT89C51 is an 8-bit microcontroller and belongsto Atmel's 8051 family. AT89C51 has 4KB of Flashprogrammable and erasable read only memory(PEROM) and 128 bytes of RAM. It can be erasedand program to a maximum of 1000 times.In 40 pin AT89C51, there are four portsdesignated as Pi, P2, P3 and Po.All these ports are8-bit bi-directional ports, i.e., they can be used asboth input and output ports. Except Powhichneeds external pull-ups, rest of the ports haveinternal pull-ups. When ls are written to these

    port pins, they are pulled high by the internal pull-ups and can be used as inputs.

    ENRLNO.090760111025,090760111030

  • 8/4/2019 8051 Based Simple Digital Clock

    6/7

    SIMPLE DIGITAL CLOCK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    All ports are also bit addressable and so their bits can also be accessed individually.

    PiLl

    PI..3P:~.,,4

    PL6Pl.-,

    P3.Q j RxDP3.1 !TxDP3 .2: i ]l:itOP3.3 i ]OII;~.P3.4 J TOP3,5 ITl

    P3.6 iW.riteP3.,7 !R.ea,d

    GNU

    n mtil :I;:lII II!13 ~n mIi iii1\1 ~iii asIII AT89C51 ill!IE mB E l iii~ ~IE ~II Iiw :Em :'EE i I i :iii!E ~IE S E a! : i D m

    VeePO ..O j .ADO'Po" :~.I.ADlPO..2. IAD2PO.3 j .AD3

    PO,,;; : ; I.ADSPO.6 IAD6PO.7 j .AD7EA/VppALE I:ProgPSENP2,,7 !.AlSIP2.6 IA14P2.5 j .A13P2. ..4 J .A12.P2,,3 !.AI~.

    P2.0 j A.,s

    Port Poand P2 are also used to provide low byte and high byte addresses,respectively, when connected to an external memory. Port 3 has multiplexed pins forspecial functions like serial communication, hardware interrupts, timer inputs andread/write operation from external memory. AT89C51 has an inbuilt UART for serialcommunication. It can be programmed to operate at different baud rates. Includingtwo timers & hardware interrupts, it has a total of six interrupts.

    ENRLNO.090760111025,090760111030

  • 8/4/2019 8051 Based Simple Digital Clock

    7/7

    SIM PLE DIG ITAL CLO CK8051 MICROCONTROLLER

    S .SAS .I .T .(E.C . DEPT)

    ~PIN DISCRIPTION: -

    Pin t~6 Functiert t~ame1 P102 P1.13 P124 8 bit input/output port (P1) pins P135 P1A6 P157 P168 P179 Reset pin; Active high Reset10 Input (receiver) for serial communication RxD P3011 Output (transmitter) for serial TxD P31communication12 External interrupt 1 IntO P3213 External interrupt 2 Int1 8 bit input/output P3.314 Timer1 external input TO port (P3) pins P3A15 Timer2 external input T1 P3-516 Wite to external data memory Wite P3-617 Read from external data memory Read P3718 Crystal 219 Quartz crystal oscillator (up to 24 MHz) Crystal 120 Ground (OV) Ground21 P20/ A822 P21/ A923 8 bit input/output port (P2) pins P22/ A1024 / P231A1125 High-order address bits when interfacing with external memory P2A/ A1226 P2.51A1327 P261A1428 P2.71A1529 Program store enable; Read from external program memory PSEN30 Address Latch Enable ALEProgram pulse input during Flash programming Prog31 External Access Enable; Vcc for internal program executions EAProgramming enable vo~age; 12V (during Flash programming) vpp32 POlI AD733 PO6/AD634 8 bit input/output port (PO)pins PO.51AD535 POAI AD436 Low-order address bits when interfacing with external memory PO3/AD337 PO21AD238 PO1/AD139 PO.DIADO40 Supply voltage; 5V (up to 6.6V) Vcc

    ENRLNO.090760111025,090760111030