Aê galera, sou novo no laboratório, não sei muito, mas pretendo ajudar como puder.

Seguinte, estou tetando fazer um painel de led, fazer as freses com animações e tals...

Como não sou muito bom, fiu vasculhar na net e achei um projeto legal de painel de led, só que o cara usou um AT89C2051 e uso Pic e compilador CCS, e gostaria de uma ajudar para eu poder entender o programa e passar para o compilador CCS, e gostaria também de uma opinião (dica, qualquer coisa ).

As partes que eu não entendi são:

---------------------------------------------

void init_timer(void)
{
    TMOD=0x01;
    TH0=0xfb;
    TL0=0x00;
    TR0=1;
    ET0=1;
    EA=1;
}


void Timer0 (void) interrupt 1 //using 2
{
    unsigned char index;
    unsigned char i,tmp1;
    unsigned char code rowtable[]={0,1,2,4,8,16};

    //TH0=0xfb; //48fps
    //TL0=0x00;
    ET0=0;
    TH0=0xf8; //30fps
    TL0=0x00;
    Row5=1; Row4=1; Row3=1; Row2=1; Row1=1;
    index++;
    if (index>5) index=1;

    //column
    tmp1=rowtable[index];
    for (i=1; i<33; i++)
    {
        Cdata=!(column[i] & tmp1);
        Cclock=1;
        Cclock=0;
    }

    //row
    Clatch=1;
    Clatch=0;

    switch (index)
    {
        case 1:
            Row1=0;
            break;
        case 2:
            Row2=0;
            break;
        case 3:
            Row3=0;
            break;
        case 4:
            Row4=0;
            break;
        case 5:
            Row5=0;
            break;
    }
    ET0=1;
}

---------------------------------------------

 

Segue o programa completo:

#include <reg51.h>
 
sbit Cclock=P1^1;
sbit Clatch=P1^0;
sbit Cdata=P3^7;

sbit Row5=P3^0;
sbit Row4=P3^1;
sbit Row3=P3^2;
sbit Row2=P3^3;
sbit Row1=P3^4;

unsigned int shift_delay;

