[SOLVED] 16x8 LED Matrix using MAX7219 (cascading problem)

Status
Not open for further replies.

justice_md5

Newbie level 3
Joined
Apr 17, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,367
Hello Edaboard team,

I work on 16x8 LED matrix using MAX7219, and have problem with scrolling text on second matrix. Scrolling on first display is working.
I'm using PIC16F628A.

MAXX's are connected in cascade. DIN from first to DOUT second, CLK common, LOAD/CS common.

Here is code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/ Software SPI configuration
sbit  SoftSpi_SDI at RB3_bit;
sbit SoftSpi_SDO at RB4_bit;
sbit SoftSpi_CLK at RB5_bit;
 
 
 
sbit SoftSpi_SDI_Direction at TRISB3_bit;
sbit SoftSpi_SDO_Direction at TRISB4_bit;
sbit SoftSpi_CLK_Direction at TRISB5_bit;
 
// max7219 LOAD/CS(-) pin configuration// max7219 configuration
void max7219_init1()
{
trisa=0;
 Chip_Select = 0;       // SELECT MAX
 Soft_SPI_Write(0x09);      //  Disable BCD mode for digit decoding
 Soft_SPI_Write(0x00);
 Chip_Select = 1;       // DESELECT MAX
 
 Chip_Select = 0;
Soft_SPI_Write(0x0A);     //  Max segment luminosity intensity
 Soft_SPI_Write(0x0F);
 Chip_Select = 1;
 
 Chip_Select = 0;
 Soft_SPI_Write(0x0B);
 Soft_SPI_Write(0x07);      // Display refresh
 Chip_Select = 1;
 Chip_Select = 0;
 Soft_SPI_Write(0x0C);
 Soft_SPI_Write(0x01);      // Turn on the display
 Chip_Select = 1;
 
 Chip_Select = 0;
 Soft_SPI_Write(0x00);
 Soft_SPI_Write(0xFF);      // No test
 Chip_Select = 1;
}
 
void max7219_init2() {
  Chip_Select = 0;       // SELECT MAX
  Soft_SPI_Write(0x09);      // BCD mode for digit decoding
  Soft_SPI_Write(0xFF);      // using Code-B
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select= 1;       // DESELECT MAX
 
  Chip_Select= 0;       // SELECT MAX
  Soft_SPI_Write(0x0A);
  Soft_SPI_Write(0x0F);      // Segment luminosity intensity
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select1 = 1;       // DESELECT MAX
 
  Chip_Select1 = 0;       // SELECT MAX
 Soft_SPI_Write(0x0B);
  Soft_SPI_Write(0x07);      // Display refresh
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select = 1;       // DESELECT MAX
 
  Chip_Select= 0;       // SELECT MAX
  Soft_SPI_Write(0x0C);
  Soft_SPI_Write(0x01);      // Turn on the display
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select = 1;       // DESELECT MAX
 
  Chip_Select1 = 0;       // SELECT MAX
  Soft_SPI_Write(0x00);
  Soft_SPI_Write(0xFF);      // No test
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select1 = 1;
  
  }
//Send data function
void Write_Byte(unsigned short myRow, unsigned short myValue)
{
 Chip_Select = 0;       // select max7219.
 Soft_SPI_Write(myRow);  // send myRow value to max7219 (digit place).
 Soft_SPI_Write(myValue);
 
 Chip_Select = 1;       // deselect max7219.
 }
 
 void Write_Byte1(unsigned short myRow, unsigned short myValue)
{
 Chip_Select = 0;
      // select ma7219.
 Soft_SPI_Write(myRow); 
 Soft_SPI_Write(myValue);
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
 
 Chip_Select = 1;    
 }
 
//Clear matrix function
void Clear_Matrix(void)
{
 unsigned short x;
 
 for(x=1;x<9;x++)
 {
  Write_Byte(x,0x00);
  }
}
 
 
unsigned int DisplayBuffer[]={0,0,0,0,0,0,0,0};
unsigned int DisplayBuffer1[]={0,0,0,0,0,0,0,0};
unsigned int speed=10;
short i, l, k, ShiftAmount, scroll, temp,temp1, shift_step=1, StringLength;
char message[]="MIPS LED MATRIX 2014" ;
char index,index1;
void main() 
{
 
   Chip_Select_Direction = 0;
   Soft_SPI_init();
 max7219_init1();
 max7219_init2();
 Clear_Matrix();
 StringLength = strlen(message) ;
 
 
 
while(1)
 {
 for (k=0; k<StringLength; k++)
 {
  for (scroll=0; scroll<(8/shift_step); scroll++)
   {
         for (ShiftAmount=0; ShiftAmount<8; ShiftAmount++)
         {
          index = message[k];
          index1=message[k-1];
          temp =CharData[index-32][ShiftAmount];
          temp1 =CharData[index-32][ShiftAmount];
          
          DisplayBuffer[ShiftAmount] = (DisplayBuffer[ShiftAmount] << shift_step)| (temp >> ((8-shift_step)-scroll*shift_step));
          DisplayBuffer1[ShiftAmount] = (DisplayBuffer1[ShiftAmount] << shift_step)| (temp1 >> ((8-shift_step)-scroll*shift_step));
         }
 
 
        for(l=0; l<5;l++)
        {
                 for (i=0; i<8; i++)
                 {
                     Write_Byte(i+1,DisplayBuffer[i]);  //Scrolling k character on firt LED Matrix
                     if(k>0)
                     Write_Byte1(i+1,DisplayBuffer1[i]);Scrolling k-1 character on second LED Matrix
 
                 }
        }
 
 
   }
   }
 
 }
 
}




Thanks in advance.
 

Problems related to malfunctioning on cascaded panels are usually mostly related to layout scope, due to parasitic capacitance of routed tracks and devices.

I could notice that you did not provide distributed delays on code, and I presume this proceeding could minimize failures.


+++
 

Thanks for fast answering.

I can not get right results in my simulation. I'm using Proteus.
Also, I can not send data to another display not at all.

I use this code:

Code C - [expand]
1
2
3
4
5
6
Chip_Select= 0;       // SELECT MAX
  Soft_SPI_Write(row);
  Soft_SPI_Write(data);      
  Soft_SPI_Write(0x00);    // Bypass the 1st Chip
  Soft_SPI_Write(0x00);
  Chip_Select = 1;


Is that correct?

And what mean distributed delays on code?


Thanks.
 
Last edited:

If possible, post here the schematic circuit so that I can provide to you a more accurate answer.


+++
 

If possible, post here the schematic circuit so that I can provide to you a more accurate answer.


+++

Thanks for answering.

Here is schematic. I did not connected external oscillator yet, power supply, etc., but simulation can work without them.
 

Attachments

  • Led_matrix.rar
    22.3 KB · Views: 128

The file you uploaded compressed has an extension .pdsprj which is not viewable at any native image manager or browsers installed at Windows operational system. You must convert to some PNG or JPG format.






+++
 

Sorry. That is Proteus project file.
Here is PDF file.

Thanks
 

Attachments

  • Led_matrix_scroll.PDF
    21.7 KB · Views: 149

I´m not seeing any delay after each chip selection, and probably this could make difference on performance depending on layout particularities.

As a first tip, I would suggest you insert a short delay after each access like that:


Code C - [expand]
1
2
Chip_Select = x ;  // required if selection is active at 'x' logic
Delay ( yyy ) ; // start testing with few micro seconds




+++
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…