Multiplexing a Multiplexer

Thread Starter

adam555

Joined Aug 17, 2013
858
What's the best technique to multiplex a multiplexer?

Say that we have the circuit bellow, but instead of just 4 digits we need 4 rows of 4 digits: what's the best way to do that with a microcontroller, while trying to:
-keep the number of I/O pins used to a minimum
-keep the number of external components to the microcontroller to a minimum
-preferably -though you could if necessary- not using any other ICs.



Thank you in advance for your help.

...

By the way, I saw designs where they don't use the transistors; instead they connect each ground of the displays to their corresponding I/O pin directly, and turn it ON/OFF by changing the mode of the I/O pin from INPUT to OUTPUT.

I tried this technique and it seems to work well -at least with an Arduino- but I was wondering if it has any risks or downside, and if it would also work in other platforms (e.g. with PICs).
 

GopherT

Joined Nov 23, 2012
8,009
If you use an I/O pin, you could overload it, or the entire chip (power ratings for both are listed on the datasheet (pin and chip).

As for multiplexing 16 or more digits, you end up with either (1) flickering display depending on how many times you can update each digit each second, or, (2) dim display because each digit is on for such a very short pulse if you are updating fast enough to avoid flicker.

I suggest over current t driving the LEDs because the pulse (and duty cycle) is so short (and low).

By the way, there are multiplexing chips with more than 8 channels so just buy one of those and cycle through each digit.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Thanks GopherT

I guess I'll also have to account for the flickering or dimming with the chip.

The circuit will be running at 5V and I'm not sure about the current, but I think the limit is between 100mA and 500mA -the less used the better-.

Is there any alternative to use over current in order to avoid the flickering or dimming? I don't know, maybe the multiplexing chip doing 2 or 4 digits at a time, or something like that...
 
Last edited:

Thread Starter

adam555

Joined Aug 17, 2013
858
I was looking for multiplexing chips and I can't find any with the necessary digits (I need to display 20 digits in total).

If I add the flickering/dimming problem, I guess I'll have to look for another solution than having them all on the same line.

So, if I have to separate them in various lines; what's the best way to do that? Again, keeping the number of I/O pins to a minimum, etc...
 

bertus

Joined Apr 5, 2008
22,278
Hello,

How about two 74154's for scanning the displays?

Rich (BB code):
74154

1-of-16 inverting decoder/demultiplexer.
     +---+--+---+
 /Y0 |1  +--+ 24| VCC
 /Y1 |2       23| S0
 /Y2 |3       22| S1
 /Y3 |4       21| S2
 /Y4 |5       20| S3
 /Y5 |6   74  19| /EN2
 /Y6 |7  154  18| /EN1
 /Y7 |8       17| /Y15
 /Y8 |9       16| /Y14
 /Y9 |10      15| /Y13
/Y10 |11      14| /Y12
 GND |12      13| /Y11
     +----------+
Each could scan 16 displays.
By switching between the two, you can have upto 32 outputs.

Bertus
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Yes, that sounds good... thanks Bertus

I never used a decoder before for multiplexing, but I guess the switching between the two would not be that different from what I'm doing already to multiplex between digits.

Following that line, I guess I'd better use 3 of 8 digits...

...

What about the flickering/dimming between all 20 digits; can I take advantage of using various multiplexers to diminish it?

If so, how?
 
Last edited:

bertus

Joined Apr 5, 2008
22,278
Hello,

3 X 8 would be 24.
You said you needed 25.

BTW the 74138 is a 1 to 8 decoder:

Rich (BB code):
74138

1-of-8 inverting decoder/demultiplexer.
     +---+--+---+            +---+----+----+---+---+---*---+---+---+---+
  S0 |1  +--+ 16| VCC        |EN1|/EN2|/EN3| S2| S1| S0|/Y0|/Y1|...|/Y7|
  S1 |2       15| /Y0        +===+====+====+===+===+===*===+===+===+===+
  S2 |3       14| /Y1        | 0 | X  |  X | X | X | X | 1 | 1 | 1 | 1 |
/EN3 |4   74  13| /Y2        | 1 | 1  |  X | X | X | X | 1 | 1 | 1 | 1 |
/EN2 |5  138  12| /Y3        | 1 | 0  |  1 | X | X | X | 1 | 1 | 1 | 1 |
 EN1 |6       11| /Y4        | 1 | 0  |  0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
 /Y7 |7       10| /Y5        | 1 | 0  |  0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
 GND |8        9| /Y6        | 1 | 0  |  0 | . | . | . | 1 | 1 | . | 1 |
     +----------+            | 1 | 0  |  0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
                             +---+----+----+---+---+---*---+---+---+---+
When you scan 25 displays, the intensity will be 1 / 25 of the original.
(it is like a PWM of 4 %).
Using a driver that can give almost the maximum current allowed for the display will give it a bit more intensity.
The flickering can be reduced by increasing the scanspeed.

Bertus
 

Thread Starter

adam555

Joined Aug 17, 2013
858
The "25" was a typo... I edited it to 20 digits as soon as I realize it. It has 4 rows of 5 digits -maybe it would be even better to use 4 multiplexers instead of 3 and keep them together-.

I already did some trials with 4 digits (which is the maximum number of displays I have available at this moment) and I already noticed that I had to balance the refresh rate to avoid flickering or dimming. I currently set each display to stay on for 1ms, which is enough to see the digits clearly and avoid flickering.

But I was thinking that if I'm using 3 separate multiplexers, that maybe there was a way to take advantage of it and diminish the problem. For example: instead of displaying one of the 20 digits at a time, do it with 3 at a time (1 for each multiplexer). Could it be done?
 
Last edited:

Thread Starter

adam555

Joined Aug 17, 2013
858
Hope nobody read the previous post that I deleted. :p

Made a test circuit to simulate the 20 digits, and they are quite dim; barely visible. First changed the 500Ω resistors from the segments to 200Ω -which practically had no effect- and then connected the segments directly to the outputs; also without making much difference.

I think Arduino limits the pin output current to 40mA (not sure about the PIC which is what I'll end up using), and at first I was worried about this current damaging the displays. But then read in the display's datasheet that I can use up to 150mA peak current; as long as the peaks are less than 40 μs long. However, I guess that to achieve the 150mA peaks I will need to use transistors to connect the each segment to the main 5V, or another similar method; which complicates the circuit a lot.

Any suggestions? :(
 

ian field

Joined Oct 27, 2012
6,536
What's the best technique to multiplex a multiplexer?

Say that we have the circuit bellow, but instead of just 4 digits we need 4 rows of 4 digits: what's the best way to do that with a microcontroller, while trying to:
-keep the number of I/O pins used to a minimum
-keep the number of external components to the microcontroller to a minimum
-preferably -though you could if necessary- not using any other ICs.
.
If your primary concern is using the least number of CPU pins; the favourite is using just a couple of pins to clock the bit patterns out to a SIPO shift register.

You can do this for both the segment patterns and the digit strobe sequence - but the nested loops in the I/O control can get quite fun.

Most people just use a 1 of n decoder to reduce pin count on the digit strobes.
 

GopherT

Joined Nov 23, 2012
8,009
Hope nobody read the previous post that I deleted. :p

Made a test circuit to simulate the 20 digits, and they are quite dim; barely visible. First changed the 500Ω resistors from the segments to 200Ω -which practically had no effect- and then connected the segments directly to the outputs; also without making much difference.

I think Arduino limits the pin output current to 40mA (not sure about the PIC which is what I'll end up using), and at first I was worried about this current damaging the displays. But then read in the display's datasheet that I can use up to 150mA peak current; as long as the peaks are less than 40 μs long. However, I guess that to achieve the 150mA peaks I will need to use transistors to connect the each segment to the main 5V, or another similar method; which complicates the circuit a lot.

Any suggestions? :(
The transistors are necessary to get higher currents than the pins can supply. You may need transistors for both rows and columns of your matrix of 4 x 5 digit displays. Normally, those displays are 10 or 20mA per segment per display. That means you can likely pulse up to 50 mA per segment at 5% duty cycle. If all 7 segments of a display are on, then you are running up to 350 mA (for the multiplexed common) when an 8 is displayed.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
If your primary concern is using the least number of CPU pins; the favourite is using just a couple of pins to clock the bit patterns out to a SIPO shift register.

You can do this for both the segment patterns and the digit strobe sequence - but the nested loops in the I/O control can get quite fun.

Most people just use a 1 of n decoder to reduce pin count on the digit strobes.
Thanks for that. I'll have a look at this method; as I only have 14 I/O pins in total, and need around 6 for other things.

On the other hand, this method would make the dimming problem worse; wouldn't it?
 

Thread Starter

adam555

Joined Aug 17, 2013
858
You need to use 74HC595 as this, and you can expending some more even as this.
Not sure, but I think I understand...

This method uses a 74HC595 for each digit, and keeps it on all the time. Right?

It's definitely a solution to all the problems; the only downside is that I would had preferred to do it with as less components as possible (specially extra ICs).

...

It's really a pity; if I could just squeeze a couple of mA more from the microcontroller I could have done it without a single external component; not even the 8 resistors. Unfortunately, once I pass it to the PIC it will get worse; as I just read the current output on the pins is just 25mA (15mA less than the Arduino board).
 

ian field

Joined Oct 27, 2012
6,536
Not sure, but I think I understand...

This method uses a 74HC595 for each digit, and keeps it on all the time. Right?

It's definitely a solution to all the problems; the only downside is that I would had preferred to do it with as less components as possible (specially extra ICs).

...

It's really a pity; if I could just squeeze a couple of mA more from the microcontroller I could have done it without a single external component; not even the 8 resistors. Unfortunately, once I pass it to the PIC it will get worse; as I just read the current output on the pins is just 25mA (15mA less than the Arduino board).
Your digit strobes have to supply up to the combined current of however many segments that digit has - most people use a driver transistor, especially as strobing means you need to increase the per pulse current to keep the average high enough for visibility.
If you're only using 7 segment digits; you only need 4 lines to drive a BCD decoder/driver, those are at least getting rarer - you may have to program a small ROM. Shifting your segment drive pattern into a SIPO shift register only takes 2 pins and your character set is entirely software defined in your micro.
 

MMcLaren

Joined Feb 14, 2010
861
Would something like this work (below)? It's a method that retasks the column driver lines for use as <clock> and <data> lines to load the shift registers (parallel SPI) during a short blanking interval at the beginning of each column display cycle. It uses six I/O pins to drive four 5-digit displays with a very respectable 20% duty cycle while the duty cycle of the PWM output controls display brightness.

Another solution might be to use a MAX7219 IC for each five digit module via daisy-chained SPI interface.

Regards, Mike
 

Attachments

Last edited:

ian field

Joined Oct 27, 2012
6,536
Would something like this work (below)? It's a method that retasks the column driver lines for use as <clock> and <data> lines to load the shift registers (parallel SPI) during a short blanking interval at the beginning of each column display cycle. It uses six I/O pins to drive four 5-digit displays with a very respectable 20% duty cycle while the duty cycle of the PWM output controls display brightness.

Another solution might be to use a MAX7219 IC for each five digit module using a daisy-chained SPI interface.

Regards, Mike
One thing I forgot to mention - if the SIPO shift register is long enough, i.e. has enough parallel outputs to address all the segments of all the digits, then there's no need to strobe the digits.

All you have to do then is clock nx enough segment bits into the register and enable the outputs.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Would something like this work (below)? It's a method that retasks the column driver lines for use as <clock> and <data> lines to load the shift registers (parallel SPI) during a short blanking interval at the beginning of each column display cycle. It uses six I/O pins to drive four 5-digit displays with a very respectable 20% duty cycle while the duty cycle of the PWM output controls display brightness.

Another solution might be to use a MAX7219 IC for each five digit module via daisy-chained SPI interface.

Regards, Mike
I like this two methods, as they drastically cut down the number of ICs. But they are also the most complicated for me to understand; specially when I don't have the parts at hand to test.
 

elec_mech

Joined Nov 12, 2008
1,500
Lot of neat ideas . . .

OP, what are the size of the displays you'll be using, e.g., 0.56", 1", 2.3", 4", etc.? This determines the voltage needed and whether or not you can use the same voltage as the microcontroller (uC). If using displays larger than 1", then you'll need to add transistors no matter which option you choose.

Do each of the 20 digits need to display a different number? When you originally stated four rows of four digits, I wasn't sure if you were repeating the same display four times or needing 16 unique values to display. I assume the latter, but want to be sure. :)

Assuming you need to control 20 digits individually and your displays are 1" or less, I'd suggest a MAX7219 (I2C) or MAX7221 (SPI). One IC controls eight seven-segment displays and only requires one resistor to set the max current to the displays. No need for transistors or extra parts. You should be able to use just 2-3 I/O pins to control all 20 digits with three IC's.

Yes, this does require more IC's than just a uC, but it eliminates the need for transistors and off loads a lot of time and code to the Maxim IC's. You can also control brightness through the software. One thing to note however is the price - these IC's run about $11 USD apiece, so not the least expensive option, but they'll save you a lot of time, coding, and wiring.

Another option is to use a display with a pre-built controller such as this. I used one of these for another project here and they worked well. Since these are I2C, you should be able to get away with just two pins to control five of these, though you'll probably have to connect one at a time and define a different address for each the first time you use them.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
I'm not sure which displays I'll use; but they will be small. I ordered 0.56" and 0.36" already to compare. The 4 at have at home for testing are 0.56".

Now that you mention it, the first digit of each row will always be the same; but the rest (16 digits) will be all different.

Yes, I was beginning to consider using the MAX7219 that MMcLaren suggested above as the best option. Either that, or simply using transistors to increase the peak current on each refresh; maybe even using a few ULN2003 or similar instead of single transistors.

About the pre-built displays: initially, I prefer not to use them; even though I know they are cheaper than if I put it together myself. Besides, I'm not sure I'll find them with 5 digits each.
 
Last edited:
Top