unsigned char code font[96][5] =
{
    {0x00, 0x00, 0x00, 0x00, 0x00},  //
    {0x00, 0x00, 0x1d, 0x00, 0x00},  //
    {0x00, 0x18, 0x00, 0x18, 0x00},  //
    {0x0a, 0x1f, 0x0a, 0x1f, 0x0a},  //
    {0x09, 0x15, 0x1f, 0x15, 0x12},  //
    {0x11, 0x02, 0x04, 0x08, 0x11},  //
    {0x0a, 0x15, 0x15, 0x0f, 0x05},  //
    {0x00, 0x14, 0x18, 0x00, 0x00},  //
    {0x00, 0x00, 0x0e, 0x11, 0x00},  //
    {0x00, 0x11, 0x0e, 0x00, 0x00},  //
    {0x0a, 0x04, 0x1f, 0x04, 0x0a},  //
    {0x04, 0x04, 0x1f, 0x04, 0x04},  //
    {0x00, 0x05, 0x06, 0x00, 0x00},  //
    {0x04, 0x04, 0x04, 0x04, 0x04},  //
    {0x00, 0x03, 0x03, 0x00, 0x00},  //
    {0x01, 0x02, 0x04, 0x08, 0x10},  //
    {0x0e, 0x13, 0x15, 0x19, 0x0e},  //0
    {0x00, 0x09, 0x1f, 0x01, 0x00},  //1
    {0x13, 0x15, 0x15, 0x15, 0x09},  //2
    {0x11, 0x11, 0x15, 0x15, 0x0a},  //3
    {0x18, 0x04, 0x04, 0x04, 0x1f},  //4
    {0x1d, 0x15, 0x15, 0x15, 0x12},  //5
    {0x0e, 0x15, 0x15, 0x15, 0x12},  //6
    {0x10, 0x10, 0x10, 0x17, 0x18},  //7
    {0x0a, 0x15, 0x15, 0x15, 0x0a},  //8
    {0x08, 0x15, 0x15, 0x15, 0x0e},  //9
    {0x00, 0x1b, 0x1b, 0x00, 0x00},  //
    {0x00, 0x15, 0x16, 0x00, 0x00},  //
    {0x00, 0x04, 0x0a, 0x11, 0x00},  //
    {0x0a, 0x0a, 0x0a, 0x0a, 0x0a},  //
    {0x00, 0x11, 0x0a, 0x04, 0x00},  //
    {0x08, 0x10, 0x15, 0x14, 0x08},  //
    {0x0e, 0x11, 0x15, 0x12, 0x0e},  //
    {0x0f, 0x12, 0x12, 0x12, 0x0f},  //A
    {0x1f, 0x15, 0x15, 0x15, 0x0a},  //B
    {0x0e, 0x11, 0x11, 0x11, 0x11},  //C
    {0x1f, 0x11, 0x11, 0x11, 0x0e},  //D
    {0x1f, 0x15, 0x15, 0x15, 0x15},  //E
    {0x1f, 0x14, 0x14, 0x14, 0x10},  //F
    {0x0e, 0x11, 0x15, 0x15, 0x17},  //G
    {0x1f, 0x04, 0x04, 0x04, 0x1f},  //H
    {0x00, 0x11, 0x1f, 0x11, 0x00},  //I
    {0x02, 0x01, 0x11, 0x11, 0x1e},  //J
    {0x1f, 0x04, 0x0c, 0x14, 0x03},  //K
    {0x1f, 0x01, 0x01, 0x01, 0x01},  //L
    {0x1f, 0x08, 0x04, 0x08, 0x1f},  //M
    {0x1f, 0x10, 0x0e, 0x01, 0x1f},  //N
    {0x0e, 0x11, 0x11, 0x11, 0x0e},  //O
    {0x1f, 0x14, 0x14, 0x14, 0x08},  //P
   //{0x0e, 0x11, 0x11, 0x0f, 0x01},  //Q
    {0x0e, 0x11, 0x15, 0x12, 0x0d},  //Q   
    {0x1f, 0x14, 0x14, 0x16, 0x09},  //R
    {0x09, 0x15, 0x15, 0x15, 0x12},  //S
    {0x10, 0x10, 0x1f, 0x10, 0x10},  //T
    {0x1e, 0x01, 0x01, 0x01, 0x1e},  //U
    {0x18, 0x06, 0x01, 0x06, 0x18},  //V
    {0x1f, 0x02, 0x04, 0x02, 0x1f},  //W
    {0x11, 0x0a, 0x04, 0x0a, 0x11},  //X
    {0x18, 0x04, 0x07, 0x04, 0x18},  //Y
    {0x11, 0x13, 0x15, 0x19, 0x11},  //Z
    {0x00, 0x1f, 0x11, 0x11, 0x00},  //
    {0x10, 0x08, 0x04, 0x02, 0x01},  //
    {0x00, 0x11, 0x11, 0x1f, 0x00},  //
    {0x04, 0x08, 0x10, 0x08, 0x04},  //
    {0x01, 0x01, 0x01, 0x01, 0x01},  //
    {0x00, 0x00, 0x10, 0x08, 0x00},  //
    {0x12, 0x15, 0x15, 0x15, 0x0f},  //a
    {0x1f, 0x09, 0x09, 0x09, 0x06},  //b
    {0x0e, 0x11, 0x11, 0x11, 0x0a},  //c
    {0x06, 0x09, 0x09, 0x09, 0x1f},  //d
    {0x0e, 0x15, 0x15, 0x15, 0x0d},  //e
    {0x0f, 0x14, 0x14, 0x10, 0x10},  //f
    {0x09, 0x15, 0x15, 0x15, 0x0e},  //g
    {0x1f, 0x08, 0x08, 0x08, 0x07},  //h
    {0x00, 0x00, 0x17, 0x00, 0x00},  //i
    {0x01, 0x01, 0x01, 0x01, 0x1e},  //j
    {0x1f, 0x04, 0x04, 0x0a, 0x11},  //k
    {0x1e, 0x01, 0x01, 0x01, 0x01},  //l
    {0x0f, 0x10, 0x0f, 0x10, 0x0f},  //m
    {0x1f, 0x10, 0x10, 0x10, 0x0f},  //n
    {0x0e, 0x11, 0x11, 0x11, 0x0e},  //o
    {0x1f, 0x12, 0x12, 0x12, 0x0c},  //p
    {0x0c, 0x12, 0x12, 0x12, 0x1f},  //q
    {0x1f, 0x08, 0x10, 0x10, 0x08},  //r
    {0x09, 0x15, 0x15, 0x15, 0x12},  //s
    {0x1e, 0x09, 0x09, 0x01, 0x02},  //t
    {0x1e, 0x01, 0x01, 0x02, 0x1f},  //u
    {0x18, 0x06, 0x01, 0x06, 0x18},  //v
    {0x1e, 0x01, 0x1e, 0x01, 0x1e},  //w
    {0x1b, 0x04, 0x04, 0x04, 0x1b},  //x
    {0x19, 0x05, 0x05, 0x05, 0x1e},  //y
    {0x11, 0x13, 0x15, 0x19, 0x11},  //z
    {0x00, 0x04, 0x0e, 0x11, 0x00},  //
    {0x00, 0x00, 0x1f, 0x00, 0x00},  //
    {0x00, 0x11, 0x0e, 0x04, 0x00},  //
    {0x08, 0x10, 0x08, 0x04, 0x08},  //
    {0x00, 0x00, 0x00, 0x00, 0x00}   //
};

unsigned char column[33]=
{
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
}; //display memory, cleared before used.


void delayms(unsigned int ms) //just about 1ms
{
    unsigned int n;
    unsigned char i;
    for (n=0; n<ms; n++)
    {
        for (i=0; i<200; i++);
    }
}


