Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SEARCH feature is gone? Scrolling on an 8 x 8 matrix

Status
Not open for further replies.
There is one byte per column. The data is correct as shown - figure out why.

The single array provides all the required information to control the matrix. Why complicate it with two arrays?

This is the approach I would take and I think it's well explained. You of course are free to do what you like. If I need to clarify anything in this approach, I will try to do so.
 
Last edited:
I think you're confused (imagine that?). To use an 8x8 matrix LED array, you have to multiplex the data. This is quite apart from scrolling.

The illustration below may help. It shows the window of the message from the above illustration. You need to do the following just to display the data.

1. Set the 8 data bits for column 1.
2. Turn on column 1.
3. Turn off column 1.
4. Set the 8 data bits for column 2.
5. Turn on column 2.
6. Turn off column 2.
7. Set the 8 data bits for column 3.
8. Turn on column 3.
9. Turn off column 3.

....and so on.

You must refresh the entire display more than 24 times a second to prevent flickering. This sequence must repeat continuously whenever the display is showing something. Thus, two arrays make no sense what so ever.

The scrolling happens at a much slower rate. It involves relatively slowly cycling through the data array.

Scrolling 8x8 - multiplex.jpg
 
Here's a Swordfish approach to multiplexing. This is for using multiple 7-segment displays using an interrupt – the same principle is needed to drive your 8x8 matrix.

Swordfish Module: 7-Segment Display – Multiple

Play with the ideas here until you are able to display a Z, X or S...a letter with multiple pixels in rows and columns. After you have mastered this, then you can add scrolling. Until you can display stationary characters, you haven't got a prayer to display a scrolling message.
 
I already have displayed stationary characters. Here is my code for displaying "KOC8283 Salmon" but have the letters upside down and backwards.
I am going to start looking over what I have and figure out why Jon has bytes missing in post #18
Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 2/4/2014                                                       *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 2/4/2014                                                       *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
DEVICE = 18F2420

CLOCK = 8
   

// import LCD library...

INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas"       // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "shift.bas"

// Arrays                                                                                  
CONST K_Data(8)AS BYTE =  (%10001000,
                           %10010000,                            
                           %10100000,
                           %11000000,
                           %11000000,
                           %10100000,
                           %10010000,
                           %10001000)
                       
CONST O_Data(8) AS BYTE =(%00011000, %00100100, %00100100, %00100100,
                          %00100100, %00011000, %00000000, %00000000)
                         
CONST C_Data (8) AS BYTE =(%00111100,
                           %01000000,                            
                           %10000000,
                           %10000000,
                           %10000000,
                           %10000000,
                           %01000010,
                           %00111100)
                           
                           
CONST E_Data(8) AS BYTE = (%00111100,
                           %11000011,                            
                           %11000011,
                           %00111100,
                           %11000111,
                           %11000011,
                           %11000011,
                           %00111100)
                          
                          
CONST TWO_Data(8) AS BYTE =   (%00111110,           
                               %0100001,              
                               %00000001,           
                               %00011110,           
                               %01100000,          
                               %11000000,          
                               %11000000,          
                               %00111110)
                              
                              
CONST THREE_Data(8) AS BYTE = (%01111110,           
                               %00000001,              
                               %00000001,           
                               %00011110,           
                               %00000001,          
                               %00000001,          
                               %00000010,          
                               %00111100)
                              
CONST S_Data(8) AS BYTE =     (%00111100,           
                               %11000010,              
                               %11000000,           
                               %01111100,           
                               %00000011,          
                               %00000011,          
                               %01000111,          
                               %00111100)                                    
                              
CONST A_Data(8) AS BYTE =     (%00010000,           
                               %00101000,              
                               %01000100,           
                               %10000010,           
                               %11111111,          
                               %10000001,          
                               %10000001,          
                               %10000001)
                                                                                      
CONST L_Data(8) AS BYTE =     (%10000000,           
                               %10000000,              
                               %10000000,           
                               %10000000,           
                               %10000000,          
                               %10000000,          
                               %10000010,          
                               %11111100)                                    
                              
CONST M_Data(8) AS BYTE =     (%00000000,           
                               %00000000,              
                               %01101100,           
                               %10010010,           
                               %10000001,          
                               %10000001,          
                               %10000001,          
                               %10000001)
                              
                              
CONST OO_Data(8) AS BYTE =    (%00111100,           
                               %01000010,              
                               %10000001,           
                               %10000001,           
                               %10000001,          
                               %10000001,          
                               %01000010,          
                               %00111100)                              
                              
                              
                              
                                  
                              
CONST N_Data(8) AS BYTE =     (%00000000,           
                               %11000001,              
                               %10100001,           
                               %10010001,           
                               %10001001,          
                               %10000101,          
                               %10000011,          
                               %10000011)                                       
                          
