Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How to multiplex 4 Anode Com Seven Segements with 8051 ?

  • Thread starter Electronics Art
  • Start date
Status
Not open for further replies.
E

Electronics Art

Guest
common anode multiplex

Hi to all
I build following circuit in the Proteus VSM
jzv9ea.png

I want use this circuit for multiplexing 4 Anode Com Seven Segement
with one port of AT89C51 microcontroller in assembly language
That showing the " 2006 " number in the seven segement
I write the program in the assembly language but it not working properly
and I not see the " 2006 " number in the seven segements fixedly
and the seven segements are on and off alternately

I upload the my project's files ( .ASM - .HEX - .DSN ) in following address
https://rapidshare.de/files/10706839/AT89C51_Multiplex_Displays.zip.html
You can download it and see my project

Anybody can write this program in the assembly language ?
Please help me
Thanks a lot
 

sunish

Advanced Member level 4
Joined
Sep 4, 2005
Messages
117
Helped
10
Reputation
20
Reaction score
2
Trophy points
1,298
Activity points
2,360
multiplexing in 8051 programming

hai
i will give u the idea about writing the programe.the idea is that u will use one port as data and u have to use any 4 port lines for switching the 7 seg display.what u have to do,insted of connecting the base of the transistor to the +vcc,connect them to the port lines in seris with a 1 k resistor.the current required to turn on the transitor will get from the 89c51.so not required to connect to the +vcc.even the darlington pair is not required.u can connect a npn transistor,collector to the +vcc,emitor to the common anode of the 7 seg display and base to the portline of the micro controller.now,place the data which is to be displayed on 7segdis-1 on the port line and make the port line connected to that high (SETB).all other 3 controlling port lines should be reset.now the data will be displayed(ie.2).now place the second data(ie.0)on data portlines and make the currsponding controll portline high and make the rest 3 clear.repeat this for the other two digit also.put the entire program in ia closed loop,then 2006 will get displayed on the 7 seg display

regards

sunish

Added after 2 minutes:

hai
i will give u the idea about writing the programe.the idea is that u will use one port as data and u have to use any 4 port lines for switching the 7 seg display.what u have to do,insted of connecting the base of the transistor to the +vcc,connect them to the port lines in seris with a 1 k resistor.the current required to turn on the transitor will get from the 89c51.so not required to connect to the +vcc.even the darlington pair is not required.u can connect a npn transistor,collector to the +vcc,emitor to the common anode of the 7 seg display and base to the portline of the micro controller.now,place the data which is to be displayed on 7segdis-1 on the port line and make the port line connected to that high (SETB).all other 3 controlling port lines should be reset.now the data will be displayed(ie.2).now place the second data(ie.0)on data portlines and make the currsponding controll portline high and make the rest 3 clear.repeat this for the other two digit also.put the entire program in ia closed loop,then 2006 will get displayed on the 7 seg display

regards

sunish
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,470
connect multiplex seven seg to microcontroller

This is your code:

Code:
ORG 0H

; ********* Main *********

MAIN:
MOV P0,#16H	; Select Segement one ,   and write digit 6 in it
CALL DEALY              	; Call 20 mili second dealy
MOV P0,#20H	; Select Segement two ,   and write digit 0 in it
CALL DEALY	; Call 20 mili second dealy
MOV P0,#40H	; Select Segement three , and write digit 0 in it
CALL DEALY	; Call 20 mili second dealy			
MOV P0,#82H	; Select Segement four ,   and write digit 2 in it
CALL DEALY	; Call 20 mili second dealy
JMP MAIN                 	; Jump the first of program

; *** 20 mili second dealy ***

DEALY:
MOV TMOD,#01H 	; Select TIMER0 and in the 16bit mode
MOV TL0,#0DFH	; Load dealy time in the TIMER0 for counting 20 mili second
MOV TH0,#0B1H	; Load dealy time in the TIMER0 for counting 20 mili second
SETB TR0		; Start Timer
STOP:
JNB TF0,STOP     	; A loop for find the end of 20 mili second if TF0=0 the 20  mili second is finished
CLR TF0		; Clear TF0 Flag
CLR TR0                   	; Stop the Timer
RET		; Return the Main program

END

Multiplexed displays must typically be operated at a current n times the nominal operating current (where n is the number of digits), to obtain sufficient brightness.

If we choose a nominal operating current of 5 mA / segment, then we need 4 x 5 = 20 mA / segment for 4 digits.
If we need all 7 segments lit / digit then the transistor must be able to drive 7 x 20 mA = 140 mA.
If you need a darlington it's up to you. But some resistors to limit the current on LEDs don't harm.
If the npn transistors are driven through port P0 then it's a must to provide pullup resistors since writing an 1 to P0 output latch disable the internal FET resistor and the output floats.

