Interfacing Seven Segment Display to 8051

  • Upload
    giri

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

  • 8/13/2019 Interfacing Seven Segment Display to 8051

    1/7

    Interfacing Seven segment display to 8051

    admin

    June - 20 - 201222 Comments

    A Note about 7 segment LE display!

    This article is about how to interface a seven segment LED displa to an !0"1

    microcontroller# $ segment LED displa is ver popular and it can displa digits from 0

    to % and &uite a few characters li'e () b) C) #) *) E) e) +) n) o)t)u)) etc# ,nowledge abouthow to interface a seven segment displa to a micro controller is ver essential in

    designing embedded sstems# ( seven segment displa consists of seven LEDs arranged

    in the form of a s&uarish "8#slightl inclined to the right and a single LED as the dotcharacter# Different characters can be displaed b selectivel glowing the re&uired LED

    segments# even segment displas are of two tpes) common cathode and common

    anode..n common cathode tpe ) the cathode of all LEDs are tied together to a singleterminal which is usuall labeled as /com/ and the anode of all LEDs are left alone asindividual pins labeled as a) b) c) d) e) f) g h or dot # .n common anode tpe) the

    anode of all LEDs are tied together as a single terminal and cathodes are left alone as

    individual pins# The pin out scheme and picture of a tpical $ segment LED displa isshown in the image below#

    $ segment LED displa

    igit drive pattern!

    Digit drive pattern of a seven segment LED displa is simpl the different logic

    combinations of its terminals $a" to $%/ in order to displa different digits and

    characters# The common digit drive patterns 0 to % of a seven segment displa areshown in the table below#

    http://www.circuitstoday.com/author/adminhttp://www.circuitstoday.com/interfacing-seven-segment-display-to-8051#commentshttp://www.circuitstoday.com/wp-content/uploads/2012/06/7-segment-LED-display-pinout-image.pnghttp://www.circuitstoday.com/author/adminhttp://www.circuitstoday.com/interfacing-seven-segment-display-to-8051#comments
  • 8/13/2019 Interfacing Seven Segment Display to 8051

    2/7

    igit a b c d e f g

    0 1 1 1 1 1 1 0

    1 0 1 1 0 0 0 0

    2 1 1 0 1 1 0 1

    3 1 1 1 1 0 0 14 0 1 1 0 0 1 1

    " 1 0 1 1 0 1 1

    5 1 0 1 1 1 1 1

    $ 1 1 1 0 0 0 0

    ! 1 1 1 1 1 1 1

    % 1 1 1 1 0 1 1

    Interfacing seven segment display to 8051!

    .nterfacing $ segment displa to !0"1

    The circuit diagram shown above is of an (T!%"1 microcontroller based 0 to % counter

    which has a $ segment LED displa interfaced to it in order to displa the count# Thissimple circuit illustrates two things# *ow to setup simple 0 to % up counter using !0"1and more importantl how to interface a seven segment LED displa to !0"1 in order to

    displa a particular result# The common cathode seven segment displa D1 is connected

    to the 6ort 1 of the microcontroller (T!%"1 as shown in the circuit diagram# 73 to710 are current limiting resistors# 3 is the reset switch and 72)C3 forms a debouncing

    circuitr# C1) C2 and 81 are related to the cloc' circuit# The software part of the pro9ect

    has to do the following tas's#

    http://www.circuitstoday.com/wp-content/uploads/2012/06/interfacing-7-segement-display-to-8051.png
  • 8/13/2019 Interfacing Seven Segment Display to 8051

    3/7

    +orm a 0 to % counter with a predetermined dela around 1:2 second here#

    Convert the current count into digit drive pattern#

    6ut the current digit drive pattern into a port for displaing#

    (ll the above said tas's are accomplished b the program given below#

    &rogram!

    ORG 000H //initial starting address

    START: MOV A,#00001001B // initial value of au!ulator

    MOV B,A

    MOV R0,#0AH //Register R0 initiali"ed as ounter $i$ ounts fro! 10

    to 0

    %AB&%: MOV A,B

    '() A

    MOV B,A

    MOV) A,*A+) // adds t$e -.te in A to t$e rogra! ounters address

    MOV 1,A

    A)A%% &%A // alls t$e dela. of t$e ti!er&) R0//)ounter R0 dere!ented -. 1

    MOV A,R0 // R0 !oved to au!ulator to $e2 if it is "ero in ne3t

    instrution4

    56 START //)$e2s au!ulator for "ero and 7u!s to START4 one to

    $e2 if ounting $as -een finis$ed4

    S5M %AB&%

    B 89H // digit drive attern for 0

    B 0H // digit drive attern for 1

    B ;BH // digit drive attern for H // digit drive attern for

    B 0>H // digit drive attern for >

    B >9H // digit drive attern for ?

    B 9H // digit drive attern for @

    &%A: MOV R=,#0;H // su-routine for dela.

    A'T1: MOV R8,#00H

    A'T

  • 8/13/2019 Interfacing Seven Segment Display to 8051

    4/7

    .n the program) initial value in ( is 00001001A# E@ecution of ;(?6C will

    add oooo1001A to the content in 6C address of ne@t instruction# The result will be the

    address of command DA 3+* line1" and the data present in this address ie 3+* digitdrive pattern for 0 gets moved into the accumulator# ;oving this pattern in the

    accumulator to 6ort 1 will displa 0 which is the first count#

    (t the ne@t count) value in ( will advance to 00001010 and after the e@ecution of

    ;?6C )the value in ( will be 05* which is the digit drive pattern for 1 andthis will displa 1 which is the ne@t count and this ccle gets repeated for subse&uent

    counts#

    The reason wh accumulator is loaded with 00001001A % in decimal initiall is that theinstructions from line % to line 1" consumes % btes in total#

    The lines 1" to 24 in the program which starts with command DA can be called as a Loo'

    (p )able *L()+# Command DA is 'nown as Define Ate B which defines a bte# This

    table defines the digit drive patterns for $ segment displa as btes in he@ format#;

  • 8/13/2019 Interfacing Seven Segment Display to 8051

    5/7

    applications# (lso the ma@imum number of displas that can be connected to the !0"1 is

    limited to 4 because !0"1 has onl 4 ports# ;ore over three 3 displas will be

  • 8/13/2019 Interfacing Seven Segment Display to 8051

    6/7

    condition is maintained for another 1ms and then port 3#1 is made low# This ccle is

    repeated and due to the persistence of vision ou will feel it as 15M#

    Transistor N1 drives the first displa D1 and transistor N2 drives the second displaD2# 711 and 712 are the base current limiting resistors of N1 and N2# The purpose of

    other components are e@plained in the first circuit#

    &rogram!

    ORG 000H // initial starting address

    MOV 1,#00000000B // lears ort 1

    MOV R,#1H // stores 1

    MOV R>,#H // stores

    MOV 8,#00000000B // lears ort 8

    MOV TR,#%AB&%1 // loads t$e adress of line //

  • 8/13/2019 Interfacing Seven Segment Display to 8051

    7/7