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.

excessive ghosting on 8 x 8 matrix

Status
Not open for further replies.

MrDEB

Well-Known Member
been hacking away at this trying to figure out why I keep getting an extra led dot on. Numbers 12 - 2 work except # 5, 3, and 1 routine have the extra led on or ghosting.
been running only routine one to try and decipher how to eliminate the ghosting.
any suggestions. NOTE checked for shorts etc. even used a different test circuit, same results.
Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 11/19/2016                                                     *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}


//xxxxxxxxxxxxxxxxxxxxxxxxxx

Device = 18F43k20 ' Tell the compiler what chip we are using
Clock = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
//CONFIG MCLRE = OFF
Config fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
Include "SetDigitalIO.bas"       // Include this file when we compile so that we can use keywords like 'setalldigital'
Include "utils.bas"
Include "convert.bas"   //xxxxx
Dim y As Byte
Dim x As Byte
Dim led As PORTA.0
Dim index As Word
Dim Switch As PORTA.3
Dim led1a As PORTD.3
Dim led1c As PORTB.3
// Sub Routines

                                                                              
// Arrays


                              
 
// CONST Cathodes_Data(9)AS BYTE = (%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000)                               
                      
Const Cathodes_Data(8)As Byte = (%01111111,       ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
                                 %10111111,        ' this is for scanning the rows
                                 %11011111,        //cathodes
                                 %11101111,
                                 %11110111,
                                 %11111011,
                                 %11111101,
                                 %11111110)
                                
                                
                                
Const Cat_Data(8)As Byte =      (%11111111,       ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
                                 %11111111,        ' this is for scanning the rows
                                 %11111111,        //cathodes
                                 %11101111,
                                 %11111111,
                                 %11111111,
                                 %11111111,
                                 %11111111)

 Const One(8)As Byte = (%00000000,
                        %00000000,
                        %00000000,               //these are the anode,
                        %00010000,
                        %00000000,
                        %00000000,
                        %00000000,
                        %00000000)         

' number 2
                                
Const Two(8)As Byte =  (%10000000,
                        %00000000,
                        %00000000,
                        %00000000,
                        %00000000,
                        %00000000,
                        %00000010,
                        %00000000)                 
                                        
Const Three(8) As Byte =(%10000000,
                         %00000000,
                         %00000000,
                         %00010000,
                         %00000000,
                         %00000000,
                         %00000010,
                         %00000000)
                                        
 Const Four(8) As Byte =(%10000001,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %10000001,
                         %00000000)                                       
                        {                 
                        (%00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000)                                       
                         }                         
 
Const Five(8) As Byte = (%10000010,
                         %00000000,
                         %00000000,
                         %00010000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %10000010)   

Const Six(8) As Byte =  (%10000010,
                         %00000000,
                         %00000000,
                         %10000010,
                         %00000000,
                         %00000000,
                         %10000010,
                         %00000000)
                                                            
Const Seven(8) As Byte =(%10010010,
                         %00000000,
                         %00000000,
                         %10000010,
                         %00000000,
                         %00000000,
                         %10000010,
                         %00000000)
                        
                                                            
Const Eight(8) As Byte =(%10010010,
                         %00000000,
                         %00000000,
                         %10010010,
                         %00000000,
                         %00000000,
                         %10000010,
                         %00000000)
                        
 Const Nine(8) As Byte= (%10010010,
                         %00000000,
                         %00000000,
                         %10010010,
                         %00000000,
                         %00000000,
                         %10010010,
                         %00000000)
                        
                                                                                                  
 Const Ten(8) As Byte=  (%10010010,
                         %00000000,
                         %10010010,
                         %00000000,
                         %10000010,
                         %00000000,
                         %10000010,
                         %00000000)
                        
                                                            
Const Eleven(8) As Byte=(%10010010,
                         %00000000,
                         %10010010,
                         %00000000,
                         %10010010,
                         %00000000,
                         %10000010,
                         %00000000)
                        
                                                        
