Search Inside My Blog

Monday, November 8, 2010

Interfacing 7 segment

  
  Seven segment display is a basic type of display which can display numbers from 0 to 9. The circuit for interfacing single 7 segment display is shown below.
    Driving a 7 segment display is as simple as flashing LEDs, but here we are flashing 7+1 LEDs. The 7 segment display module has 8 LEDs (7 segments to display number and one segment for decimal point or dot) arranged in a particular manner as shown in image below.
 
    By driving (in the sense controlling ON and OFF conditions) these LEDs in various combinations, we can display the numbers 0 to 9. There are basically two types of 7 segment displays, they are common cathode and common anode. In common cathode, the cathodes of all the LED segments are connected together, we should apply a logic 1 or high input to a segment pin to light up that particular segment, and in common cathode the case is opposite. Table below shows the combinations of inputs to be applied to 7 segment display for digits 0 to 9.

For common cathode displays
Digitbinary input valuehexadecimal input value
011111100FC
10110000060
211011010DA
311110010F2
40110011066
510110110B6
610111110BE
711100000E0
811111110FE
911110110F6
For common anode displays
Digitbinary input valuehexadecimal input value
00000001103
1100111119F
20010010125
3000011010D
41001100199
50100100149
60100000141
7000111111F
80000000101
90000100109
 
The images shown below are the photographs of 7 segment add-on board for my microcontroller board, I have included one 7 segment in the current version of my development board, so if you are using that circuit then you don't need an external 7 segment display board. Click on the image to enlarge.
 

The assembly language source code for interfacing 7 segment display is given below.
;*************************************************
;
;Program: Driving seven segment display
;Author: Mahesh
;Description: Displays numbers 0 to 9 on
;the LED seven segment display continuously
;
;*************************************************

;Declarations
port equ P0

;*************************************************

;Main program
org 0000h
     ljmp main
org 30h
 
main:mov r0,#08h
     mov a,#00000001b      ;test all segments of disp
up:  rr a
     mov port,a
     acall delay
     djnz r0,up

again:mov port,#11111100b  ;'0'
     acall delay
     mov port,#01100000b   ;'1'
     acall delay
     mov port,#11011010b   ;'2'
     acall delay
     mov port,#11110010b   ;'3'
     acall delay
     mov port,#01100110b   ;'4'
     acall delay
     mov port,#10110110b   ;'5'
     acall delay
     mov port,#10111110b   ;'6'
     acall delay
     mov port,#11100000b   ;'7'
     acall delay
     mov port,#11111110b   ;'8'
     acall delay
     mov port,#11110110b   ;'9'
     acall delay
     sjmp again

;*************************************************

delay:mov r2,#0ffh         ;delay subroutine
up3: mov r4,#03fh
up2: mov r3,#0fh
up1: djnz r3,up1
     djnz r4,up2
     djnz r2,up3
     ret

;*************************************************

end

No comments:

Post a Comment