Page 1 of 1

5x7 Led Matrix

PostPosted: Sun Dec 30, 2012 12:20 am
by Tianjin
Hi all, I was trying to display alphabets A to Z using p18f4520,ULN2003 and 5x7 led matrix.
I use mplab c compiler,20MHz, and the program was compiled successfully but I doesn't work on protues simulation.
Here's z code, would u tell me why it doesn't display the letters?

unsigned short count, column, num, repeat;
unsigned char fill_1[130]={ 0x7e, 0x09, 0x09, 0x09, 0x7E, // A
0x7f, 0x49, 0x49, 0x49, 0x36, // B
0x3e, 0x41, 0x41, 0x41, 0x22,
0x7f, 0x41, 0x41,0x22, 0x1c,
0x7f, 0x49, 0x49, 0x49, 0x63,
0x7f, 0x09, 0x09, 0x09, 0x01,
0x3e, 0x41, 0x41, 0x49, 0x7a,
0x7f, 0x08, 0x08, 0x08, 0x7f,
0x00, 0x41, 0x7f, 0x41, 0x00, // I
0x20, 0x40, 0x41, 0x3f, 0x01,
0x7f, 0x08, 0x14, 0x22, 0x41,
0x7f, 0x40, 0x40, 0x40, 0x60,
0x7f, 0x02, 0x04, 0x02, 0x7f,
0x7f, 0x04, 0x08, 0x10, 0x7f,
0x3e, 0x41, 0x41, 0x41, 0x3e,
0x7f, 0x09, 0x09, 0x09, 0x06,
0x3e, 0x41, 0x51, 0x21, 0x5e,
0x7f, 0x09, 0x19, 0x29, 0x46,
0x46, 0x49, 0x49, 0x49, 0x31, // S
0x01, 0x01, 0x7f, 0x01, 0x01,
0x3f, 0x40, 0x40, 0x40, 0x3f,
0x1f, 0x20, 0x40, 0x20, 0x1f,
0x3f, 0x40, 0x30, 0x40, 0x3f,
0x63, 0x14, 0x08, 0x14, 0x63,
0x07, 0x08, 0x70, 0x08, 0x07,
0x61, 0x51, 0x49, 0x45, 0x43 // Z
};

//====================MAIN================================

void main(void)
{

ADCON1 = 0b00111101; // configure RA2 and RA5 as digital I/O
ADCON2 = 0b10110100; //// Set result right justified, manual acquisition time, Fosc/4

TRISD=0b00000000; //configure PORTD as output
TRISC=0b00000000; // RC7(RX) as input , RC6(TX) as output
PORTC=0; //intial value of PORTC is zero
PORTD=0; //intial value of PORTD is zero

do{
// Display 26 alphabets
for (num=0; num<26; num++) {

for (repeat=0; repeat<100; repeat++){
column = 1;
for(count = num*5;count < (num*5+6);count++){
PORTC = fill_1[count];
PORTD = column;
Delay10TCYx(200);
column = column<<1;
}
}
}
}
while(1);
}

Re: 5x7 Led Matrix

PostPosted: Sun Dec 30, 2012 7:35 am
by ABSF
Did you try slowing down the mcu clock in Proteus, to say 1 or 2 MHz.... What is the proteus loading when you run the simulator?

I checked your codes and it seems OK to me.

Allen

Re: 5x7 Led Matrix

PostPosted: Sun Dec 30, 2012 3:24 pm
by Tianjin
ABSF WROTE:Did you try slowing down the mcu clock in Proteus, to say 1 or 2 MHz.... What is the proteus loading when you run the simulator?

I checked your codes and it seems OK to me.

Allen

thank u. look ,did u see the letters well? I can't see each letters well.

Re: 5x7 Led Matrix

PostPosted: Thu Apr 11, 2013 12:49 am
by takao21203
Normally a font table is placed in the FLASH, so you declare it const.

Also these matrix modules are multiplexed. Depends on the font table, you may have to shuffle the data.

Try to get the matrix drive right at first.

Use conditional compile, and a switch, so you either get data from the table, or you load a test pattern.

When the test pattern works (multiplexing), work out with the font table.

For instance Row 0: 00000001. Row 1: 00000010. And so forth. Checker pattern.

I have built many such circuits, it took hours sometimes. It is not so easy.