In the multiplexing configuration, it is necessary to disable the display
while the source driver switches from one digit to the next. This technique is called "interdigit blanking" and is necessary to prevent partial illumination (ghosting) of segments intended to be off. This phenomena results from the source driver requiring more time to turn off than the sink driver takes to turn
on. Blanking will delay the sink driver turn on and will allow the source driver to turn off completely.
You can do that by writing FFH to P0 during let's say 1 ms after each writing of usefull data (20 ms).

A common procedure is to cross beyond the interrupt vector table and set the ORG to say 50H for the MAIN: label
Setting the stack pointer it's also recommended.
 

E

Electronics Art

Guest
how to multiplex display at proteus

silvio said:
Multiplexed displays must typically be operated at a current n times the nominal operating current (where n is the number of digits), to obtain sufficient brightness.

If we choose a nominal operating current of 5 mA / segment, then we need 4 x 5 = 20 mA / segment for 4 digits.
If we need all 7 segments lit / digit then the transistor must be able to drive 7 x 20 mA = 140 mA.
If you need a darlington it's up to you. But some resistors to limit the current on LEDs don't harm.
If the npn transistors are driven through port P0 then it's a must to provide pullup resistors since writing an 1 to P0 output latch disable the internal FET resistor and the output floats.

In the multiplexing configuration, it is necessary to disable the display
while the source driver switches from one digit to the next. This technique is called "interdigit blanking" and is necessary to prevent partial illumination (ghosting) of segments intended to be off. This phenomena results from the source driver requiring more time to turn off than the sink driver takes to turn
on. Blanking will delay the sink driver turn on and will allow the source driver to turn off completely.
You can do that by writing FFH to P0 during let's say 1 ms after each writing of usefull data (20 ms).
A common procedure is to cross beyond the interrupt vector table and set the ORG to say 50H for the MAIN: label
Setting the stack pointer it's also recommended.


Very Thanks for your help
Are you can write a assembly program for this circuit that showing
the " 2006 " number at the 7 segments display ?
Also correction my circuit in the PROTEUS VSM software
Because I start to learning 8051 and assembly three days ago and I'm not professional
Very Very Thanks :D

Added after 1 minutes:

sunish said:
hai
i will give u the idea about writing the programe.the idea is that u will use one port as data and u have to use any 4 port lines for switching the 7 seg display.what u have to do,insted of connecting the base of the transistor to the +vcc,connect them to the port lines in seris with a 1 k resistor.the current required to turn on the transitor will get from the 89c51.so not required to connect to the +vcc.even the darlington pair is not required.u can connect a npn transistor,collector to the +vcc,emitor to the common anode of the 7 seg display and base to the portline of the micro controller.now,place the data which is to be displayed on 7segdis-1 on the port line and make the port line connected to that high (SETB).all other 3 controlling port lines should be reset.now the data will be displayed(ie.2).now place the second data(ie.0)on data portlines and make the currsponding controll portline high and make the rest 3 clear.repeat this for the other two digit also.put the entire program in ia closed loop,then 2006 will get displayed on the 7 seg display
regards
sunish

Thanks your help
Are you download my project's files ?
If you download, you see I write a program strictly like your idea
But my problem is with 7 segments displays

This is my code :
Code:
ORG 0H

; ********* Main *********

MAIN:
MOV P0,#16H	; Select Segement one ,   and write digit 6 in it
CALL DEALY              	; Call 20 mili second dealy
MOV P0,#20H	; Select Segement two ,   and write digit 0 in it
CALL DEALY	; Call 20 mili second dealy
MOV P0,#40H	; Select Segement three , and write digit 0 in it
CALL DEALY	; Call 20 mili second dealy			
MOV P0,#82H	; Select Segement four ,   and write digit 2 in it
CALL DEALY	; Call 20 mili second dealy
JMP MAIN                 	; Jump the first of program

; *** 20 mili second dealy ***

DEALY:
MOV TMOD,#01H 	; Select TIMER0 and in the 16bit mode
MOV TL0,#0DFH	; Load dealy time in the TIMER0 for counting 20 mili second
MOV TH0,#0B1H	; Load dealy time in the TIMER0 for counting 20 mili second
SETB TR0		; Start Timer
STOP:
JNB TF0,STOP     	; A loop for find the end of 20 mili second if TF0=0 the 20  mili second is finished
CLR TF0		; Clear TF0 Flag
CLR TR0                   	; Stop the Timer
RET		; Return the Main program

END
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,470
Well, something quickly for your code. I add few lines for interdigit blanking keeping the same code fashion as yours in order to understand what is new in DELAY routine.

Code:
ORG 0H
JMP MAIN


ORG 50H
; ********* Main *********

