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.

[SOLVED] LED Matix problem, ghosting

Status
Not open for further replies.

hemanteda

Member level 1
Joined
May 5, 2011
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,550
Hi everyone,

This is in continuation to the 16x16 LED matrix I've been trying to build. I was having current issues earlier and as suggested in the forum I'm using ULN2003 and UDN2981 now with no hardware issues (or thats what I feel).

My current config is PIC16F877 ->74HC573->ULN->Matrix
->74HC573->UDN->100 ohm->Matrix

The problem is that I see ghost (dimly lit LED) for each LED thats on. I'm not sure if this is a hardware issue or software. The pic is running at 16Mhz (external crystal) My code is as follows (CCS, Refresh() is called using Timer0 interrupt - setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);)


void Refresh(void)
{
unsigned int8 HighByte, LowByte;

//get low byte
LowByte = make8(LED[Row_Counter],0);
//get high byte
HighByte = make8(LED[Row_Counter],1);


//output lowbyte to latch 1
Latch_Data(Latch_1, PORT_D, LowByte);
//output highbyte to latch 2
Latch_Data(Latch_2, PORT_D, HighByte);


// switch the current row on, latch 3 and 4
switch(Row_Counter)
{
case 0:
Latch_Data(Latch_3, PORT_D, 0b00000001);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 1:
Latch_Data(Latch_3, PORT_D, 0b00000010);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 2:
Latch_Data(Latch_3, PORT_D, 0b00000100);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 3:
Latch_Data(Latch_3, PORT_D, 0b00001000);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 4:
Latch_Data(Latch_3, PORT_D, 0b00010000);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 5:
Latch_Data(Latch_3, PORT_D, 0b00100000);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 6:
Latch_Data(Latch_3, PORT_D, 0b01000000);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 7:
Latch_Data(Latch_3, PORT_D, 0b10000000);
Latch_Data(Latch_4, PORT_D, 0b00000000);
break;
case 8:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00000001);
break;
case 9:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00000010);
break;
case 10:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00000100);
break;
case 11:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00001000);
break;
case 12:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00010000);
break;
case 13:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b00100000);
break;
case 14:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b01000000);
break;
case 15:
Latch_Data(Latch_3, PORT_D, 0b00000000);
Latch_Data(Latch_4, PORT_D, 0b10000000);
break;
}


//increment Row_Counter
Row_Counter++;
//check and reset row counter
if(Row_Counter > 15) Row_Counter = 0;
}






//loads new data into a 74HC537 latch
//arguments pin = pin to which the latch enable is connected, data to be loaded, port on which the bus is
void Latch_Data(unsigned int16 pin, unsigned int8 port, unsigned int8 data)
{
//put latch enable pin to high
output_high(pin);

//select port connected to bus, output data on port
switch(port)
{
case 0:
output_a(data);
break;
case 1:
output_b(data);
break;
case 2:
output_c(data);
break;
case 3:
output_d(data);
break;
case 4:
output_e(data);
break;
}

//close latch
output_low(pin);
}

Any suggestions?
 

That is very inefficient code!
For selecting the rows, look at the '<<' function to shift bits to the left. You can replace all the switch/case statement with something like (I haven't actually tried this):

unsigned int RowBit;

void SelectRow(int RowCounter))
{
RowBit = 1 << RowCounter;
Latch_Data(Latch_3, PORT_D, RowBit & 0x00FF);
Latch_Data(Latch_4, PORT_D, RowBit & 0xFF00);
}

However, I think the ghosting problem is just due to residual charge on the curent switches, try inserting a short gap between selecting digits and in that gap turn all LEDs off.

Brian.
 

Thanks Brian! I updated the code as per your suggestion... But I still have the ghosting problem, I tried the all LEDs off with a lil delay but it didnt solve the issue... Any other ideas? also could you explain the LED switch off delay a bit further, maybe I'm doing it wrong
 

Code:
//put latch enable pin to high
output_high(pin);

switch(port)
{
case 0:
output_a(data);
break;
case 1:
output_b(data);
break;
case 2:
output_c(data);
break;
case 3:
output_d(data);
break;
case 4:
output_e(data);
break;
}

//close latch
output_low(pin);

You have the latch in "open" state while changing the port. Try to strobe the latch after changing the port.
 

By switch off delay what mean is you should turn all the LEDs off for a brief period before writing the next pattern out to them. I thnk the ghosting is caused because the LEDs are not having time to turn off before the next signal is sent out to drive them. Bjuric is correct, try movng the "output_high(pin)" line driving the enable pin so it is immediately before the "output_low(pin)" command so the data is set up and ready to go before toggling the latch. There could be other reasons, can you post a schematic of the LED driving circuits.

Brian.
 

Before you latch the data you need to turn off the rows:

Code:
//get low byte
LowByte = make8(LED[Row_Counter],0);
//get high byte
HighByte = make8(LED[Row_Counter],1);

[COLOR="red"]Latch_Data(Latch_3, PORT_D, 0b00000000);  // add this
Latch_Data(Latch_4, PORT_D, 0b00000000);  // add this[/COLOR]

//output lowbyte to latch 1
Latch_Data(Latch_1, PORT_D, LowByte);
//output highbyte to latch 2
Latch_Data(Latch_2, PORT_D, HighByte);
 

Are all ICs properly protected by power decoupling capacitors ?
I had some problem like that, whose effect increased to most faraway LEDs from microcontroller.

+++
 

Put oscilloscope probe on the output of PIC and input of ULN & UDN and LED pins, to see the voltage level and signal shape. it will help you to make sure the problem is from SW side or form HW side.

You told "I see ghost", if you mean the light is fluctuating it may from SW side. If it is not turn on compactly it may from HW. Be aware the Vce (saturation voltage of Collector Emitter)of UDN is almost 2v. So you may need to recalculate the resistance of limiting resistor.
 

First of all my apologies for not replaying early enough, I wasnt well and have tried all the solutions everybody suggested today only. THE GHOST IS GONE! For the curious kind upand_at_them's solution fixed it, thanks to you buddy. Also all the advise was quite helpful, thanks everyone!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top