Strange shadow in LED display

Status
Not open for further replies.
I have finally made it work, but the problem now is that almost all letters have shadow. I have programmed it mysefl, so i dont know if this could be easier or not, i just want a clear words on it.

Please tell me how to fix it

Here is video and a code:
https://www.youtube.com/watch?v=7HE58dF1lDI&feature=youtu.be

Code:
#include "C:\Keil\REG51ID2.h"
#include "C:\Keil\ID2.h"


#define   COL   P1
#define   ROW   P0


data   signed int j,b,k,brzina;
data unsigned char i;

brzina=5;


void AQ(int i) {ROW=15; COL=i+8; for ( k = 0; k < brzina; k++);  
				ROW=20; COL=i+9; for ( k = 0; k < brzina; k++);
				ROW=15; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }			 

void BQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=21; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=10; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }
 				   
void CQ(int i) {ROW=14; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=17; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=17; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void DQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=17; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=14; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }		 
	  				
void EQ(int i){ ROW=31; COL=i+8; for ( k = 0; k < brzina; k++);  
				ROW=21; COL=i+9; for ( k = 0; k < brzina; k++);
				ROW=21; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }			 

void FQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=20; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=20; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void GQ(int i) {ROW=14; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=17; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=19; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void HQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=4; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }

void IQ(int i) {ROW=17; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=17; COL=i+10; for ( k = 0; k < brzina; k++);
			  }			 

void JQ(int i) {ROW=3; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=1; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }
									
void KQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=4; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=27; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void LQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=1; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=1; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }

void MQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++);  
				ROW=24; COL=i+9; for ( k = 0; k < brzina; k++);
				ROW=31; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }			 

void NQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=12; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }
 				
void OQ(int i) {ROW=14; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=17; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=14; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void PQ(int i){ROW=31; COL=i+8;; for ( k = 0; k < brzina; k++); 
				ROW=20; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=28; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }

void RQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++);  
				ROW=20; COL=i+9; for ( k = 0; k < brzina; k++);
				ROW=15; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }			 

void SQ(int i) {ROW=9; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=21; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=18; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }
 				
