Sunteți pe pagina 1din 8

10/23/13

7-Segment Display Interfacing and Programming - Embedded Club 4 U

Embedded Club 4 U
Home Counter Course Contents Downloads Useful Links Contact Us
Training > Embedded System 6-week Training >

Search this site

7-Segment Display Interfacing and Programming


5.1 Introduction Till now y ou hav e learn what is an embedded sy stem, basic memory architecture of a microcontroller, how to implement assembly language and use of some softwares like pinnacle 52, keil-C and flash magic; we also hav e come across how to interface LEDs from a microcontroller and how to generate different pattern through it. now its time to mov e forward and learn one more step ahead towards the completion of our 6-weak training. so here today we will learn about 7-Segment display ; How to interface and program it; and some of the applications of it. 5.2 7 -Segm ent Display A 7-Segment display is a useful electronic component use to produce numeric, alphabetic and some non-alphabetic sy mbols using a specific arrangement of LEDs as shown in figure here. A 7-Segment display has 10-Pins representing each a, b , c , b , e , f, g and h LEDs respectiv ely along with two ex tra pins for GND and VSS. following shown an original 7-Segment display dev ice along with its pin diagram. LED h is also denoted by sy mbol dp .

Home Introduction Course Contents Embedded DSP Sensors Guide Training Downloads Books Magazines Softwares Useful Links Projects Contuct Us Sitemap

As we hav e studied in LED interfacing a 7 -segment display is also interfaced in same way as it is also made of LEDs. So we can interface LEDs in three way s bu here difference is that 7 -Segment display s comes in two ty pes by manufacturers i.e. "Com m on Anode " and "Com m on Cathode "; the logics are shown in figure below.

and

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

1/8

10/23/13

7-Segment Display Interfacing and Programming - Embedded Club 4 U

and thus which logic is o implement is on the bases of these specifications prov ided by manufacturer. interfacing in our case has been shown below. 5.3 7-Segm ent Display Interfacing We interface 7-Segment display with port zero of microcontroller; and to do so we connect P0.0 to P0.7 to Pin a to dp (h ) of 7-Segment display respectiv ely ; and connect Vss terminal of display to 5V Power supply and GND pin to ground. the configuration is shown in figure below.

5.4 Cascading sev en segm ent display Here we hav e a question in mind that if we want to interface more then one 7-Segment display with microcontroller what we will do??? as we are using one port for one 7-segment display if we use all the four ports for four 7-Segment display ??? isn't it less efficient??? The answer of all these questions are hidden under this topic "CASCADING " cascading refers to connecting similar or non-similar component from the same connections with a reference of enabling and disabling each components according to specification.

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

2/8

10/23/13

components according to specification.

7-Segment Display Interfacing and Programming - Embedded Club 4 U

For cascading four 7-Segment display we use the following schem where all the a to f (dp ) pins of 7 -segment display are connected paralleled to the port zero of microcontroller along with common ground and Vss pin of all the four 7-segments are use for enabling and disabling them so are connected to port two of microcontroller along with NOT Gate in order to " " and thus clearing or sending "0" on pins of port two cause enabling the display and signal "1" cause disabling it.

5.5

7 -Segm ent Display Program m ing

Programming a 7-Segment display is so easy as to program a LED array but here pattern should be generate in a manner so as it appears as a meaningful character and with cascaded mode we also need to send "clear" (0) or "set bit " (1) signal on respected pins of port two in order to enable or disable respected 7-Segment display . The signals on Port zero which can generate meaningful characters on 7-Segment display are listed in table below.

Ex ample Lets write a program to show character "3" on 7-Segm ent display .

Showing character "3" on 7-Segment display


https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming
;****************************************

3/8

10/23/13

7-Segment Display Interfacing and Programming - Embedded Club 4 U


;**************************************** ;** Showing character "3" on 7-Segment display ** ;**************************************** org 0000h main: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 ;Origin ;Main subroutine ;Enabling Display-1 ;Disabling Display-2 ;Disabling Display-3 ;Disabling Display-4 ;Sending LED pattern of character "3" at port zero

mov P0,11110010b jmp $ end

;End

OUTPUT

5.6 Generating counting from 0 to 9

0 to 9 Counter
;************************************* ;************ 0 to 9 Counter ************* ;************************************* org 0000h main: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 mov P0,#0FCh call delay mov P0,#60h call delay mov P0,#0DAh character "2" to Port zero call delay ;Start ;Main Subroutine ;Enabling Display-1 ;Disabling Display-2 ;Disabling Display-3 ;Disabling Display-4 ;Sending character "0" to Port zero ;Calling Delay Function ;Sending pattern of character "1" to Port zero ;Calling Delay Function ;Sending pattern of ;Calling Delay Function

