Continue to Site

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.

multiplexing code problem

Status
Not open for further replies.

sayf alawneh

Junior Member level 3
Joined
Aug 15, 2014
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
256
my project is to make a 00 to 99 counter using 2 common cathode 7 segments and pic 16f877a the segments are connected to portb the tens digit transistor is connected to RD0 and the ones digit transistor is connected to RD1
the problem is that the tens digit isnt showing but the ones digit is working well , i dont know where is the problem
here is the code

char x,y=0;
unsigned short mask(unsigned short num){
switch(num){
case 0:return 0x3f;
case 1:return 0x06;
case 2:return 0x5B;
case 3:return 0x4F;
case 4:return 0x66;
case 5:return 0x6D;
case 6:return 0x7D;
case 7:return 0x07;
case 8:return 0x7F;
case 9:return 0x6F;
}
}
void main()
{
TRISB=0;// PORTB is output
TRISD=0;// PORTD is output
PORTB=0;// initialize PORTB
PORTD=0;// initialize PORTD
for(;;){ // ifinite loop
PORTD=1; // transistor on RD0 is enabled and transistor on RD1 is disabled
PORTB=mask(y); //tens digit
delay_ms(10);// eye delay
PORTD=2; // transistor on RD1 is enabled and transistor on RD0 is disabled
PORTB=mask(x); //ones digit
delay_ms(10); // eye dealy
x++;
if(x==10){x=0;y++;if(y==10)y=0;}
delay_ms(1000);//over all delay between counting
}
}

- - - Updated - - -

here is a picture for the circuit


شششششششش.PNG
 

The first problem I see is that you are only turning on the 10s display for 10ms every 1.02s. You might see it flicker, but probably not. You would need to continually refresh both displays in order for vision persistence to make them both appear on solid. Basically you need to add loop inside the for loop containing the two PORTD/PORTB output statements and delays. If you stay with 10ms delays, you would need to run that loop 50 times, then you can increment the x and y variables and continue refreshing, without the 1s delay.

If you still have problems, confirm that your RD1 pin output is working.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top