8x8 LED Matrix marquee

General discussion on mikroC.
Author
Message
Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

8x8 LED Matrix marquee

#1 Post by Hearty » 02 Mar 2010 15:39

Hi,

Before all, my english is not my native language,
so, sorry for any mystake, and more over, I'm very new in PIC world.

I'm trying to translate an old code from a user named Xor.
The original code is in MikroB, I want it in MikroC. :?:
I working on a 16F876A with 8x8 Led matrix

Original code:

Code: Select all

' This code tested on 18F452 @ 8MHz - Default Configs

const font5x7  as byte[215] = (
        $3E, $51, $49, $45, $3E,' 0
        $00, $42, $7F, $40, $00,' 1
        $42, $61, $51, $49, $46,' 2
        $21, $41, $45, $4B, $31,' 3
        $18, $14, $12, $7F, $10,' 4
        $27, $45, $45, $45, $39,' 5
        $3C, $4A, $49, $49, $30,' 6
        $01, $71, $09, $05, $03,' 7
        $36, $49, $49, $49, $36,' 8
        $06, $49, $49, $29, $1E,' 9
        $00, $36, $36, $00, $00,' :
        $00, $56, $36, $00, $00,'
        $00, $08, $14, $22, $41,' <
        $14, $14, $14, $14, $14,' =
        $41, $22, $14, $08, $00,' >
        $02, $01, $51, $09, $06,' ?
        $32, $49, $79, $41, $3E,' @
        $7E, $11, $11, $11, $7E,' A
        $7F, $49, $49, $49, $36,' B
        $3E, $41, $41, $41, $22,' C
        $7F, $41, $41, $22, $1C,' D
        $7F, $49, $49, $49, $41,' E
        $7F, $09, $09, $01, $01,' F
        $3E, $41, $41, $51, $32,' G
        $7F, $08, $08, $08, $7F,' H
        $00, $41, $7F, $41, $00,' I
        $20, $40, $41, $3F, $01,' J
        $7F, $08, $14, $22, $41,' K
        $7F, $40, $40, $40, $40,' L
        $7F, $02, $04, $02, $7F,' M
        $7F, $04, $08, $10, $7F,' N
        $3E, $41, $41, $41, $3E,' O
        $7F, $09, $09, $09, $06,' P
        $3E, $41, $51, $21, $5E,' Q
        $7F, $09, $19, $29, $46,' R
        $46, $49, $49, $49, $31,' S
        $01, $01, $7F, $01, $01,' T
        $3F, $40, $40, $40, $3F,' U
        $1F, $20, $40, $20, $1F,' V
        $7F, $20, $18, $20, $7F,' W
        $63, $14, $08, $14, $63,' X
        $03, $04, $78, $04, $03,' Y
        $61, $51, $49, $45, $43)' Z

sub procedure matrixchar(dim sh, indx as byte)
   For ccpr1L = 1 to 15
      LATB = sh
      For adresh = 0 to 4
         adresl = font5x7[indx+adresh]
         LATC = not(adresl)
         delay_5500us
         LATB = LATB << 1
      Next adresh
   Next ccpr1l
end sub

main:
TRISB = 0
TRISC = 0
LATB = 255
LATC = 0
ADCON1 = 6

While 1=1
   For ccpr1h = 0 to 211 Step 5
      matrixchar(4,ccpr1h)
   Next ccpr1h
   ccpr2l = 1
   For ccpr1h = 0 to 7
      matrixchar(ccpr2l, 85)
      ccpr2l = ccpr2l << 1
   Next CCPR1H
   ccpr2l = 128
   For ccpr1h = 0 to 7
      matrixchar(ccpr2l, 85)
      ccpr2l = ccpr2l >> 1
   Next CCPR1H
Wend

end.


Translated code:

