Moving message on LED dot matrix


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    May 2005
    Posts
    70

    Default Moving message on LED dot matrix

    Dear friend Microcode used
    Now we study moving message on LED dot matrix but did not work.
    We have sample in code (CSS) but i not under stand on code need you help to conver c code to basic code.


    CodeCSS )
    #include <16F877.h>
    #fuses HS,NOWDT,NOPROTECT,PUT,NOLVP
    #use delay(CLOCK = 10000000 )

    #use fast_io(B)

    #bit STROBE = 0x06.0 //PIN_B0
    #bit LATCH = 0x06.1 //PIN_B1
    #bit CLOCK = 0x06.2 //PIN_B2

    #bit SIN3 = 0x06.3 //PIN_B3
    #bit SIN2 = 0x06.4 //PIN_B4
    #bit SIN1 = 0x06.5 //PIN_B5

    //
    //
    // | | |
    // | SIN2 | SIN3 |
    // | | |
    // | Colum3 | Colum2 | Colum1 | Colum0 |
    // | | | | |
    // |7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 ------
    // | | | | 1 |
    // | | | | 2 |
    // | | | | 3 |
    // | | | | 4 | ROW0
    // | | | | 5 |
    // | | | | 6 |
    // | | | | 7 |
    // |----------------|-----------------|-----------------|----------------------- SIN1
    // | | | | 0 |
    // | | | | 1 |
    // | | | | 2 |
    // | | | | 3 |
    // | | | | 4 | ROW1
    // | | | | 5 |
    // | | | | 6 |
    // | | | | 7 |
    // |----------------|-----------------|-----------------|-----------------|-----
    // |


    char const font[3][16] =
    {
    {0x00,0x00,0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40 ,0x40,0x7C,0x00,0x00,0x00,0x00}, //E
    {0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10 ,0x10,0x10,0x00,0x00,0x00,0x00} //T
    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00} //Space
    };

    char const ScanRow1[16] =
    {
    0,0,0,0,0,0,0,0,1,2,4,8,16,32,64,128
    };

    char const ScanRow0[16] =
    {

    1,2,4,8,16,32,64,128,0,0,0,0,0,0,0,0
    };

    int buffer[4][16];

    int Colum3,Colum2,Colum1,Colum0,Row1,Row0;
    //int CheckClock,ValueBitSIN3,ValueBitSIN2,ValueBitSIN1;
    int k,l,m,n,o,p,q;


    void SendData16Bit();
    void SendDataSIN8BitHighbyte();
    void SendDataSIN8BitLowbyte();
    void BeginData();
    void ClearData();
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$
    #INT_TIMER1
    void IntTimer1_isr()
    {
    STROBE = 1; //STROBE OFF

    for (k=0;k<8;k++) // Row 0 to 7
    {
    Colum2 = buffer[2][k];
    Colum0 = buffer[0][k];
    Row0 = ScanRow0[k];
    SendDataSIN8BitLowbyte();

    Colum3 = buffer[3][k];
    Colum1 = buffer[1][k];
    Row1 = ScanRow1[k];
    SendDataSIN8BitHighbyte();

    LATCH = 0; //LATCH ON
    LATCH = 1; //LATCH OFF

    STROBE = 0; //STROBE ON
    delay_us(50);
    STROBE = 1; //STROBE OFF
    }

    for (k=8;k<16;k++) // Row 8 to 15
    {
    Colum2 = buffer[2][k];
    Colum0 = buffer[0][k];
    Row0 = ScanRow0[k];
    SendDataSIN8BitLowbyte();

    Colum3 = buffer[3][k];
    Colum1 = buffer[1][k];
    Row1 = ScanRow1[k];
    SendDataSIN8BitHighbyte();

    LATCH = 0; //LATCH ON
    LATCH = 1; //LATCH OFF

    STROBE = 0; //STROBE ON
    delay_us(50);
    STROBE = 1; //STROBE OFF
    }

    //STROBE = 0; //STROBE ON
    //set_timer1(65451); // FF AB interrupt 34uS
    set_timer1(65400);
    }
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$
    //################################################## ############################
    void main()
    {

    //-----------------------------
    set_tris_b(0x00);
    enable_interrupts(INT_TIMER1);
    enable_interrupts(GLOBAL);
    setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
    set_timer1(65451); // FF AB interrupt 34uS

    //-----------------------------
    STROBE = 1; //STROBE OFF
    LATCH = 1; //LATCH OFF
    CLOCK = 0; //Clock OFF Active High

    SIN3 = 0; //S-IN3 OFF
    SIN2 = 0; //S-IN3 OFF
    SIN1 = 0; //S-IN3 OFF




    ClearData();
    BeginData();


    //LOOP
    while(1)
    {

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

    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[3][n] = ((buffer[3][n]) * 2) + (((buffer[2][n]) &0B10000000)/128) ; //colum3
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[2][n] = ((buffer[2][n]) * 2) + (((buffer[1][n]) &0B10000000)/128) ; //colum2
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[1][n] = ((buffer[1][n]) * 2) + (((buffer[0][n]) &0B10000000)/128) ; //colum1
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[0][n] = ((buffer[0][n]) * 2) + (((buffer[3][n]) &0B10000000)/128) ; //colum0
    }
    //----------------------------------------

    delay_us(100);

    }



    }
    }
    //################################################## ############################
    //================================================== ============================
    void SendDataSIN8BitHighbyte()
    {
    int i;

    for(i=0;i<8;i++)
    {
    SIN3 = bit_test(Colum1,(i));
    SIN2 = bit_test(Colum3,(i));
    SIN1 = bit_test(Row1,(i));

    CLOCK = 1; //Clock ON
    CLOCK = 0; //Clock OFF

    }
    }
    //================================================== ============================
    //================================================== ============================
    void SendDataSIN8BitLowbyte()
    {
    int i;

    for(i=0;i<8;i++)
    {
    SIN3 = bit_test(Colum0,(i));
    SIN2 = bit_test(Colum2,(i));
    SIN1 = bit_test(Row0,(i));

    CLOCK = 1; //Clock ON
    CLOCK = 0; //Clock OFF

    }
    }
    //================================================== ============================
    //================================================== ============================
    void BeginData()
    {
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[0][n] = font[2][n]; // Space
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[1][n] = font[1][n]; // T
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[2][n] = font[1][n]; // T
    }
    //----------------------------------------
    //----------------------------------------
    for (n=0;n<16;n++)
    {
    buffer[3][n] = font[0][n]; // E
    }
    //----------------------------------------
    //----------------------------------------
    //for (n=0;n<16;n++)
    //{
    // buffer[4][n] = font[2][n]; // Space
    //}
    //----------------------------------------
    }
    //================================================== ============================
    //================================================== ============================
    void ClearData()
    {
    //========================================
    for(l=0;l<4;l++) // clear buffer
    {
    for (m=0;m<16;m++)
    {
    buffer[l][m] =0;
    }
    }
    //========================================
    }
    //================================================== ============================

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I suggest you download the CCS documentation + their Demo and try to understand what it does yourself first.

    Or like i said in another thread... pay someone here

    Out of curiosity.. is this for a school work?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Red face If you come up with the circuit I may help

    Hi,

    I have done a moving display with PBP but cannot share it due to commercial restrictions. If you are using Shift Registers then the idea is :

    1. Get the font data from a lookup table
    2. Dump column data for every row and light up that row, do it in even periods and you have got the scanning.

    3. For moving message use a pointer in your message table and update it at regular intervals to scroll.

    I know that this is very rudimentary. Post your schematic and I will try to help. I got the lookup table for the 5x7 matrix from this forum by dave and thankful for the same. So perhaps its my turn.
    Regards

    Sougata

  4. #4
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi sougata
    Here is picture of circuit 512 ...
    There are 8 pin for control

    Strobe = control On/Off Dot matrix led display, logic "0" active led on
    Latch = control data transfer logic "0"
    Clock = clock
    Sin1 = control row0,row1
    Sin2 = control culum2 , culum3
    Sin3 = control culum0 , culum1
    Vcc_led = power +5 v
    Vcc_IC = power +5 v
    Attached Images Attached Images    

  5. #5
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Thumbs down

    From your post i can see that you have a 16 row by 32 Cols
    the easy way i would have dont this is use PortB & Portc for for Rows
    Then use 4 74hc595 shift reisters for your cols to give you 32bits then use the shiftout command.
    Here is an example of an 8 Row by 16 Cols
    i used portb for the Rows and 2 74hc595 for the cols
    This should get you started

    ' Program USING 74HC595 .BAS

    INCLUDE "Modedefs.bas"
    ADCON1=7
    TRISA=0:TRISB=0:TRISC=0

    'PORT ASSIGNS******************************************* ***
    DataP VAR PORTC.0'Data pin (74x595.14)
    Clk VAR PORTC.1'shift clock (74x595.11)
    Latch VAR PORTC.2'Output Latch(74x595.12)
    RowVAR BYTE

    'Variables ***********************************************
    Delay CON 0'Delay
    pattern VAR WORD 'Output pattern
    A VAR BYTE ' Loop counter for 16 values of Rows



    Pause 1000
    Low Latch

    main :
    pattern = %0000000000000001 'pattern for my columns
    For A=0 To 15 ' set the Count 16 times
    LookUp A,[0,255,255,24,24,255,255,0,0,255,255,219,219,195,19 5,0],Row
    'Those values in the Table should give HE on your display
    ShiftOut DataP,Clk,msbFirst,[pattern\16] 'Send pattern to 74x595
    PORTB=0 'Blank portb before changing
    column
    PulsOut Latch,1 'Latch 74x595 outputs
    PORTB=Row 'Transfer values from table to
    portb
    Pause Delay 'Delay
    pattern=pattern <<1 'shift pattern 1 place the to left
    Next A 'this should give me 0000000000000001 to 1000000000000000


    GoTo main






    Isaac

  6. #6
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    How to set like becode with PBP....

    Now we used lookup but we cannot specify line or font number

    char const font[3][16] =
    {
    {0x00,0x00,0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40 ,0x40,0x7C,0x00,0x00,0x00,0x00}, //E
    {0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10 ,0x10,0x10,0x00,0x00,0x00,0x00} //T
    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00} //Space
    };

  7. #7
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Default

    you are mixing pbp with c ?

  8. #8
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Default

    why not use the data command and prewrite the data to eeprom

    Isaac

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    Char var byte[48]
    char[0]=
    char[1]=
    char[2]=
    char[3]=
    char[4]=
    '
    '
    '
    '
    '
    or have a look HERE
    and HERE
    Last edited by mister_e; - 13th November 2006 at 16:16.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Thank all friend for advise

    I have question ..

    I would to know valve of each bit of A (see below)

    A con % 10010111

    A bit 0 = 1
    A bit 1 = 1
    A bit 2 = 1
    A bit 3 = 0
    A bit 4 = 1
    :
    :
    :

    we write as below but not work...

    A con % 10010111
    For i = 0 to 8 ' loop for bit number
    x [i] = A.[i]
    print x[i]
    next i

    Sorry .... it may not cler for my question ( I don't how to say)

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    xVar=A.0[i]

    And 'print' is not a Melabs PicBasic statement
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi Mister_e
    Thank for you advise ..

  13. #13
    Join Date
    May 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Moving message on LED dot matrix

    isaac, i'm using your code to drive 4x74hc595, but i can't find the things to change in the code.

    i need to use 4 x 8x8 led matrix, but only work 2 of those.

    i apreciate your help

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. Flashing!! LED Dot matrix problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th December 2006, 09:45
  5. matrix led array( moving singboard )
    By ufuk0106 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th April 2005, 17:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts