Multiplexing a Multiplexer

Discussion in 'General Electronics Chat' started by adam555, Aug 17, 2014.

  1. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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.

    [​IMG]

    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).
     
  2. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,070
    3,841
    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.
     
    adam555 likes this.
  3. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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: Aug 17, 2014
  4. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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...
     
  5. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello,

    How about two 74154's for scanning the displays?

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

    Bertus
     
  6. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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: Aug 17, 2014
  7. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello,

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

    BTW the 74138 is a 1 to 8 decoder:

    Code ( (Unknown Language)):
    1.  
    2. 74138
    3.  
    4. 1-of-8 inverting decoder/demultiplexer.
    5.      +---+--+---+            +---+----+----+---+---+---*---+---+---+---+
    6.   S0 |1  +--+ 16| VCC        |EN1|/EN2|/EN3| S2| S1| S0|/Y0|/Y1|...|/Y7|
    7.   S1 |2       15| /Y0        +===+====+====+===+===+===*===+===+===+===+
    8.   S2 |3       14| /Y1        | 0 | X  |  X | X | X | X | 1 | 1 | 1 | 1 |
    9. /EN3 |4   74  13| /Y2        | 1 | 1  |  X | X | X | X | 1 | 1 | 1 | 1 |
    10. /EN2 |5  138  12| /Y3        | 1 | 0  |  1 | X | X | X | 1 | 1 | 1 | 1 |
    11.  EN1 |6       11| /Y4        | 1 | 0  |  0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
    12.  /Y7 |7       10| /Y5        | 1 | 0  |  0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
    13.  GND |8        9| /Y6        | 1 | 0  |  0 | . | . | . | 1 | 1 | . | 1 |
    14.      +----------+            | 1 | 0  |  0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
    15.                              +---+----+----+---+---+---*---+---+---+---+
    16.  
    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
     
  8. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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: Aug 17, 2014
  9. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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? :(
     
  10. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    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.
     
  11. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,070
    3,841
    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.
     
  12. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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?
     
  13. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    You need to use 74HC595 as this, and you can expending some more even as this.
     
    absf likes this.
  14. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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).
     
  15. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    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.
     
  16. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    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
     
    Last edited: Aug 17, 2014
    absf likes this.
  17. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    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.
     
  18. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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.
     
  19. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    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.
     
  20. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    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: Aug 18, 2014
Loading...