Code: Select all

 const unsigned char font8x8[152]={
                                   0xEB, 0x81, 0x98, 0x3D, 0xBC, 0x19, 0x81, 0xD7,
                                   0xC3, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0xC3,
                                   0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xbd, 0x81, 0xff,
                                   0xEB, 0x81, 0x98, 0x3D, 0xBC, 0x19, 0x81, 0xD7,
                                   0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,
                                   0x42, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0x42,
                                   0xC3, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0xC3,
                                   0xC3, 0xC3, 0x3C, 0x3C, 0x3C, 0x3C, 0xC3, 0xC3,
                                   0xC3, 0xC3, 0x00, 0x18, 0x18, 0x00, 0xC3, 0xC3,
                                   0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3,
                                   0x24, 0x24, 0xE7, 0x00, 0x00, 0xE7, 0x24, 0x24,
                                   0x18, 0x24, 0x42, 0x99, 0x99, 0x42, 0x24, 0x18,
                                   0x00, 0x62, 0x62, 0x7E, 0x62, 0x62, 0x62, 0x00,
                                   0x00, 0x7E, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00,
                                   0x00, 0x3C, 0x62, 0x7E, 0x62, 0x62, 0x62, 0x00,
                                   0x00, 0x7C, 0x62, 0x7C, 0x62, 0x62, 0x62, 0x00,
                                   0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00,
                                   0x00, 0x42, 0x24, 0x18, 0x18, 0x18, 0x3C, 0x00,
                                   0x18, 0x0C, 0x06, 0xFF, 0xFF, 0x06, 0x0C, 0x18
                                   };

void LeftScroll(int indx, int flg)
{
int t0, t1, t2, t3 ;
   for (t0=0;t0<8;t0++)
   {
      PORTC = 1;
      t3 = 0;
      for (t1=0;t1<8;t1++)
      {
         if (t1==flg)
         {
            t2 = 0;
            t3++;
            if(t1 < 2)
            {
            flg = t1 + 8;
            }
         else
            {
            t2 = font8x8[indx+t1-t3];
            }
         }
         PORTB =~t2;
         delay_us(3500);
         PORTC = PORTC << 1;
     }
   }

 }
void main()
{



TRISB = 0;
TRISC = 0;
PORTC = 0;
PORTB = 0;
ADCON1 = 6;

while (1)  {
   ADRESL = 0;
   ADRESH = 8;
   while (ADRESL < 152) {
      LeftScroll(ADRESL, ADRESH);
      ADRESL++;
      ADRESH--;
      if (ADRESH == 0)
      {
       ADRESH = 8 ;
       }
   }
}

}
My translation seems to be wrong
the display result is bad (wrong) and erratic.

Anyone can drive me on the good way?

Best regards,

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#2 Post by Hearty » 04 Mar 2010 08:49

Nobody can help me?

My question is wrong or insane or something like that?
Maybe this problem is threaded somewhere many time,
so please just a link.

Regards,

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#3 Post by Hearty » 08 Apr 2010 17:16

more than 100 views and no answer,
I can't to thank you.

