Two 4051's to drive 8x8 LED matrix - interference

Hello everyone,

I am relatively new to the electronics and hope to find an explanation/some tip on the following.

I am using 2 x 4051 multiplexers (one as mux, second - demux) to have access to all 64 led in my LED matrix using only 6 Arduino pins.
My code is running as I wish but there appear some parasite leds. Here is complete code

const int oA = 5;
const int oB = 6;
const int oC = 7;
const int iA = 10;
const int iB = 11;
const int iC = 12;

int pinOuts[3]={oA,oB,oC};  //mux control pins
int pinIns[3]={iA,iB,iC};   //demux control pins

// adresses of columns of Matrix
int ColVol[8][3] = { \
    {LOW,LOW,LOW},\
    {LOW,LOW,HIGH},\
    {LOW,HIGH,LOW},\
    {LOW,HIGH,HIGH},\
    {HIGH,LOW,LOW},\
    {HIGH,LOW,HIGH},\
    {HIGH,HIGH,LOW},\
    {HIGH,HIGH,HIGH},\
};

// adresses of rows of Matrix
int RowVol[8][3] = { \
    {LOW,LOW,LOW},\
    {LOW,LOW,HIGH},\
    {LOW,HIGH,LOW},\
    {LOW,HIGH,HIGH},\
    {HIGH,LOW,LOW},\
    {HIGH,LOW,HIGH},\
    {HIGH,HIGH,LOW},\
    {HIGH,HIGH,HIGH},\
};


//sample letter "H"
int H[8][8]= { \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}  \
};


void setup() {
     for (int f = 0; f < 3; f++) {
       pinMode(pinOuts[f],OUTPUT);
       pinMode(pinIns[f],OUTPUT);
     }
}


void loop() {
  

  for (int i=0; i<8; i++) 
  {
    for (int j=0; j<8; j++) 
    {
      if (H[i][j] == 1)
      {
        for (int k=0; k<3; k++) 
        {
          digitalWrite( pinOuts[k], RowVol[i][k]);
          digitalWrite( pinIns[k], ColVol[j][k]);
        }
       delay(1);
      } 
      
    }
      
  }

}

if I don't use delay (1) vertical columns of the letter H have neighbors slightly lit up.

Has someone seen this before?
Any ideas how to have exactly wanted leds on?

Thanks in advance

I am using 2 x 4051 multiplexers (one as mux, second - demux)

That is not very normal, have you got a schematic of how you have wired it up?
Normally an 8X8 matrix is wires up using latches and buffers.
Using a 4051 for lighting up LEDs not not a good idea. The current is limited. It is designed for more of inputs.
See this for typical configurations:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

Thanks a lot for rapid reaction!

I am going to put schematic using Fritzing. need some time.
Cheers

rodneysfan:
Thanks a lot for rapid reaction!

I am going to put schematic using Fritzing. need some time.
Cheers

Can you not draw it with pen and paper, that package produces totally unreadable schematics.

I attach an image of how things are hooked. I decided not to draw exact matrix pin connections (for the sake of image clarity), I personally do not think that it would matter for my problem.
I really do not get how leds that are in LOW@ +ve terminal and LOW@ -ve terminal can have any current passing through.
Thanks again for your time!

I personally do not think that it would matter for my problem.

Yes but it would make other people understand what you are doing a lot better.

Sorry I don't know where you got that design from but it is very wrong.
First of all there is no current limiting components, a resistor is the simplest way of limiting the current.

Next you can only light up one LED at a time. This means that each LED is only on for 1/64th of the time. That means it will be very dim, remember you do fading with PWM by adjusting the on / off ratio.

I really do not get how leds that are in LOW@ +ve terminal and LOW@ -ve terminal can have any current passing through.

Yes you are right about this.

I was thinking that the pullup and pulldown resistors attached to pin 3 (common out/in) of mux/demux would limit current.
Leds are already dim if hooked up with those two resistors only.

Sorry but have you any idea how hard it is to see what a circuit is doing without a schematic.

Here is a new sketch. Hope it clarifies things.

Thanks now I can see exactly what is wrong.

  1. You should not have any resistors in the +5V supply to the chip.
  2. A series resistor of 2K2 in the common input to the selector is way too high. This needs to be in the order of 100R or so.

Having said that read my other concerns about this design, especial the bit about having a 1 to 64 on / off ratio of the LED the LED is always going to be dim.

Thank you,

I did as you suggested but unfortunately the parasitic leds are still on. And here I am agree that it has to do with 1/64 on/off ratio.
To give an idea what I mean under "parasitic" I attach some photos of letter H:
one without delay( in the innermost loop) - columns #1,3,6,8 are not supposed to light up.
and two photos with delay (1) - you can see that these column get dimmer.
With even higher delays these column dissapear but the trade-off is that I get noticeable blinking.
I am asking myself now, if it is possible to have neat letters (static or scrolling or whatsoever) using two MUXes.

This comes about because when you write the three bits to change the data line selected you do this one at a time. So suppose you go from 011 to 100 you go through the intermediate stages of 010, 000 and 100. This addresses very briefly the wrong data lines and so can light up the wrong LEDs. Without a delay this intermediate state is a significant fraction of the time the targeted LED is on. As the delay gets longer this fraction gets smaller.

Ways round this:-

  1. Use the data enable line to turn the data selector on and off while changing the address.
    or
  2. Use direct port addressing to change all the data select address lines at the same time. Although there will still be a slight amount of time with the wrong addresses due to propagation delays through the chip.

Thanks a lot!

I just read an article about direct port adressing, definitely an option to try out.
And data enable line you've mentioned, I guess you meant INH (inhibit) pin ? I will try and get back with feedback.

Have a nice Sunday

Have you read the data sheet? the part about on channel resistance from a single ended supply? The applicable data sheets are supplied.

74HC4051.pdf (121 KB)

CD405X.pdf (193 KB)

Why not use a chip that's designed for the job, like the MAX7219 ?

True, I had a choice between MAX7219 and CD4159. At that time I was looking at something that I could connect 100% myself (no help from outside :cold_sweat:) and rapidly, so I chose CD4159 for simplicity and datasheet clarity.
Oh yeah, as far as I understood MAX7219 is best suited for common cathodes, meaning I had to do some stuff (advised at forums, like inverting currents and many more I do not understand at all) to get it working with common anode matrices.