Continue to Site

# 7 segment LED's application using 8051

Status
Not open for further replies.

#### robismyname

##### Full Member level 6
7 segment display using 8051

I have 4 (dual 7 segment LED's) that I am using for a 8051 application (using ports 0-3).

I need to option of displaying unique number values on each segment of the led's but I noticed that for one 7 segment LED all pins are attached together (see attached data sheet) causing both segments of the LED to display the same number.

How do I design my LED's using the 8051 to have each segment be independent of one another?

Also how do I use the decimal on the LED (what pin controls the decimal)?

#### Roma_te

##### Member level 1
application of 8051

For connecting several indicators together you should connect all the same name segments together (A to A, B to B, e.t.c.) and connect them (via current switch) to one port of MC (for example A to P1.0, B - P1.1, ... G - P1.6). Each pins DIG1 and DIG 2 should be connected (also via current switch) to separate pins of MC (for example P2.0, P2.7).
Pins A...G provide indicating of data, pins DIG1 and DIG2 of all indicators provide indicator selecting. You should provide such controll of these pins, which provide only one indicator on in the same time. So your software should provide cyclical outputing data on Indicator 1, indicator 2, ... indicator 8. If the frequency of this cycle will be more then 60 Hz you will not see blinking.

raha_m

Points: 2

### raha_m

Points: 2

#### robismyname

##### Full Member level 6
how to connect much led to microcontroller

Roma_te said:
For connecting several indicators together you should connect all the same name segments together (A to A, B to B, e.t.c.) and connect them (via current switch) to one port of MC (for example A to P1.0, B - P1.1, ... G - P1.6). Each pins DIG1 and DIG 2 should be connected (also via current switch) to separate pins of MC (for example P2.0, P2.7)............

How many current switches do I need? Will this one suffice?

raha_m

### raha_m

Points: 2

#### Roma_te

##### Member level 1
avr with 7 segment indicator led schematic

robismyname said:
How many current switches do I need? Will this one suffice?
I prefer attached circuit based on bipolar transistors.
You will nead 8 switches with NPN transistors for current ~1A and 7 switches with PNP transistors for current ~150 mA.

raha_m

### raha_m

Points: 2

#### ctownsend

dual 7 segment display pin diagram

robismyname said:
How do I design my LED's using the 8051 to have each segment be independent of one another?

Also how do I use the decimal on the LED (what pin controls the decimal)?

On a common cathode I would use a 2N3904 transistor on the common cathode pin to gnd. One pin will turn on & off that display. According to your datasheet that would be pins 5 & 10. So you connect a 2N3904 transistor to each of those pins, and share the 8 pins (A-G) with one port on the 8051.

Your data sheet does not show which pin is the Decimal point. What I would do is plug the display into a breadboard and with a 5 volt power supply and a 470 ohm resistor in series, apply power to each of the pins (one by one) while ground is connected to pin 5 and then pin 10 after. You can't cause damage with the resistor.

Good Luck

#### robismyname

##### Full Member level 6
8051 application

Roma_te said:
robismyname said:
How many current switches do I need? Will this one suffice?
I prefer attached circuit based on bipolar transistors.
You will nead 8 switches with NPN transistors for current ~1A and 7 switches with PNP transistors for current ~150 mA.

For the PNP transistors in your diagram you have the base wire going to the MCU and Emitter wire going to ground.

The link has the base wire going to ground and the Emitter wire gong to the MCU.

so who is correct?

#### Roma_te

##### Member level 1
leds application

robismyname said:
For the PNP transistors in your diagram you have the base wire going to the MCU and Emitter wire going to ground...
The triangle on this diagram - 5VDC

#### robismyname

##### Full Member level 6
7 segment led + base

Roma_te said:
The triangle on this diagram - 5VDC

Ok so 5 volts for PNP Emmitter triangle and 5 volts for NPN base triangle? Any need for a truth table?

#### Roma_te

##### Member level 1
7 segment connect to pnp transistor

robismyname said:
Ok so 5 volts for PNP Emmitter triangle and 5 volts for NPN base triangle?
Yes
robismyname said:
Any need for a truth table?
For switch off all indicators you should output on P2 XXXX0000 (X-any bit, 0 or 1);
For switch on 1-st indicator - P2=XXXX0001;
For switch on 2-nd indicator - P2=XXXX0010;
For switch on 3-rd indicator - P2=XXXX0100;
For switch on 4-th indicator - P2=XXXX1000;

For switch off all segments of active indicator - P1=11111111;
For switch on segment A - P1=11111110;
For switch on segment B - P1=11111101;
For switch on segment C - P1=11111011;
For switch on segment D - P1=11110111;
For switch on segment E - P1=11101111;
For switch on segment F - P1=11011111;
For switch on segment G - P1=10111111;
For switch on segment DP (it is not implemented in your indicator) - P1=01111111.

#### robismyname

##### Full Member level 6
how to uln2003 connect large common cathode

Roma_te said:
For switch off all indicators you should output on P2 XXXX0000 (X-any bit, 0 or 1);
For switch on 1-st indicator - P2=XXXX0001;
For switch on 2-nd indicator - P2=XXXX0010;
For switch on 3-rd indicator - P2=XXXX0100;
For switch on 4-th indicator - P2=XXXX1000;

Roma_te,

I have 4 dual 7 segment leds. Each dual 7 segment led has common cathode (pin#5 and pin#10). So doesn't that mean I need 8 NPN transistors,not 4? One for each common cathode pin?

#### ctownsend

uln2003 to controll 7segment

That is wrong. Maybe I am missing something here, but if your displays are CC (common cathode) This is the correct way to wire it up.

A logic "1" on the base of the transistors turns that particular display ON. A logic "0" turns it off. On the 7 port pins, a logic "1" turns the particular led on while a logic "0" turns it off.

You can create a table in your code and use the movc instruction:
Code:
ONE 		EQU	0Ch		; single digit (low nibble)
TEN		EQU	0Dh		; LH digit (upper nibble)

Update_Disp:
mov	dptr,#display_table
mov	a,one			;copy one digit to acc
movc	 a,@a+dptr		;get digit from offset in acc
ret

;0 = 028h, 1 = 07Eh, 2 = 019h, 3 = 01Ch
;4 = 04Eh, 5 = 08Ch, 6 = 088h, 7 = 03Eh
;8 = 008h, 9 = 00Eh
;
display_table:
db	00101000B,01111110B,00011001B,00011100B
db	01001110B,10001100B,10001000B,00111110B
db	00001000B,00001110B

Now this table can be wrong AS IT ALL DEPENDS ON HOW YOU CONNECT THE DISPLAY TO YOUR PORT

Good Luck

#### robismyname

##### Full Member level 6
common cathode 7 segment display using 8051

ctownsend said:
That is wrong. Maybe I am missing something here, but if your displays are CC (common cathode) This is the correct way to wire it up.

To clarify all displays are common cathode.

So you are telling me that I dont need NPN's on the dispaly pins (A-G) going to the MCU ports? Only PNP's on the common cathode pins of the displays going to the MCU ports?

Can I use PNP - PN2 222A 749 instead of BC327-25 or 2N3904?

#### sn_burki

##### Full Member level 5
uln2003 pdf datasheet with 7 segment circuit

robismyname said:
ctownsend said:
That is wrong. Maybe I am missing something here, but if your displays are CC (common cathode) This is the correct way to wire it up.

To clarify all displays are common cathode.

So you are telling me that I dont need NPN's on the dispaly pins (A-G) going to the MCU ports? Only PNP's on the common cathode pins of the displays going to the MCU ports?

Can I use PNP - PN2 222A 749 instead of BC327-25 or 2N3904?
The given idea is good for small 7 segment display but if you are using large 7segment displays then you will have to bring change in it like using ULN 2003 on all segments (A-G).

#### ctownsend

schematic big display 7 segment

robismyname said:
Can I use PNP - PN2 222A 749 instead of BC327-25 or 2N3904?

you need NPN transistors.
P2N2222A should work.

Digi-Key part #: P2N2222AGOS-ND.

make sure you install the resistors on all port pins!
sn_burki said:
The given idea is good for small 7 segment display but if you are using large 7segment displays then you will have to bring change in it like using ULN 2003 on all segments (A-G).

Yes, what he said. I was under the assumption that these are small displays.

#### robismyname

##### Full Member level 6
avr 7 segment led display

sn_burki said:
The given idea is good for small 7 segment display but if you are using large 7segment displays then you will have to bring change in it like using ULN 2003 on all segments (A-G).

the way large and small is used in your text is unclear. Im using the LDD-F304NI. Are these considered large or small?

#### ctownsend

7 segment using 8051

that is the same data sheet you posted above. You should not have a problem using a resistor on the data lines with your micro controller.

There are tons of schematics for Common Anode seven segment displays available if you search google. I haven't found very many diagrams with a Common Cathode setup.

### robismyname

Points: 2

#### robismyname

##### Full Member level 6
8051 2n3904

ok sounds good. I have a real good understanding now on how to handle this. Thanks To all who provided input

#### electronproton

##### Newbie level 6
schematic for seven segment

hi..

I'm using common anode seven segment..
the circuit is similar to ctownsend schematic..

but the problem is my 7805 become very hot when the seven segment ON..

what should i do?

thx

#### Roma_te

##### Member level 1
seven segment display 8051

electronproton said:
but the problem is my 7805 become very hot when the seven segment ON.what should i do?
There are several ways of solutions this problem:
1. If the light of your LEDs are large enough you can decrease current thru them. It is possible by increasing resistance of resistors or by periodic power off all indicators for some time. In the second case if the frequency of indicators blinking will be more then 50 Hz you will not recognize it.

3. Take power for indicators from input of 7805. Then it is necessary put switches based on two transistors. I think that this way is the most difficult if your device is made and it could be implemented if previous does not provide success.

#### ctownsend

7segment common led 8051

electronproton said:
I'm using common anode seven segment..
the circuit is similar to ctownsend schematic..
are you aware that common anode would require pnp transistors instead of npn? The power would be switched instead of gnd.

electronproton said:
but the problem is my 7805 become very hot when the seven segment ON..
show us your circuit. what is the current rating of your 7805?

Status
Not open for further replies.