:(

Bonca
Posts: 319
Joined: 18 Mar 2009 07:55

Re: 8x8 LED Matrix marquee

#4 Post by Bonca » 14 Apr 2010 06:05

Hello!
Send me a schematic and I will try to simulate on Proteus.

Bonca

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#5 Post by Hearty » 14 Apr 2010 07:46

Bonca wrote:Hello!
Send me a schematic and I will try to simulate on Proteus.

Bonca
Bonca, just for the answer god bless you.

Here is the link with the complete project,
including the Isis file, and MikroC files.

http://dl.free.fr/rONRc086y

My best regards,

:wink:

Bonca
Posts: 319
Joined: 18 Mar 2009 07:55

Re: 8x8 LED Matrix marquee

#6 Post by Bonca » 14 Apr 2010 14:52

Hi!
I have tested your code on Proteus. Led columns are lighting each in turn. Before next column turns on, previous column fades. Is it that you have expected?
8x8.jpg
8x8.jpg (107.43 KiB) Viewed 14265 times
Bonca

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#7 Post by Hearty » 14 Apr 2010 14:55

Hi,

no, In my mind it will display the listed hex
chararactères at up of the code source.

the font8x8[152]= variable

Bonca
Posts: 319
Joined: 18 Mar 2009 07:55

Re: 8x8 LED Matrix marquee

#8 Post by Bonca » 15 Apr 2010 08:36

Don't be sad! If you modify your program, send it again and I will simulate on Proteus.

Bonca

basicbasic111
Posts: 127
Joined: 26 Jan 2010 17:01

Re: 8x8 LED Matrix marquee

#9 Post by basicbasic111 » 15 Apr 2010 19:49

hi,hearty

i am afraid the codes from xor u posted here

do not match your translated codes


the orginal codes should be as follows:

Code: Select all

const font5x7  as byte[220] = (
        $3E, $51, $49, $45, $3E,' 0
        $00, $42, $7F, $40, $00,' 1
        $42, $61, $51, $49, $46,' 2
        $21, $41, $45, $4B, $31,' 3
        $18, $14, $12, $7F, $10,' 4
        $27, $45, $45, $45, $39,' 5
        $3C, $4A, $49, $49, $30,' 6
        $01, $71, $09, $05, $03,' 7
        $36, $49, $49, $49, $36,' 8
        $06, $49, $49, $29, $1E,' 9
        $00, $36, $36, $00, $00,' :
        $00, $56, $36, $00, $00,'
        $00, $08, $14, $22, $41,' <
        $14, $14, $14, $14, $14,' =
        $41, $22, $14, $08, $00,' >
        $02, $01, $51, $09, $06,' ?
        $32, $49, $79, $41, $3E,' @
        $7E, $11, $11, $11, $7E,' A
        $7F, $49, $49, $49, $36,' B
        $3E, $41, $41, $41, $22,' C
        $7F, $41, $41, $22, $1C,' D
        $7F, $49, $49, $49, $41,' E
        $7F, $09, $09, $01, $01,' F
        $3E, $41, $41, $51, $32,' G
        $7F, $08, $08, $08, $7F,' H
        $00, $41, $7F, $41, $00,' I
        $20, $40, $41, $3F, $01,' J
        $7F, $08, $14, $22, $41,' K
        $7F, $40, $40, $40, $40,' L
        $7F, $02, $04, $02, $7F,' M
        $7F, $04, $08, $10, $7F,' N
        $3E, $41, $41, $41, $3E,' O
        $7F, $09, $09, $09, $06,' P
        $3E, $41, $51, $21, $5E,' Q
        $7F, $09, $19, $29, $46,' R
        $46, $49, $49, $49, $31,' S
        $01, $01, $7F, $01, $01,' T
        $3F, $40, $40, $40, $3F,' U
        $1F, $20, $40, $20, $1F,' V
        $7F, $20, $18, $20, $7F,' W
        $63, $14, $08, $14, $63,' X
        $03, $04, $78, $04, $03,' Y
        $61, $51, $49, $45, $43,' Z
        $3E, $51, $49, $45, $3E)' 0
        
sub procedure LeftScroll(dim indx, flg as byte)
dim t0, t1, t2, t3 as byte
   For t0 = 0 to 4
      LATB = 1
      t3 = 0
      For t1 = 0 to 7
         If t1 = flg Then
            t2 = 0
            inc(t3)
            If t1 < 2 Then flg = t1 + 5 End If
         Else
            t2 = font5x7[indx+t1-t3]
         End If
         LATC = not(t2)
         delay_us(3500)
         LATB = LATB << 1
      Next t1
   Next t0
end sub

main:
TRISB = 0
TRISC = 0
LATB = 0
LATC = 0
ADCON1 = 6

While 1=1
   ADRESL = 0
   ADRESH = 5
   While ADRESL < 215
      LeftScroll(ADRESL, ADRESH)
      inc(ADRESL)
      If dec(ADRESH) = 0 Then ADRESH = 5 End If
   Wend
Wend

end.
i have a few suggestions for you

1) if you want to similate the codes on proteus,
you just type" matrix"
that would save you a lot of time making the transistor connections

2) may i know if you would like to drive
only one 8x8 matrix display?

i do not have codes for that

but i have codes for 16x64 ( driven by max7219 spi)
with proteus files ( written in mickro c pro)
if u like it i can send u everything
perhaps u may get some ideas
how to drive one single 8x8 display


cheers

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#10 Post by Hearty » 16 Apr 2010 10:45

BasicBasic111, thank you for your suggestion.

In fact, I want a simple circuit, no external piece,
with one display at this time,
to understand how coding this.

I know there are many other ways to achieve
this display,

for exemple I coded myself this one:

Code: Select all

/* **********************************************************
         Exercice d'affichage multiplexé sur une matrice
         de 8x8 LEDs.          PIC16F876A
         - Anodes communes sur le portB et Cathodes sur PortC

 ***********************************************************/