void TQ(int i) {ROW=16; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=16; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void UQ(int i) {ROW=31; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=1; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=31; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }

void VQ(int i) {ROW=30; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=1; COL=i+9; for ( k = 0; k < brzina; k++);  
				ROW=30; COL=i+10; for ( k = 0; k < brzina; k++); 
			  }

void ZQ(int i) {ROW=19; COL=i+8; for ( k = 0; k < brzina; k++); 
				ROW=21; COL=i+9; for ( k = 0; k < brzina; k++); 
				ROW=25; COL=i+10; for ( k = 0; k < brzina; k++);  
			  }

		
main ()
{
      InitRS232();

		  
		     while(1){

			 for (i=56;  i>0;  i--) {
				for (j=0; j<100; j++) {AQ(i-48);BQ(i-44);CQ(i-40);DQ(i-36);EQ(i-32);FQ(i-28);GQ(i-24);HQ(i-20);IQ(i-16);JQ(i-12);KQ(i-8);LQ(i-4);MQ(i);}
			 		 				 }
				  
			 }
					
			 	
      PrintLn(); PrintString("--- PROGRAM END ---");  while(1);
}
 
I usually clear the ports at each interrupt of the display before I change them in there,just to be sure. Have you tried slowing down the display timer interrupt? (I can't read "C" yet), maybe its too quick of pulses?
 
I have tried it, yes. But it is the same.

Also as i am moving integer i, and as it can be showed only if it is (0<=i<12). And if on some letter in some time int is 18= that is 10010, and according to truth table (as it is looking only for lower 4 bits) it is 0010, and it will light 3th row.
I have put CD4072 with upper 4 bits as input, and output is attached to inhibit of decoder (if inhibit is 0, it is ok, if it is 1 nothing is showed), so if i is higher than 16 then CD4072 has 1 as input (it works as OR chip), and it turnes off my decoder and letter is not shoed.
Maybe this is the problem? And problem is now that it suddenly stopped to work, so all letters are mixed (A at i=10 and E at i=26 for example) because A (i=10)=1010, and E (i=26 and shoudnt be shown)=11010, chip should turn of decoder because of first 1. I think you should understand...
How can i fix it?
 
go back to before when it was half working, then delete the first while(1) , plus the {} for it. my guess it that you are refreshing too fast
 
You need to allow 10-100uS of time where all segments are OFF, before each new digit is displayed. That will stop the ghosting or shadowing.
 
It looks to me - in the code - like you're loading the next row data while the previous column is active. Try deactivating the column before loading the next row, as per the following code:

Code:
#include "C:\Keil\REG51ID2.h"
#include "C:\Keil\ID2.h"
 
 
#define   COL   P1
#define   ROW   P0
 
 
data   signed int j,b,k,brzina;
data unsigned char i;
 
brzina=5;

#define showline(r, c) COL=12; ROW=r; COL=c; for ( k = 0; k < brzina; k++);
 
void AQ(int i) {showline(15, i+8);  
				showline(20, i+9);
				showline(15, i+10); 
			  }			 
 
void BQ(int i) {showline(31, i+8); 
				showline(21, i+9); 
				showline(10, i+10); 
			  }
 
void CQ(int i) {showline(14, i+8); 
				showline(17, i+9);  
				showline(17, i+10); 
			  }
 
void DQ(int i) {showline(31, i+8); 
				showline(17, i+9); 
				showline(14, i+10);  
			  }		 
 
void EQ(int i){ showline(31, i+8);  
				showline(21, i+9);
				showline(21, i+10); 
			  }			 
 
void FQ(int i) {showline(31, i+8); 
				showline(20, i+9); 
				showline(20, i+10); 
			  }
 
void GQ(int i) {showline(14, i+8); 
				showline(17, i+9);  
				showline(19, i+10); 
			  }
 
void HQ(int i) {showline(31, i+8); 
				showline(4, i+9); 
				showline(31, i+10);  
			  }
 
void IQ(int i) {showline(17, i+8); 
				showline(31, i+9); 
				showline(17, i+10);
			  }			 
 
void JQ(int i) {showline(3, i+8); 
				showline(1, i+9); 
				showline(31, i+10); 
			  }
 
void KQ(int i) {showline(31, i+8); 
				showline(4, i+9);  
				showline(27, i+10); 
			  }
 
void LQ(int i) {showline(31, i+8); 
				showline(1, i+9); 
				showline(1, i+10);  
			  }
 
void MQ(int i) {showline(31, i+8);  
				showline(24, i+9);
				showline(31, i+10); 
			  }			 
 
void NQ(int i) {showline(31, i+8); 
				showline(12, i+9); 
				showline(31, i+10); 
			  }
 
void OQ(int i) {showline(14, i+8); 
				showline(17, i+9);  
				showline(14, i+10); 
			  }
 
void PQ(int i) {showline(31, i+8);
				showline(20, i+9); 
				showline(28, i+10);  
			  }
 
void RQ(int i) {showline(31, i+8);  
				showline(20, i+9);
				showline(15, i+10); 
			  }			 
 
void SQ(int i) {showline(9, i+8); 
				showline(21, i+9); 
				showline(18, i+10); 
			  }
 
void TQ(int i) {showline(16, i+8); 
				showline(31, i+9);  
				showline(16, i+10); 
			  }
 
void UQ(int i) {showline(31, i+8); 
				showline(1, i+9); 
				showline(31, i+10);  
			  }
 
void VQ(int i) {showline(30, i+8); 
				showline(1, i+9);  
				showline(30, i+10); 
			  }
 
void ZQ(int i) {showline(19, i+8); 
				showline(21, i+9); 
				showline(25, i+10);  
			  }
 
 
main ()
{
      InitRS232();
 
 
		     while(1){
 
			 for (i=56;  i>0;  i--) {
				for (j=0; j<100; j++) {AQ(i-48);BQ(i-44);CQ(i-40);DQ(i-36);EQ(i-32);FQ(i-28);GQ(i-24);HQ(i-20);IQ(i-16);JQ(i-12);KQ(i-8);LQ(i-4);MQ(i);}
			 		 				 }
 
			 }
 
 
      PrintLn(); PrintString("--- PROGRAM END ---");  while(1);
}
 
Your probably missing "inter-digit blanking". You have to turn, say a column, off completely for a short time while monkeying with the row values, otherwise it smears.
 

You are awesome ! Thank you. The code is much bettery your way

It first starts so good, but then i dont know what happen, but letters starts to mix?

I dont know how, but with this code, you removed all shadows, only problem now is that mixing (like without that if or without OR gate)

https://www.youtube.com/watch?v=pFJY1usOcc4&feature=youtu.be

Btw thank you all for helping me!

Woops, look what happend after a while the display is on:

https://www.youtube.com/watch?v=6SJAIfW1KGs&feature=youtu.be
 
Last edited:
Hey, sorry about that. Try changing the line at the top from
Code:
#define showline(r, c) COL=12; ROW=r; if(c < 12)COL=c; for ( k = 0; k < brzina; k++);
to
Code:
#define showline(r, c) COL=12; ROW=r; if(12 > (unsigned char)(c))COL=c; for ( k = 0; k < brzina; k++);

That way the column will be disabled when i-x > 12 and when i-x < 0 (I hope that makes sense).
 
Last edited:
You were right, now it is working only on software, and it is sooo good. Now only thing i need to learn is how to make that if i enter some world that it would go to exact place of code and to show. But it is not a problem even if i cant do that, you got it to work for me and i appreciate it very very much !

I wil put 4 keys insted of 4 inputs for cd4072, and if i could, i will try to make a "pong" game on it

EDIT: Ye, but question now is can i put push buttons to higher 4 bits of column port?
 
Last edited:
I'm glad it's working

lol, I thought I read that you're going to use 4 switches to make a pong game on the 4072..

Which 8051 microcontroller are you using? You should be able to use the other pins as inputs, just make sure the port is set to an appropriate value.
 
According to the datasheet, you just write a '1' to the bits of the port that you want to use as inputs. Your switches can then connect from the port pins to GND (0V).

Change the code thusly
Code:
#define showline(r, c) COL=12; ROW=(r); if(12 > (unsigned char)(c))COL=(c) | 0xF0; for ( k = 0; k < brzina; k++);

The logical ORing of 0xF0 (11110000 binary) with the column value is setting the top 4 port bits high.
 
So i just replace this row of code, and then i define sbit KEY1=P1^4 (and 5,6,7), and then to detect if it is pressed or not:

If (KEY1==0) {do this}?

And no resistor is needed?
 
That looks ok to me (after glancing at https://www.keil.com/support/man/docs/c51/c51_le_sbit.htm).

You should have a look at the datasheet yourself to further your learning, but it says that the port pin in its high state has either a weak or a medium pullup active. When you pull it low with the switch, the medium pullup will turn off, and just the weak pullup will be on. Therefore no resistor pullup is required.
 
NVM, + and - of that LED where connected. Look how it work now

https://www.youtube.com/watch?v=GrP_Gn8Pz9Y&feature=youtu.be


Ok, i will put that together when i buy some more buttons. Now after finished desoldering of 4072, LED in last col, 5 row from bottom dont light up when it need to

I checked with other battery and it light up, so the problem is not in LED. Everything else is ok and show perfectly..
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…