MAIN:
MOV P0,#16H		; Select Segement one ,   and write digit 6 in it
CALL DEALY              ; Call 20 mili second dealy
MOV P0,#20H		; Select Segement two ,   and write digit 0 in it
CALL DEALY		; Call 20 mili second dealy
MOV P0,#40H		; Select Segement three , and write digit 0 in it
CALL DEALY		; Call 20 mili second dealy			
MOV P0,#82H		; Select Segement four ,   and write digit 2 in it
CALL DEALY		; Call 20 mili second dealy
JMP MAIN                ; Jump the first of program

; *** 20 mili second dealy ***

DEALY:
MOV TMOD,#01H 		; Select TIMER0 and in the 16bit mode
MOV TL0,#0DFH		; Load dealy time in the TIMER0 for counting 20 mili second
MOV TH0,#0B1H		; Load dealy time in the TIMER0 for counting 20 mili second
SETB TR0		; Start Timer
STOP:
JNB TF0,STOP     	; A loop for find the end of 20 mili second if TF0=1 the 20 mili second is finished
CLR TF0			; Clear TF0 Flag
CLR TR0                 ; Stop the Timer
;**********here is new********************
MOV TL0,#017H		; Load dealy time in the TIMER0 for counting 1 mili second
MOV TH0,#0FCH		; Load dealy time in the TIMER0 for counting 1 mili second
MOV P0, #0FFH		; Select No Segment, and write 1111b to 447 for interdigit blanking
SETB TR0		; Start Timer
STOP1:
JNB TF0,STOP1     	; A loop for find the end of 1 mili second if TF0=1 the 1 mili second is finished
CLR TF0			; Clear TF0 Flag
CLR TR0                 ; Stop the Timer
;****************until here******************
RET			; Return the Main program

END
 

wek

Full Member level 4
Joined
Dec 21, 2004
Messages
239
Helped
28
Reputation
56
Reaction score
2
Trophy points
1,298
Activity points
1,991
I'd guess the main trouble is in the hardware - power source, decoupling, reset...

By the way, how do you limit the current into segments?

wek
 

E

Electronics Art

Guest
silvio said:
Well, something quickly for your code. I add few lines for interdigit blanking keeping the same code fashion as yours in order to understand what is new in DELAY routine.

Thanks a lot dear silvio for your helps
But I find my problem with circuit
The problem create by " Proteus VSM " software simulation method
This software can not online simulation the analog device
The 7 segments displays is a analog device and Proteus can not simulation properly
this devices in the multiplexing method
But the "7segments displays Multiplexed pack " such as 2,4,6 or 8 digit in one pack very good simulation with Proteus software
I build my circuit again with "7segments displays Multiplexed pack "
and change a few my code and this circuit working very good
You can see my circuit's schematic in the following image
k12kiw.png

This is my new code :
Code:
ORG 0H
; ******* Main Program ******
MAIN:
MOV    P0,#02H
SETB   P0.4
CALL   DELAY
MOV P0,#00H
SETB   P0.5
CALL   DELAY
MOV P0,#00H
SETB   P0.6
CALL   DELAY
MOV P0,#06H
SETB   P0.7
CALL   DELAY
JMP MAIN
; ******** Time Dealy 20 mili second *******
DELAY:
MOV    R0,#0FH
D1:
MOV    R1,#0FFH
D2:
DJNZ   R1,D2
DJNZ   R0,D1
RET

END

You can download my new project's files from following address
https://rapidshare.de/files/10770267/New_Multiplex.zip.html

Thanks again from dear silvio for your helps :D
Also thanks a lot from Mr Nahvi for finding this problem :D

Added after 16 minutes:

wek said:
how do you limit the current into segments?

Hi dear wek

I not want to build this circuit in the real world
Just I want test the assembly program for multiplexing 7segments displays
And this circuit is a simulation and there are no problem with segments current
Thanks :D
 

narccizzo

Full Member level 3
Joined
Jan 20, 2006
Messages
174
Helped
16
Reputation
32
Reaction score
11
Trophy points
1,298
Location
PATZCUARO,MICHOACAN,MEXICO
Activity points
2,819
Hi everyone!
It's pretty good to make a full simulation of the circuit without any wire, that method save a lot of time, but i think some time you have to build a real circuit end keep on mind that there are some problems in a real hardware that maybe you don't see easyly in simulation if you decide to do that maybe this helps..
if the uC has the hability to disable the upper fet to make the output like open collector kind thats good for your circuit because you save components (in the anode commun configuration) but the better way is the cathode com configuration because only needs 2 components by digit, in a multiplexed way you have to remember its gonna be on only T/n sec, where T is the time to display the full number, that means to more digits... less average current and less light, so you have to increase the voltage that feeds the displays.
good luck!
this is how do i connect both configurations..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top