Const Tweleve(8)As Byte=(%10010010,
                         %00000000,
                         %10010010,
                         %00000000,
                         %10010010,
                         %00000000,
                         %10010010,                                 
                         %000000000)
            

// Start Of Program
'portd = 0
'portb = 1
SetAllDigital                       // Make all Pins digital I/O's

TRISB = %00000000                   // Make PORTB all outputs                 // Make PORTD all outputs
TRISC = %00000000                   // Make PORTC all outputs
TRISA = %00000000
TRISD = %00000000
x = 0
y = 0
Switch = 1
SetAllDigital
Input (Switch)
Switch = 1
PORTB = %11111111//Cathodes_Data(x) rows top to bottom
PORTD = %00000000//A_data(x) colums 8 (L-R


// Main Loop
While True()
  {
 
 //12
 repeat   
 For x = 0 To 7
 PORTD = Tweleve(x)// colums 8 (L-R the X is the scan
 PORTB = Cathodes_Data(x) //rows top to bottom
    DelayuS(200)   //keeps the led enabled until a button pressed
    Next
    Until Switch=0
    DelayMS(30)  //debounce
    
    
  //11
  Repeat
    For x = 0 To 7
        PORTB = Cathodes_Data(x) //rows top to bottom
        PORTD = Eleven(x)// colums 8 (L-R the X is the scan
       DelayUS(200)
       Next
       Until Switch=0
       DelayMS(30)
    
     //10
     Repeat
     For x = 0 To 7
        PORTB = Cathodes_Data(x) //rows top to bottom
        PORTD = Ten(x)// colums 8 (L-R the X is the scan
         DelayUS(200)
         Next
         Until
         Switch=0
         DelayMS(30)
        
     //9   
     Repeat
         For x = 0 To 7
            PORTB = Cathodes_Data(x) //rows top to bottom
            PORTD = Nine(x)// colums 8 (L-R the X is the scan
             DelayUS(200)
             Next
             Until Switch=0
             DelayMS(30)
            
            
     //8       
     Repeat
             For x = 0 To 7
                PORTB = Cathodes_Data(x) //rows top to bottom
                PORTD = Eight(x)// colums 8 (L-R the X is the scan
                DelayUS(200)
                 Next
                 Until Switch=0
                 DelayMS(30)
                
                
   //7             
     Repeat
              For x = 0 To 7
                    PORTB = Cathodes_Data(x) //rows top to bottom
                    PORTD = Seven(x)// colums 8 (L-R the X is the scan
                    DelayUS(200)
                     Next
                     Until Switch=0
                     DelayMS(30)
                    
     //SIX               
     Repeat
              For x = 0 To 7
                        PORTB = Cathodes_Data(x) //rows top to bottom
                        PORTD = Six(x)// colums 8 (L-R the X is the scan
                         DelayUS(200)
                         Next
                         Until Switch=0
                         DelayMS(30)  //debounce
      
      //5                   
              Repeat
              For x = 0 To 7
                  PORTB = Cathodes_Data(x) //rows top to bottom
                  PORTD = Five(x)// colums 8 (L-R the X is the scan
                  DelayUS(200)
                  Next
                  Until Switch=0
                  DelayMS(30)
                            
        //FOUR                     
              Repeat
              For x = 0 To 7
                  PORTB = Cathodes_Data(x) //rows top to bottom
                  PORTD = Four(x)// colums 8 (L-R the X is the scan
                  DelayUS(200)
                  Next
                  Until Switch=0
                  DelayMS(30)
            
             //3                   
                      Repeat
                      For x = 0 To 7
                          PORTB = Cathodes_Data(x) //rows top to bottom
                          PORTD = Three(x)// colums 8 (L-R the X is the scan
                          DelayUS(200)
                          Next
                          Until Switch=0
                                     DelayMS(30)
            //2                         
                         Repeat
                          For x = 0 To 7
                              PORTB = Cathodes_Data(x) //rows top to bottom
                              PORTD = Two(x)// colums 8 (L-R the X is the scan
                              DelayUS(200)
                              Next
                              Until Switch=0
                              DelayMS(30)         
                          }                         
                                        
                  //1                       
                       Repeat
                          'For x = 0 To 7
                              PORTB = %11101111 //rows top to bottom
                              PORTD = %00010000 //colums 8 (L-R the X is the scan
                              DelayUS(200)
                              PORTB=%11111111
                              DelayUS(1000)
                              'Next
                              Until Switch=0
                              DelayMS(30)       
                          
 'Next
 'Next
 //delayms(2000)INSERT A BUTTON PRESS HERE TO DECREASE THE NUMBER