CONST cathodes(8) AS BYTE = (%11111110,       'top
                             %11111101,
                             %11111011,
                             %11110111,      ' cathodes colums
                             %11101111,       ' top to bottom
                             %11011111,
                             %10111111,
                             %01111111)        'bottom
                             
                             
                            
                            
                            
                            
                            
                            
                            
                        
DIM x AS BYTE
DIM index AS BYTE
              
// Sub Routines
SUB draw_K()
REPEAT
        FOR x = 0 TO 7
       
        PORTC =K_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
          
            //PORTB = %00000000           // I put this here to make sure that we don't get ghosting when moving to the next column
        NEXT
        INC(index)
        UNTIL (index) = 70
       //delayms(100)
index = 0                          
// draw_O()
REPEAT                           
      FOR x = 0 TO 7
       
        PORTC =O_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
REPEAT
//DRAW C                           
      FOR x = 0 TO 7
       
        PORTC =C_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
REPEAT
//DRAW 8                           
      FOR x = 0 TO 7
       
        PORTC =E_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
REPEAT
//DRAW 2                           
      FOR x = 0 TO 7
       
        PORTC =TWO_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
//DRAW 8
REPEAT                          
      FOR x = 0 TO 7
       
        PORTC =E_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
//DRAW 3
REPEAT                          
      FOR x = 0 TO 7
       
        PORTC =THREE_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
//DRAW S      
REPEAT
        FOR x = 0 TO 7
       
        PORTC =S_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
          
            //PORTB = %00000000           // I put this here to make sure that we don't get ghosting when moving to the next column
        NEXT
        INC(index)
        UNTIL (index) = 70
       //delayms(100)
index = 0                          
// draw A
REPEAT                           
      FOR x = 0 TO 7
       
        PORTC =A_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
//DRAW L      
REPEAT
        FOR x = 0 TO 7
       
        PORTC =L_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
          
            //PORTB = %00000000           // I put this here to make sure that we don't get ghosting when moving to the next column
        NEXT
        INC(index)
        UNTIL (index) = 70
       //delayms(100)
index = 0                          
// draw M
REPEAT                           
      FOR x = 0 TO 7
       
        PORTC =M_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
// draw_OO()
REPEAT                           
      FOR x = 0 TO 7
       
        PORTC =OO_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
REPEAT
//DRAW N                           
      FOR x = 0 TO 7
       
        PORTC =N_Data(x)
        PORTB = cathodes(x)
        
          DELAYMS(1)
       
        NEXT
         // PORTB = %00000000 // I put this here to make sure that we don't get ghosting when moving to the next column
       INC(index)  
       UNTIL (index) = 70
       index = 0
     
      
  
                               
                        
END SUB

// variable declaration
// Start Of Program
//OSCCON = %01111111                  // Sets the internal oscillator for 8Mhz
SetAllDigital                       // Make all Pins digital I/O's
TRISC = %00000000                   // Make PORTD all outputs
TRISB = %00000000                   // Make PORTB all outputs
index = 0
// Main Loop
WHILE True()                        // This creates an infinite loop
    draw_K
   
  