mov P0,#0F2h ;Sending pattern of character "3" to Port zero call delay ;Calling Delay Function mov P0,#66h ;Sending pattern of character "4" to Port zero call delay ;Calling Delay Function mov P0,#0B6h ;Sending pattern of character "5" to Port zero call delay ;Calling Delay Function mov P0,#0BEh ;Sending pattern of character "6" to Port zero call delay ;Calling Delay Function mov P0,#0E0h ;Sending pattern of character "7" to Port zero call delay ;Calling Delay Function mov P0,#0FEh ;Sending pattern of

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

4/8

10/23/13

mov P0,#0FEh ;Sending pattern of character "8" to Port zero call delay ;Calling Delay Function mov P0,#0F6h ;Sending pattern of character "9" to Port zero call delay ;Calling Delay Function jmp main delay: ;Infinite Loop ;Delay Function

7-Segment Display Interfacing and Programming - Embedded Club 4 U

mov 40h,#0FFh ;Move FFh to memory location with address 40h L1: ;Label "L1" mov 41h,#99h ;Move 99h to memory 41h djnz 41h,$ ;Jump here till 41h becomes zero djnz 40h,L1 ;Jump to "L1" till 40h becomes zero ret ;return end ;End

OUTPUT

5.7

Generating counting from 0 to 9 [using array]

0 to 9 Counter using Array


;************************************* ;******** 0 to 9 Counter using Array********* ;************************************* org 0000h main: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 mov a,#00h Up: mov 30h,a mov dptr,#arr movc a,@a+dptr mov P0,a call delay mov a, 30h inc a jmp Up jmp main arr: db db db db db db db db db db 11111100b 01100000b 11011010b 11110010b 01100110b 10110110b 10111110b 11100000b 11111110b 11110110b ;Enabling Display-1 ;Disabling Display-2 ;Disabling Display-3 ;Disabling Display-4

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

5/8

10/23/13

7-Segment Display Interfacing and Programming - Embedded Club 4 U


delay: mov 40h,#0FFh L1: mov 41h,#99h djnz 41h,$ djnz 40h,L1 ret end

OUTPUT

5.8

Generating two digit numbers

Two digit number


;************************************* ;*********** Two digit number ************ ;************************************* org 0000h main: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 mov P0,#01100000b call delay clr P2.1 sbit P2.0 sbit P2.2 sbit P2.3 mov P0,#11011010b call delay jmp main delay: mov 40h,#50h L1: mov 41h,#99h djnz 41h,$ djnz 40h,L1 ret end

OUTPUT

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

5.9

Generating two four bit numbers alternatively

6/8

10/23/13
5.9

7-Segment Display Interfacing and Programming - Embedded Club 4 U


Generating two four bit numbers alternatively

Alternating two four digit numbers


;************************************ ;***** Alternating two four digit numbers ***** ;************************************ org 0000h main: mov 30h,#0FFh UP1: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 mov P0,#01100000b call delay clr P2.1 sbit P2.0 sbit P2.2 sbit P2.3 mov P0,#11011010b call delay clr P2.2 sbit P2.1 sbit P2.0 sbit P2.3 mov P0,#11110010b call delay clr P2.3 sbit P2.1 sbit P2.2 sbit P2.0 mov P0,#01100110b call delay djnz 30h,UP1 jmp $ mov 30h,#0FFh UP2: clr P2.0 sbit P2.1 sbit P2.2 sbit P2.3 mov P0,#10110110b call delay clr P2.1 sbit P2.0 sbit P2.2 sbit P2.3 mov P0,#10111110b call delay clr P2.2 sbit P2.1 sbit P2.0 sbit P2.3 mov P0,#11100000b call delay clr P2.3 sbit P2.1 sbit P2.2 sbit P2.0 mov P0,#11111110b call delay djnz 30h,UP2 jmp $ jmp main

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

7/8

10/23/13

7-Segment Display Interfacing and Programming - Embedded Club 4 U


delay: mov 40h,#30h L1: mov 41h,#99h djnz 41h,$ djnz 40h,L1 ret end

OUTPUT

CLICK TO DOWNLOAD SOURCE CODES

Day - 6 >>> INDEX <<< Day - 4

Comments

yuiyui

hjkhk

vbhbjk

hykhyuk

Sign in | Report Abuse | Print Page | Remove Access | Powered By Google Sites

https://sites.google.com/site/embeddedclub4u/training/embedded-system-training-in-45-days-6-week/7-segment-display-interfacing-and-programming

8/8

S-ar putea să vă placă și