8051 INTERFACING   

Online FREE !

 

 

7 Segment Display

 

INTRODUCTION

 

For the seven 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 (the schematic shows 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 must be set to 5V. This is simply done by setting the pins on the 8051 to '1' or '0'.

 

 

LED displays are

  •  Power-hungry (10ma per LED)

  •  Pin-hungry (8 pins per 7-seg display)

 

 But they are cheaper than LCD display

7-SEG  Display are available in two types -1. Common anode   &   2. common cathode ,  but command anode display are most suitable for interfacing with 8051 since 8051 port pins can sink current better than sourcing it.

 

 

 

 

                                                                                                                                                                                                                                         

CREATING DIGIT PATTERN

For displaying Digit say 7 we need to light segments -a ,b, c. Since we are using Common anode display , to do so we have to to provide  Logic -0 (0 v) at anode of  these segments.

so need to clear  pins- P1.0 ,P1.1,P1.2.    that is 1 1 1 1 1 0 0 0 -->F8h .

 

Connection                                                                                                               Hex Code

Segment number

8051 pin number

a

P1.0

b

P1.1

c

P1.2

d

P1.3

e

P1.4

f

P1.5

g

p1.6

h(dp)

P1.7

Digit

Seg. h

Seg. g

Seg. f

Seg. e

Seg. d

Seg. c

Seg. b

Seg. a

HEX

0

1

1

0

0

0

0

0

0

C0

1

0

0

0

0

0

1

1

0

06

2

1

0

1

0

0

1

0

0

A4

3

1

0

1

1

0

0

0

0

B0

4

1

0

0

1

1

0

0

1

99

 

 

 

You can also 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  this is one of limitation of 7-seg display.

Since we can 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 be flicker-free. At least 30HZ .Therefore  – time one digit is ON is 1/30 seconds 

 

INTERFACING

Note that I am using Common Anode display. so the common Anode pin is tied to 5v .The cathode pins are connected to port 1 through 330 Ohm resistance (current limiting).

              Common Anode display

                                                                                                                                                           

                                                                                                                                                                                                             

 

   

CODE EXAMPLE

Connection - a:h to port p1.0:p1.7 , D0:D1 to p3.0:p3.1.

 

To Display - Consider example of vending machine where we want to display number of soft drink bottles on display entered by customer. Suppose he enter 3 (03) bottles then we will use lookup table to see DIGIT PATTERN of these keys. 

So  DIGI[1]=c0 (hex code for '0')  &

      DIGI[2]=bo(hex code for '3').

 

Note: I have taken values for DIGI[1] & DIGI[2] directly in code.

 

Algorithm

 

C LANGUAGE             (SPJ SIDE51)

 

 

 

 

 

 

start : disable [D0:D1]
again : enable D0
[a:h] - pattern for Digit1
delay
disable D0. Enable D1

[a:h] - pattern for Digit2
delay
Goto again

 

 

 

#include <Intel\8052.h>
#include <standard.h>
#include<stdio.h>
#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')*/


while(1) {
for (cnt=1;cnt<3;cnt++)

 {
P3 = cnt; /*Enable D0 and then D1*/
P1=DIGI[cnt];/*P1=c0 when D0 is enabled & P1=b0 when d1 is enabled*/
delay_ms(20);
 }
}
}
 

 

 

 

 

 

 

Site Developed and maintained by Mahesh Wankhede