WEND
{
(%00000000,           
                               %00000000,              
                               %00000000,           
                               %00000000,           
                               %00000000,          
                               %00000000,          
                               %00000000,          
                               %00000000)                               // Loop back to the while loop as long as we havent finished.
 
I started basically from scratch, verifying my port bits and after writing this short code I realized I was trying to turn on the anodes from C0 to C7 in a FOR X = 0 to 7 loop portc = Anodes_Data(x) instead of just reading Anodes_Data(0).
the code here scrolls a solid line from bottom to top of matrix.
Now I understand why Jon had the bytes in post #18 except the missing bytes??
 
.... and figure out why Jon has bytes missing in post #18...

The data accurately reflects what's shown in the illustration.


Thanks Ian. This one, I'm making up as I go. Personally, I'd use a chip like the AS1106 to do this and relieve the micro from the busy work of refreshing the display.
 
Last edited by a moderator:
Well making some progress. Figured out the missing bytes in Jons post and finally got a letter K to scroll across the display. Not perfect but it works. needs some work, lots of it.
Plan to get this letter K working then assign each letter as a variable in portc then just cycle through this one routine. I realize this is not done but doing lots of different things and making it work. After I see where I made my mistake, thanks to Jon, about the data numeration in the CONST arrays allowed me to see the forest dispite the trees.
Code:
{
*****************************************************************************
*  Name    : testing routine.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 2/4/2014                                                       *
*  Version : 1.0                                                            *
*  Notes   : letter testing routine                                                               *
*          :                                                                *
*****************************************************************************
}
DEVICE = 18F2420

CLOCK = 8
   

// import LCD library...

INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas"       // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "shift.bas"

// Arrays                                                                                  
// Arrays

  
const test(44)as byte = (%11111111, %10000000, %01000000, %00100000, %01000000, %10000000, %11111111, %00000000,
                         %11111111, %10001001, %10001001, %10000001, %00000000,
                         %00100010, %01010001, %10001001, %10001010 ,%01000100, %00000000,
                         %00100010, %01010001 ,%10001001, %10001010, %01000100, %00000000,
                         %00011111, %00101000, %11001000 ,%01001000, %00101000, %00011111, %00000000,
                         %00000000 ,
                         %00111100, %01000010, %10000001, %10000101, %01000110, %00000000 ,
                         %11111111 ,%10001001, %10001001, %10000001, %00000000)                  
CONST Anodes_Data(8)AS BYTE =(%11111111,
                               %00011000,                            
                               %00100100,
                               %01000010,
                               %10000000,
                               %00000000,
                               %00000000,
                               %00000000)
                       
CONST Cathodes_Data(8)AS BYTE =(%11111110,
                                 %11111101,
                                 %11111011,
                                 %11110111,
                                 %11101111,
                                 %11011111,
                                 %10111111,
                                 %01111111)
                     
                     
                                               
                                      
                                                     
                             
// variable declaration                              
'DIM x AS BYTE
DIM x AS WORD
'DIM indexc AS portc
'dim indexb as byte
'DIM bits AS BYTE
DIM y AS BYTE
DIM b(8) AS BYTE
                 
// Sub Routines

              

// Start Of Program
'portc = 0
'portb = 1
SetAllDigital                       // Make all Pins digital I/O's
TRISC = %00000000                   // Make PORTD all outputs
TRISB = %00000000                   // Make PORTB all outputs
y = 0
// Main Loop
WHILE True()
     
       portc = Anodes_Data(0)     '0
       portb = Cathodes_Data(0)
       delayms(1)
     
       portc = Anodes_Data(1)      '0
       portb = Cathodes_Data(1)
       delayms(1)
       portc = Anodes_Data(2)      '0
       portb = Cathodes_Data(2)
       delayms(1)
       portc = Anodes_Data(3)      '0
       portb = Cathodes_Data(3)
       delayms(1)
      
       portc = Anodes_Data(4)        '0
       portb = Cathodes_Data(4)
       delayms(300)
       'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        portc = %00000000
       portc = Anodes_Data(0)     '0
       portb = Cathodes_Data(1)
       delayms(1)
     
       portc = Anodes_Data(1)      '0
       portb = Cathodes_Data(2)
       delayms(1)
       portc = Anodes_Data(2)      '0
       portb = Cathodes_Data(3)
       delayms(1)
       portc = Anodes_Data(3)      '0
       portb = Cathodes_Data(4)
       delayms(1)
      
       portc = Anodes_Data(4)        '0
       portb = Cathodes_Data(5)
       delayms(300)
       'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        portc = %00000000
      portc = Anodes_Data(0)     '0
       portb = Cathodes_Data(2)
       delayms(1)
     
       portc = Anodes_Data(1)      '0
       portb = Cathodes_Data(3)
       delayms(1)
       portc = Anodes_Data(2)      '0
       portb = Cathodes_Data(4)
       delayms(1)
       portc = Anodes_Data(3)      '0
       portb = Cathodes_Data(5)
       delayms(1)
      
       portc = Anodes_Data(4)        '0
       portb = Cathodes_Data(6)
       delayms(300)
       'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        portc = %00000000
       portc = Anodes_Data(0)     '0
       portb = Cathodes_Data(3)
       delayms(1)
     
       portc = Anodes_Data(1)      '0
       portb = Cathodes_Data(4)
       delayms(1)
       portc = Anodes_Data(2)      '0
       portb = Cathodes_Data(5)
       delayms(1)
       portc = Anodes_Data(3)      '0
       portb = Cathodes_Data(6)
       delayms(1)
      
       portc = Anodes_Data(4)        '0
       portb = Cathodes_Data(7)
       delayms(300)
       'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         portc = %00000000
       portc = Anodes_Data(0)     '0
       portb = Cathodes_Data(4)
       delayms(1)
     
       portc = Anodes_Data(1)      '0
       portb = Cathodes_Data(5)
       delayms(1)
       portc = Anodes_Data(2)      '0
       portb = Cathodes_Data(6)
       delayms(1)
       portc = Anodes_Data(3)      '0
       portb = Cathodes_Data(7)
       delayms(300)
      
    
       portc = %00000000
     
    
    
WEND                  // Loop back to the while loop as long as we havent finished.
 
Yes, and the "missing bytes" as you say are "missing" why?

For the sake of my sanity, it's time to take leave of this topic. I'm happy if I've helped in some way, but nothing you're doing has any relationship to anything I've suggested, so my work here is over.
 
Last edited:
Why the missing byte? there not needed.
I have taken your suggestion on the layout of the CONST arrays. I had them / used them from top to bottom instead of across. The code I posted is my interpretation of what you suggested. I realize it isn't perfect but then one point I should have mentioned is I only have 8- 150 ohm resistors but running at 3v BUT want to limit the amount of current total. At present I am pushing the boundaries but by putting in the 1ms delays should help. Going to work on the posted code as it does work butdoes need to limit the amount of led segment blinking or flutter for a better term.
 
Yes, and the "missing bytes" as you say are "missing" why?

For the sake of my sanity, it's time to take leave of this topic. I'm happy if I've helped in some way, but nothing you're doing has any relationship to anything I've suggested, so my work here is over.


Fear not avid readers, he shall return! PM me if you want me to give odds and take bets :D
 
Nice non-answer.

If you look at the illustration in post #17, each line of the data shown in post #18 represents one character, including the trailing space. Each binary number represents one column of the display.

The line with only a single value of %0000000 is because I inadvertently included an extra blank column between the A and the G when I made the drawing. This should have been an absolute no-brainer to figure out.


Elaborating a bit before I blow this off...

Yes, the individual characters should be constant arrays.

But the message should not. The actual message should be a variable array. Copy the data for each needed character into the data array. Then scroll across this array in 8 bit steps. Why 8 bits? That's a question for the reader to understand.

I'll have no more comments.
 
you could have waited a bit!!!! now you've lowered the odds! I stood to make a killing. You will return for more punishment. I am also selling popcorn
 
I understand post 17 and 18 regardless of the error in the space between the A and the G.
I got single letters but getting them to scroll across is the issue.
I got the K to scroll using my posted code but I want the K to scroll from right to left
Will try the scanning of the variable arrays as suggested.
 
Johns explanation in post 17, 18, and 22 will only show one letter at a time but not scrolling across. Here is my interperation of what needs to happen when scrolling
WHILE True()

FOR x = 0 TO 8

FOR y = 0 TO 7

PORTC = Anodes_Data(y)

portb = Cathodes_Data(x)

DELAYMS(50)

NEXT

NEXT

WEND



WHEN USING ABOVE LOOP IT ONLY DISPLAY ONE ROW AND CYCLES FROM RIGHT TO LEFT

WHEN SCROLLIN FROM RIGHT TO LEFT YOU NEED TO ENABLE

  1. ROW 0/COLUM 0

  2. ROW 0/ COLUM 0 AND ROW 1 COLUM 1

  3. ROW 0 COLUM 0, ROW 1 COLUM 1 AND ROW 2 COLUM 2

  4. ROW 0 COLUM 0, ROW 1 COLUM 1, ROW 2 COLUM 2 , ROW 3 COLUM 3 AND ROW 4 COLUM 4

    ETC UNTIL ROW 7 OF THE ANODES IS ON COLUM 7 UNLESS YOU HAVE SPACES



CONST Anodes_Data(8)AS BYTE =(%11111111, 'LEFT TO RIGHT

%00011000,

%00100100,

%10000001,

%00000000,

%00000000,

%00000000,

%00000000)



CONST Cathodes_Data(9)AS BYTE = (%11111110, 'top row

%11111101,

%11111011,

%11110111,

%11101111,

%11011111,

%10111111,

%01111111,

%11111111) 'bottom row






CYCLE 4

CYCLE 3

CYCLE 2

CYCLE 1





ANODE DATA 0

ANODE DATA 1

ANODE DATA 2

ANODE DATA 3



















































DATA NEEDS TO BE DISPLAYED AS THE CATHODES PROGRESS FROM 0 TO 7
 
Am sure tumbleweed can figure it out. He seems to figure out these train wrecks.
I tried the message with different loops and the loop needs to recycle the privious dadt as it progresses on the display.
harder than it looks
 
Post #17 outlines exactly the procedure needed to scroll text data across one or several 8x8 character arrays. Going from this description to code is straight forward to anyone who is not a copy&paste wannabe programmer.

It's not that I can't easily code this. I will not code it for you. Aside from the futility of helping you (including hundreds of posts and dozens of technical articles on your behalf), this project is for The Knights of Columbus. The Knights of Columbus is a homophobic, anti-gay organization and I will do nothing that benefits them in any way. Hatred and bigotry are not ok no mater how you try to disguise them.

The Anti-Gay, Anti-Chice Politics of The Knights of Columbus

Sorry to bring politics into this discussion, but I have to stand up for what's important to me (and my husband, just for the record).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top