seven segment output problem

Thread Starter

bobparihar

Joined Jul 31, 2014
93
I did seven segment interfacing o simulation and on developing kit of 8051 and i was successful( when i did connect the seven segment only to the MCU in Proteus )
but now when i did implement it on my own general purpose PCB board with the circuit that is required for the hardware then i am getting error in output..

with the same circuit proteus also giving error on output

the circuit i am following is in the attached images

my code is as follows

Code:

#include<reg51.h>
sbit a=P1^0;
int ar[]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // common anode segment
unsigned int i,j;
void main()
{


for(i=0;i<10;i++)
{
a=1; //to the common pin of segment
P2=ar; //
for(j=0;j<50000;j++); // just for some delay

}
}
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
A couple of thoughts:

P2=ar; assigns the address of the array (with a compiler warning probably) to the port. You want to index the array like P2=ar[1];
I would use a PNP with active low on the base to drive the anode. The port pin may not be able to source the current required to drive the display at a high enough voltage to satisfy Vbe+ Vled + Vol to turn on the transistor.

Good luck.
 

Thread Starter

bobparihar

Joined Jul 31, 2014
93
A couple of thoughts:

P2=ar; assigns the address of the array (with a compiler warning probably) to the port. You want to index the array like P2=ar[1];
I would use a PNP with active low on the base to drive the anode. The port pin may not be able to source the current required to drive the display at a high enough voltage to satisfy Vbe+ Vled + Vol to turn on the transistor.

Good luck.
sir, i am using a common anode seven segment display

and iam already using ar instead of ar in my code.. it just misplaced by editor here

can i use a PNP transistor for a common anode configuration?
if so...then how the common pin of seven segment will get positive voltage(high)?

actually my real purpose is to multiplex two seven segment and then use it for display.. but first i want to test that does my circuit is correct for one seven segment.. that is why i am trying.. once i succeed then i will do multiplexing
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
can i use a PNP transistor for a common anode configuration?
if so...then how the common pin of seven segment will get positive voltage(high)?
Like this:
Change the NPN to a PNP transistor.
Interchange the collector and emiter i.e. connect the emitter to +5 and the collector to the common anode of the display.
Add a resistor between base and emmitter (68K-200K - not critical) to ensure that the transistor turns off.
Be sure the 10K base resistor will sink enough base current to turn it on fully.
Drive the digit select (a1) LOW to turn on the transistor, drive it HIGH to turn the transistor off.

To turn on a digit pattern, write the complement of the desired pattern to the segments (0 = segment ON) and write a 0 to P1.0
Something like this - changes in CAPS:
Code:
#include<reg51.h>
sbit a=P1^0;
unsigned char ar[]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // common anode segment CHANGED TO UNSIGNED CHAR
unsigned char i; CHANGED TO UNSIGNED CHAR
unsigned int j;

void main(){
while(1){
   for(i=0;i<10;i++){
       a=1; //to the common pin of segment TURN DISPLAY OFF WHILE CHANGING SEGMENTS
       P2=ar[i]; // FETCH PATTERN USING INDEX i
       a = 0; //TURN DISPLAY ON
       for(j=0;j<50000;j++); // just for some delay
   }//for i
}//while
}//main
EDIT: presumably you have the rest of the uC hooked up properly - EA/ pulled up, etc. You can verify that the processor is running by inspecting ALE. Unless explicitly disabled in the code, it will be pulsing if the processor is running.
 
Last edited:

Thread Starter

bobparihar

Joined Jul 31, 2014
93
Like this:
Change the NPN to a PNP transistor.
Interchange the collector and emiter i.e. connect the emitter to +5 and the collector to the common anode of the display.
Add a resistor between base and emmitter (68K-200K - not critical) to ensure that the transistor turns off.
Be sure the 10K base resistor will sink enough base current to turn it on fully.
Drive the digit select (a1) LOW to turn on the transistor, drive it HIGH to turn the transistor off.

To turn on a digit pattern, write the complement of the desired pattern to the segments (0 = segment ON) and write a 0 to P1.0
Something like this - changes in CAPS:
Code:
#include<reg51.h>
sbit a=P1^0;
unsigned char ar[]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // common anode segment CHANGED TO UNSIGNED CHAR
unsigned char i; CHANGED TO UNSIGNED CHAR
unsigned int j;

void main(){
while(1){
   for(i=0;i<10;i++){
       a=1; //to the common pin of segment TURN DISPLAY OFF WHILE CHANGING SEGMENTS
       P2=ar[i]; // FETCH PATTERN USING INDEX i
       a = 0; //TURN DISPLAY ON
       for(j=0;j<50000;j++); // just for some delay
   }//for i
}//while
}//main
EDIT: presumably you have the rest of the uC hooked up properly - EA/ pulled up, etc. You can verify that the processor is running by inspecting ALE. Unless explicitly disabled in the code, it will be pulsing if the processor is running.

thanks a ton for help, sir..
the circuit i am following is shown in attached picture
u can check it and if there is something wrong please inform me..
i did connect 31 pin(EA) to 40 pin(VCC) by wire

how can i verify that the processor is running by inspecting ALE??
 

Attachments

Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
how can i verify that the processor is running by inspecting ALE??
If you have an oscilloscope or logic probe its easy. If you have a digital multimeter you can sometimes see by measuring the voltage on the pin. If ALE is running, the reading will jump around a bit. You can also check the oscillator this way.

The segment pattern you show looks like an inverted '0' but that does not correspond to the value indicated on the output port?
The circuit looks OK but its hard to tell from the picture if the correct pins are used on the display.

Did you update the code as suggested?
 
Top