// y = y + 1
 Wend           // Loop back to the while loop as long as we havent finished.
 
why is this 4

Code:
Const Four(8) As Byte =(%10000001,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %10000001,
                         %00000000)                                       
                        {                 
                        (%00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000,
                         %00000000)                                       
                         }
 
I'd try rearranging the output updates, like

Code:
PORTB = %11111111 // Turn everything off
PORTD = Tweleve(x)// colums 8 (L-R the X is the scan
PORTB = Cathodes_Data(x) //rows top to bottom

At the moment, the "wrong" column power is on for a very short time after the next character row pattern is output.
Setting them all off before making the change to the data pattern should give a cleaner transition.

The double data in "four" as atomsoft pointed out was another query.
 
if you look at the last routine I think I did exactly what you suggested?
Code:
 Repeat
                          'For x = 0 To 7
                              PORTB = %11101111 //rows top to bottom
                              PORTD = %00010000 //colums 8 (L-R the X is the scan
                              DelayUS(200)
                              portb=%11111111
                              delayus(1000)
                              'Next
                              Until Switch=0
                              DelayMS(30)
 
the #4 works good.
having issue with extra segment on in routines #5, 3, 2, 1 only
 
I tried taking the bull by the horns and still ghosting on routines 5, 3 and 1
all the other routines work great
Code:
   PORTD=%00010000 //anodes
                            PORTB = %11101111  //cathodes
                            DelayMS(1000)
                            PORTB=%11111111  //cathodes all off
                            DelayUS(200)
 
An LED driver chip such as the MAX7219 handles all the complexity of driving either eight 7-segment digits or an 8×8 LED matrix. You just tell the chip what to display and you're done with it until you want to display something else. Much less overhead and busywork in your code that way.

SmartSelect_20200608-121909_Firefox.jpgSmartSelect_20200608-121935_Firefox.jpg
 
I have several of the MAX7219 chips but would need to redesign my board. I am wondering why most of my routines work great EXCEPT Five, Three and One. Only common thing I come up with is a middle segment is used but it is used on the 12 - 7 routines with no issues. That should eliminate any shorts or defective Led matrix.
 
Last time I did this... I arranged the 8x8 matrices into a array of 32 x 16.. Then lit the leds like pixels of a screen.

The screen was held in a " backbuffer " and was written to the led matrices in an interrupt... Very smooth transitions.

I have video's but they are for 4 8x8 modules..
 
I tried just turning on 1 segment and still get an extra segment lit. plan to build another perf board with different matrix thinking maybe the matrix is defective. Purchased from online store.
Code:
 // PORTD=%00010000 //anodes
                            'PORTB = %11101111  //cathodes
                            'DelayMS(1000)
                            'PORTB=%11111111  //cathodes all off
                            'DelayUS(200)
 
Not sure why but went from common anode to common cathode and no ghosting?
now am trying to perform some multi tasking.
want to display the matrix THEN if a key press to toggle desired led. The matrix works fine as does the 10 buttons/leds but getting both to play together? attempted n interrupt but am sure it was not set up correctly.
trying to display the matrix THEN when adval changes from <1000 then toggle led.
If no key press then just display desired matrix and wait for a key press
 

