need help in vertical scroll 7x32 matrix with pic18f2550 and 74hc595 shift register

Discussion in 'Embedded Systems and Microcontrollers' started by anoopmb25, Mar 23, 2015.

  1. anoopmb25

    Thread Starter New Member

    Jan 15, 2011
    17
    0
    hi,

    i created a 7X32 led matrix for text scrolling with the tutorial posted in Embedded Lab .com

    MCU IS PIC 18F2550
    CRYSTAL 20 MHZ

    7 rows are scanned with cd4017 and goes to uln2803 and to matrix
    32 columns are driven by chained 4 74hc595 shift registers

    I can scroll text from right to left without any problem

    I need help to
    - scroll text from left to right
    - scroll text vertically both upwards and downwards
    -show some efects or animaions like fading,step in, sweep in etc..
    -start scrolling from right end and stops at left end up to a defined time delay
    -scroll one text vertically and others static mode

    my code in mikroc is given below

    Code (Text):
    1.  
    2. sbit Serial_Data at RA0_bit;
    3. sbit SH_Clk at RA1_bit;
    4. sbit ST_Clk at RA2_bit;
    5. sbit CD4017_Clk at RA2_bit;
    6. sbit CD4017_RST at RA1_bit;
    7.  
    8. const unsigned short CharData[][7] =
    9. {
    10. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0x20, Space
    11. {0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04} , // 0x21, !
    12. {0x09, 0x09, 0x12, 0x00, 0x00, 0x00, 0x00}, // 0x22, "
    13. {0x0a, 0x0a, 0x1f, 0x0a, 0x1f, 0x0a, 0x0a} , // 0x23, #
    14. {0x04, 0x0f, 0x14, 0x0e, 0x05, 0x1e, 0x04} , // 0x24, $
    15. {0x19, 0x19, 0x02, 0x04, 0x08, 0x13, 0x13} , // 0x25, %
    16. .............................................................................
    17. {0x00, 0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11}, // 0x78, x
    18. {0x00, 0x11, 0x11, 0x0f, 0x01, 0x11, 0x0e}, // 0x79, y
    19. {0x00, 0x00, 0x1f, 0x02, 0x04, 0x08, 0x1f}, // 0x7a, z
    20. {0x06, 0x08, 0x08, 0x10, 0x08, 0x08, 0x06}, // 0x7b, {
    21. {0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04}, // 0x7c, |
    22. {0x0c, 0x02, 0x02, 0x01, 0x02, 0x02, 0x0c}, // 0x7d, }
    23. {0x08, 0x15, 0x02, 0x00, 0x00, 0x00, 0x00} // 0x7e, ~
    24.  
    25. };
    26. unsigned short Buffer[7][5] = {
    27. {0,0,0,0,0},
    28. {0,0,0,0,0},
    29. {0,0,0,0,0},
    30. {0,0,0,0,0},
    31. {0,0,0,0,0},
    32. {0,0,0,0,0},
    33. {0,0,0,0,0}
    34. };
    35.  
    36. unsigned int speed, StringLength;
    37. unsigned short i, l, k, row, scroll, temp, shift_step=1;
    38. unsigned short m, SerialConnect=0, UserIP = 0;
    39.  
    40. const unsigned char default_message[]="hello world";
    41.  
    42. void Send_Data(unsigned short rw){
    43. unsigned short Mask, t, num, Flag;
    44. for (num = 0; num < 5; num++) {
    45. Mask = 0x01;
    46. for (t=0; t<6; t++){
    47. Flag = Buffer[rw][num] & Mask;
    48. if(Flag=0) Serial_Data = 0;
    49. else Serial_Data = 1;
    50. SH_Clk = 1;
    51. SH_Clk = 0;
    52. Mask = Mask << 1;
    53. }
    54. }
    55.  
    56. // Apply clock on ST_Clk
    57. ST_Clk = 1;
    58. ST_Clk = 0;
    59.  
    60. }
    61.  
    62. void scrollleft()
    63. {
    64. StringLength = 11;//hello world
    65. for (k=0; k<StringLength+4; k++){
    66. for (scroll=0; scroll<(7/shift_step); scroll++) {
    67. for (row=0; row<7; row++){
    68. index = default_message[k];
    69. temp = CharData[index-32][row];
    70. Buffer[row][4] = (Buffer[row][4] << Shift_Step) | (Buffer[row][3] >> (7-Shift_Step));
    71. Buffer[row][3] = (Buffer[row][3] << Shift_Step) | (Buffer[row][2] >> (7-Shift_Step));
    72. Buffer[row][2] = (Buffer[row][2] << Shift_Step) | (Buffer[row][1] >> (7-Shift_Step));
    73. Buffer[row][1] = (Buffer[row][1] << Shift_Step) | (Buffer[row][0] >> (7-Shift_Step));
    74. Buffer[row][0] = (Buffer[row][0] << Shift_Step)| (temp >> ((7-shift_step)-scroll*shift_step));
    75. }
    76. speed = 15;
    77. for(l=0; l<speed;l++){
    78.  
    79. CD4017_Rst = 1;
    80. CD4017_Rst = 0;
    81.  
    82. for (i=0; i<7; i++) {
    83.  
    84. Send_Data(i);
    85. CD4017_Clk = 1;
    86. CD4017_Clk = 0;
    87. Delay_ms(1);
    88.  
    89. } // i
    90. } // l
    91. } // scroll
    92. } // k
    93.  
    94.  
    95. }
    96.  
    97. void main() {
    98. CMCON = 0x07; // Disable comparators
    99. ADCON0 = 0x00; // Select ADC channel AN0
    100. ADCON1 = 0b00001110; // RA0 as analog input
    101. TRISC = 0x00;
    102. TRISB = 0xFF;
    103. TRISA = 0x01;
    104.  
    105. while(1){
    106.  
    107. scrollleft();
    108.  
    109. }
    110.  
    111.  
    112.  
    113. }
    114.  

    kindly help me to do above stated actions

    sorry for my bad english and thanks in advance

    Moderators note : Please use code tags for pieces of code
     
    Last edited by a moderator: Mar 23, 2015
  2. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    first build the image in RAM.
    Then move a window, copy to display buffer.
     
    RRITESH KAKKAR likes this.
  3. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Hello,
    PIC18 is good choice with high ram memory . you can use directly portb than 4017 for scanning!
     
  4. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Hello,
    can we get font other than 5x7 ???
     
Loading...