void init_timer(void)
{
    TMOD=0x01;
    TH0=0xfb;
    TL0=0x00;
    TR0=1;
    ET0=1;
    EA=1;
}


void Timer0 (void) interrupt 1 //using 2
{
    unsigned char index;
    unsigned char i,tmp1;
    unsigned char code rowtable[]={0,1,2,4,8,16};

    //TH0=0xfb; //48fps
    //TL0=0x00;
    ET0=0;
    TH0=0xf8; //30fps
    TL0=0x00;
    Row5=1; Row4=1; Row3=1; Row2=1; Row1=1;
    index++;
    if (index>5) index=1;

    //column
    tmp1=rowtable[index];
    for (i=1; i<33; i++)
    {
        Cdata=!(column[i] & tmp1);
        Cclock=1;
        Cclock=0;
    }

    //row
    Clatch=1;
    Clatch=0;

    switch (index)
    {
        case 1:
            Row1=0;
            break;
        case 2:
            Row2=0;
            break;
        case 3:
            Row3=0;
            break;
        case 4:
            Row4=0;
            break;
        case 5:
            Row5=0;
            break;
    }
    ET0=1;
}


void LED_put_byte(unsigned char inp)
{
    unsigned char i;
    for (i=1;i<33;i++) column[i]=column[i+1];
    column[32]=inp;
}


void LED_puts(unsigned char *lcd_string)
{
    unsigned char i,tmp_chr;
    while (*lcd_string)
    {
        tmp_chr=*lcd_string;

        for (i=0;i<5;i++)
        {
            LED_put_byte(font[tmp_chr-32][i]);
            delayms(shift_delay);
        }
        LED_put_byte(0); //space between character
        delayms(shift_delay);
        lcd_string++;
    }
}



void main()
{
    init_timer();

    shift_delay=100; //bigger = slower shift
    while(1)
    {
        LED_puts("8x32 Matrix LED: AT89C2051, 74HC595, "

                 "HEM1588 8x8, LEDFCS9012        ");
    }
}

 

 

Agradeço!

Exibições: 3408

Respostas a este tópico

Olá Marcus, você tem como postar o esquema também ?

Acho que vai ficar mais fácil entender...

abç

cara este tipo de projeto é bem complexo pois envolve muita multiplexação e isso bem complicado eu aconselo primeiro vc temtar usar uma matrix pequena tipo 3x3, 4x4 ou 8x8 feita com led mesmo pode ser caseira mesmo

o da uma olha neste circuito

e neste site pode te servir de ponto de vista http://www.best-microcontroller-projects.com/led-dot-matrix-display...

 

 

 

A~e galera alguem ja utilizou o ci 74hc164n?

estou fazendo alguns testes com ele para entender melor o seu funcionamento; estou fazendo assim:

#bit pino_data    = 0xf81.0

#bit pino_clock = 0xf80.0

int conta;

int comando;

main(){pino_data=0;

pino_clock=0;
while (TRUE){ 

set_tris_b(0x00);

  set_tris_a(0x00); 

for (conta =0; conta<8; conta++)  {   

  pino_data = !pino_data;   

  delay_us(2);   

  pino_clock = 0;   

  delay_us(2);

    pino_clock = 1; 

    delay_us(2);     

 

delay_ms(300);
}}

 

e eu não estou conseguindo jogar um dado certo, tipo, quando executo o programa acima todos os pinos ficam em high...

alguem tem alguma dica?

 

Agradeço!

Aê galera, alguém por aqui programa at89c52 e pic em linguagem C? 

Gostaria de uma ajuda para passar uma interrupção do at89c52 para pic16f628a, compilador CCS.

Programa do at89c52:

void multiplex() interrupt 1 using 1

{       

    TR0=0;

    TL0=(TIMER0_COUNT & 0x00FF);

    TH0=(TIMER0_COUNT >>8);

    TR0=1;
     timer0_tick=1;

}

 


void main(void){
   int i,j;    unsigned char row; 

   unsigned char *dataPtr, *tmpDataPtr;

   unsigned char messageLength, currentChar, charOffset, tmpCurrentChar, tmpCharOffset;

   char msg[32]; // ram for message max length     unsigned char ledArray[32];    
    P1=0xFF;

    P3=0xFF;

    P2=0xFF;

    EA      =0;

    TL0        = (TIMER0_COUNT & 0x00FF);/* timer 0 period 5ms         */       

    TH0        = (TIMER0_COUNT >>8);

    TL1=0XFD;        //9600 @ 11.0592

    TH1=0XFD;        //TMOD &=0xF0;       

    TMOD =0x21;       

    SCON =0X50;       
    ET0=1;   

    TR1=1; 

    TR0= 1;     /* enable timer 0                        */       

    EA      = 1;

     RI=0;

.

.

.

.

 

Agradeço!

 

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço