Jump to content
43oh

LED matrix display pixel ghosting


Recommended Posts

I constructed a simple 8x8 LED matrix display using two 74595 shift registers to drive the rows and columns. I created an array to output to the display. I have it scrolling some characters (currently two, I plan to expand it to many more with the addition of an I2C EEPROM). The uC is running @ 1MHZ off of the internal DCO, could this be too slow?

 

The code works and the matrix displays what it I told it to BUT there are undesired "ghost" pixels which flicker on and off in a pattern. I have switched out the 74595 registers and that didn't seem to fix it.

 

Has anyone seen this before and know how to fix it?

 

Here is a video of it in operation. The code is posted bellow.

The video quality is poor but the horizontal "ghosting" is still very evident, the random vertical lines are also occurring and are not just an affect of the poor frame rate.

 

 

#include  

#define CLOCK BIT4
#define DATA BIT5
#define LATCH BIT3
#define delayLoop 15
#define arrayLength 13

void delay(unsigned int ms);
void pulseClock(void);
void shiftOut(char val);
void pinWrite(unsigned int bit, unsigned char val);

const char index[8] = {0x74,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE};
const char font[arrayLength][8] ={
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x00, 0x00,
0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00, 0x00,
0x31, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x00,
0x49, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x20, 0x7f, 
0x49, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x10, 0x20,
0x49, 0x49, 0x49, 0x31, 0x00, 0x7f, 0x20, 0x10,
0x46, 0x49, 0x49, 0x49, 0x31, 0x00, 0x7f, 0x20,
0x00, 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, 0x7f};

void main (void){

BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
WDTCTL = WDTPW + WDTHOLD;			// Disable WDT               
P1DIR |= (CLOCK + DATA + LATCH);	// Set P1DIR

while(1){				
	int i, j, t;
	for(j = 0; j < arrayLength; j++){
		for(t = 0; t < delayLoop; t++){
			for(i = 0; i < 8; i++){
				pinWrite(LATCH,0);
				shiftOut(index[i]);
				shiftOut(font[j][i]);
				pinWrite(LATCH,1);
			}
		}
	}
}
}

void delay(unsigned int ms){
	while (ms--){
       __delay_cycles(1000);
   }
}

void pulseClock(void){
P1OUT |= CLOCK;
P1OUT ^= CLOCK;
}

void shiftOut(char val){
//P1OUT &= ~LATCH;	
char i;
 	for(i = 0; i < 8; i++){
   	pinWrite(DATA, (val & (1 << i)));
       pulseClock();
   }
 	//P1OUT |= LATCH;
 	//P1OUT &= ~LATCH;	
}

void pinWrite(unsigned int bit, unsigned char val){
if(val){
   	P1OUT |= bit;
 	}else{
   	P1OUT &= ~bit;
 	}
}

Link to post
Share on other sites

Here is how I write to my 74hc595, and I am running at 1Mhz.

 

When writing to the 74HC595, I always put the latch on logic 0.

And shift data in from the going from logic 0 to logic 1 on the clock pin.

Then at the end of my shifting in data, put the latch pin to logic 1.

 

If I am looking at your code correctly, your clocking High to low on you clock pin when shifting in. Try going from low to high.

 

I had to re-edit this part.

 

If you need a delay use a the delay call for ms delay or maybe a 'for' statement after shifting in the data.

 

for(j = 0; j < arrayLength; j++)

{

for(t.......) // this part in the program is ok

{

for(i = 0; i < 8; i++)

{

pinWrite(LATCH,0);

shiftOut(index);

shiftOut(font[j]);

pinWrite(LATCH,1);

// short ms delay here maybe would help...

}

 

}

}

 

 

 

Also check for loose wires and make sure you don't have any floating logic pins...

Link to post
Share on other sites

it looks like a similar problem i had with a 3 digit display that was multiplexed. My issue was switching two fast and the display would ghost with the digits next to it.

I found 2 solutions which may help you.

 

One is set a longer delay between character writes/column writes. Adding a few more ms to a delay may work. You will have to play around with it to find the spot that needs the delay, but my guess is after the shiftouts but before that for loop ends

 

the other may not work for you since I dont know what your circuit looks like, but I also added some pulldown resistors on the data lines, but i was using transistors to multiplex my display. (8 character lines + 3 multiplex lines) after doing this i was able to run it much faster, but i lost some brightness on faster speeds.----- maybe use the built in pulldowns/pullups? remember to use the one for the correct initial state- (IE latch - low = pulldown )

Link to post
Share on other sites
  • 2 weeks later...
const char index[8] = {0x74,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE};

 

I'm guessing that should actually be a 0x7F instead of 0x74?

 

Double check your font data, are you using 1 led at a time? or multiple leds?

 

That fixed everything. I've found myself mixing up 'F' and '4' before when dealing with HEX numbers...

Link to post
Share on other sites
Haven't found a good schematic drawing program anyone have any suggestions for a free one?

 

See this thread.

 

I've had pretty good results with Eagle, seems to be lacking some older and newer devices, though.

Here's the library I created for the 'G2231, same pinout as 'G2211.

 

If/when you get Eagle installed, just extract the zip into the lbr folder in the Eagle install folder.

msp430g2231.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...