Attachments

  • interrupt test.bas
    17.3 KB · Views: 171
Not sure why but went from common anode to common cathode and no ghosting?

Sorry, your code is more of a mystery than I care to unravel.

However, I believe you are using 8×8 LED matrices if I recall this saga correctly. I don't quite understand what you did to switch from "common anode" to "common cathode" as the nomenclature really doesn't make much sense in an 8×8 matrix. You can talk about row-common xxx or column-common xxx, but if you get right down to the details, a line of LEDs will have common anodes. The line of LEDs at 90° to the first line will have common cathodes. Whether the first line is a row or column depends on how the matrix is oriented.

So, I'm assuming you didn't change your code to "switch from" common anodes to common cathode. What you probably did was swap connections around. If this is indeed what you did, the problem is you had some shorts or wrong connections to start with that got corrected when you switched things around.

To illustrate my point about common anode vs common cathode, compare the schematics of a row-common-anode and a row-common-cathode 8×8 matrix. Rotate one of the images 90°, and you'll see the connection are exactly the same.

Just to be complete here, the above applies to monochromatic LED arrays. If you have an RGB array, each dot has a red, a green and a blue LED. In this case, each RGB LED will be either common anode or common cathode, but there will be a separate red, green and blue connections for the non-common column or row.

SmartSelect_20200626-195057_Dropbox.jpg
 
all I did was change the port disginations. The matrix pin outs are the same.
changed this
PORTD = Cathodes_Data(x) //rows top to bottom
PORTB = Two(x)// colums 8 (L-R the X is the scan
to this
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Two(x)// colums 8 (L-R the X is the scan

worked like a charm
will edit my code for a better understanding of what I am trying to achieve.
NOTE the circuit boards are all the same so there are no shorts etc.
 
here is maybe a shorter code. If I knew (read the help file on interrupts several times but?) can't get the configuration correct?


*****************************************************************************
 

Attachments

  • edited short.bas
    8.8 KB · Views: 171
all I did was change the port disginations. The matrix pin outs are the same.
changed this
PORTD = Cathodes_Data(x) //rows top to bottom
PORTB = Two(x)// colums 8 (L-R the X is the scan
to this
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Two(x)// colums 8 (L-R the X is the scan

worked like a charm

Like I said, I don't have the wherewithal to decipher your code. If your code does anything like you think it does, what you did can't possibly work. Good luck.
 
Regarding trying to read an ADC input:

The last version of your code has the command

SetAllDigital

three times. I guess you wanted to be sure!

What does SetAllDigital do?

Set – it sets something....

All – it sets ALL of something....

Digital – it sets all the pins to DIGITAL.

What's the alternative of digital? Analog, as in ADC.


In the last code you posted, you never set up the ADC, and then made doubly sure it wouldn't work by using SetAllDigital three times to be sure.

From the Swordfish ADC example:

Code:
// initialise and clear LCD...
ADCON1 = $07   // PORTE as digital (LCD)

//========================================
TRISA.0 = 1    // configure AN0 as an input 
ADCON1.7 = 1   // set analogue input on PORTA.0 
//=========================================

delayms (500)
LCD.Cls

This would have been clearer with the addition of ADC:

// initialise ADC and clear LCD...

Two lines in the middle set up AN0 as an ADC input. You must do this in your code.

So summarizing:

1. Use SetAllDigital exactly once to set all the analog pins to digital.

2. Follow that with the two lines from the example to enable AN0 as an ADC input. This must follow all your Tris statements too.

(A discussion of Tris vs setting each pin as an input or output could follow here, but what's the point?)

Beyond this pointer, your code baffles me. Good luck untangling the mess.
 
Thanks Jon I made all corrections etc.
It now works ok (better than it did) but the matrix is blinking too fast. need to tweek it.
the adc works really well. I put the matrix sub route after the CASE SELECT and it responds better but get too muck blinking. get back at it later today after trip to Longview.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top