int i,j;                     // variable de comptage
int v,lettre;                   // variable de fréquence de scrolling
//unsigned short IncCol;    // Variable d'incrémentation de colonne
unsigned short offset;
void main()    // Programme principal
{
// Préparation du caractère affichable
// Tableau de huits entiers (8x8) */

const unsigned char colonnes[][8]={
                                   {0xEB, 0x81, 0x98, 0x3D, 0xBC, 0x19, 0x81, 0xD7},
                                   {0xC3, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0xC3},
                                   {0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xbd, 0x81, 0xff},
                                   {0xEB, 0x81, 0x98, 0x3D, 0xBC, 0x19, 0x81, 0xD7},
                                   {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55},
                                   {0x42, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0x42},
                                   {0xC3, 0xC3, 0x3C, 0x24, 0x24, 0x3C, 0xC3, 0xC3},
                                   {0xC3, 0xC3, 0x3C, 0x3C, 0x3C, 0x3C, 0xC3, 0xC3},
                                   {0xC3, 0xC3, 0x00, 0x18, 0x18, 0x00, 0xC3, 0xC3},
                                   {0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3},
                                   {0x24, 0x24, 0xE7, 0x00, 0x00, 0xE7, 0x24, 0x24},
                                   {0x18, 0x24, 0x42, 0x99, 0x99, 0x42, 0x24, 0x18},
                                   {0x00, 0x62, 0x62, 0x7E, 0x62, 0x62, 0x62, 0x00},
                                   {0x00, 0x7E, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00},
                                   {0x00, 0x3C, 0x62, 0x7E, 0x62, 0x62, 0x62, 0x00},
                                   {0x00, 0x7C, 0x62, 0x7C, 0x62, 0x62, 0x62, 0x00},
                                   {0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00},
                                   {0x00, 0x42, 0x24, 0x18, 0x18, 0x18, 0x3C, 0x00},
                                   {0x18, 0x0C, 0x06, 0xFF, 0xFF, 0x06, 0x0C, 0x18},

                                   };
ADCON0=0;  // ADC désactivé
TRISA=0;   // PORTA configuré en sortie
TRISB=0;   // PORTB configuré en sortie
TRISC=0;   // PORTC configuré en sortie

PORTA=0;   // mise à zéro des ports A
PORTB=0;   // mise à zéro des ports B
PORTC=0;   // mise à zéro des ports C
lettre=0;
v=0;
j=0;
offset=0;  PortC = 0;
   while(1)                            // Boucle infinie
{
  for (i=0;i<8;i++)                 // itération sur les 8 lignes
  {

    PortB = (colonnes[lettre][i])<<offset;  // output valeur colonnes de la ligne courante
    PortC = 1<<i;                      // sélection ligne courante

    if(i==7)
    {j++;}
    Delay_ms(1);
  }
  // après 32 affichages (32ms), scroll de l'affichage (Scrolling part

  if(v==15)
  {
    offset = (offset + 1) % 8;
     v=0;
  }
   if(lettre==18)
    {lettre=0; j=0;
     }
  if(j==200){
  lettre++;
  j=0; }
  v++;

   
}

}
It work to display, the scroll work too but with some mystake,
this is my problem, the scrolling
and more over, scrolling all the charactère smoothly one after one (again sorry for my poor english)

try it with the same schematic uploaded before,
you'll see what I mean.

Edit:
Of course the display with led and transistors is bad to fast refresh on isis,
but I tried the code in real, on a bread board, so i can see it more faster...
simulation is just to see something like to have an approach.


Thanks for your attention.

basicbasic111
Posts: 127
Joined: 26 Jan 2010 17:01

Re: 8x8 LED Matrix marquee

#11 Post by basicbasic111 » 16 Apr 2010 13:13

hi,

i guess you are getting there

way to go, pal

i did try your new codes

on my proteus

but my proteus crashed lol
:D

cpu load tends to reach 90 to 100

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#12 Post by Hearty » 17 Apr 2010 08:41

Oh god! :)

Sorry for that,
i'm unlucky with that problem,

I'll try to find a new orientation, garden or clay sculpt... :lol:

Anyway, thank you for trying.

Have a nice day

basicbasic111
Posts: 127
Joined: 26 Jan 2010 17:01

Re: 8x8 LED Matrix marquee

#13 Post by basicbasic111 » 20 Apr 2010 09:42

it is ok

my proteus crashes all the time
by the way how is your matrix ?


:)

Hearty
Posts: 11
Joined: 02 Mar 2010 14:10

Re: 8x8 LED Matrix marquee

#14 Post by Hearty » 28 May 2010 18:36

Hi BasicBasic

Sorry for the late answer,
I was in billions books of C
sleep on C, eat C, C..C CC .cccccc argh!! :D

I re do all from zero,
And now I solved my problem,
and understand what I do.

My Led matrix work as well, and scroll as I want.

I'm try now to understand how, I can make a relation between
a string characteres and the array ASCII code.

and again, eat and sleep C C C...cccc..c :D

Here is a test demonstration:
Youtube Video

;)

basicbasic111
Posts: 127
Joined: 26 Jan 2010 17:01

Re: 8x8 LED Matrix marquee

#15 Post by basicbasic111 » 29 May 2010 07:12

WOW!!!!


:)
Very well done!!!

I saw your demo and it was so nice.


Way to go, pal!

Post Reply

Return to “mikroC General”