Beruflich Dokumente
Kultur Dokumente
It will be much easier to understand if you first read Interfacing LED's to Microcontroller.
Basically there are two types of 7-Seg display's: Common Cathode where all the segments share the same Cathode. Common Anode where all Segments share the same Anode.
Here we will be only discussing the Common Anode type.In common Anode in order to turn ON a segment the corresponding pin must be set to 0. And to turn it OFF it is set to 1.
Figure 2
Controller P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 7-seg display A B C D E F G
Figure 1 shows how to interface 7-seg display to a microcontroller. Now we create a lookup table containing the seven segment pattern to display the corresponding hex digits. e.g. consider we have to display '1' from the above figure we come to know that turning ON segment B & C will show '1' on the 7seg display so P2.1 & P2.2 should be LOGIC 0 whereas rest of the pins should be LOGIC 1. FIGURE 2 shows the lookup table for CA display.
Figure 3 We can now interface a single 7-Seg to the microcontroller but for interfacing multiple 7-seg's we use Scanning Principle where One 7-seg is displayed after another but this process is very fast hence the flickering cannot be seen by human eye. Figure 3 shows the circuit for interfacing two 7 seg displays.
When interfacing more than one 7-seg display the segment's (A-G) of all displays are connected together whereas their ANODE (Cathode in case of CC displays) are switched ON one after another. Consider we have to display '31' on the above 7-seg display so we TURN ON the first transistor by setting its corresponding pin to 1 & then give the 7-seg equivalent code for '3' which is 4fh. Then we TURN OFF the first transistor & TURN ON the second & output its corresponding 7-seg equivalent code of '1' i.e. 06h.Then we again go back to display '3' this is a never ending loop. ORG 0000h CLR P3.0 CLR P3.1 MOV P2,#0ffh
loop: CLR P3.0 SETB P3.1 MOV P2,#4fh CALL delay CLR P3.1 SETB P3.0 mov P2,#06h CALL delay AJMP loop
7 Segment Display
TION
n segment display you can use the LT-541 or LSD5061-11 chip. Each of the segments of the display is connected to a pin on the 8051
ows how to do this). In order to light up a segment on the the pin must be set to 0V. To turn a segment off the corresponding pin mus
are
2. common cathode , but command anode display are most suitable for interfac
051 port pins can sink current better than sourcing it.
DIGIT PATTERN
g Digit say 7 we need to light segments -a ,b, c. Since we are using Common anode display , to do so
Hex Code Segment Seg. h number Digit 0 1 2 3 e 4 f g h(dp) 1 0 a b c d 1 0 1 0 1 Seg. g 8051 pin number Seg. f Seg. e 1 0 0 P1.0 0 P1.1 0 P1.2 1 P1.3 1 P1.4 0 P1.5 p1.6 P1.7 1 1 0 0 1 99 0 0 0 1
Seg. d 0 0 0 0
Seg. c 0 1 1 0
Seg. b 0 1 0 0
Seg. a 0 0 0 0
HEX C0 06 A4 B0
do this for some characters like A ,E .. but not for D or B because it will be same as that of 0 & 8 . So
limitation of 7-seg display. 30HZ .Therefore time one digit is ON is 1/30 seconds
Enable only one 7-seg display at a time ,we need to scan these display at fast rate .The scanning frequency should be high enough to
NG
m using Common Anode display. so the common Anode pin is tied to 5v .The cathode pins are connected to port 1 through 330 Ohm r
ting).
MPLE
onsider example of vending machine where we want to display number of soft drink bottles on display entered by customer. Suppose h
then we will use lookup table to see DIGIT PATTERN of these keys.
Algorithm
(SPJ SIDE51)
isable [D0:D1]
enable D0
#include<etc.h> void main( ){ unsigned char DIGI[2]; unsigned char right,cnt; P1 = 0; /* initialize all P1 outputs to be zero*/ P3 = 0; DIGI[1]=0xc0;/*(hex code for '0')*/ DIGI[2]=0xb0;/*(hex code for '3')*/
D0. Enable D1
ain