Go Down

Topic: Multiplexing - I need to run this idea by someone (Read 1 time) previous topic - next topic

scswift

Feb 17, 2010, 10:31 am Last Edit: Feb 17, 2010, 10:34 am by scswift Reason: 1
Hey guys,

I've been planning to build a project where I need to control four 20 segment led bar graphs, and I've been considering my options for how to control them with my Arduino Pro Mini.  Multiplexing is one obvious solution, but dividing the array up into 8 10 segment sections would still require 18 pins, which is too many.  Other solutions I've looked at are leaving out a few of the led's on each end, shift registers, and charlieplexing.  None of which are particularly appealing to me, for various reasons.  Charlieplexing got me thinking though.

I was looking at this graphic in the Wikipedia article about it:


And I wondered... why use two pins to control two leds?

Why not do this?


So I looked up whether that was possible, and I found this thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249317220

Which says you can indeed use this method to turn one led on, or the other, but if you want to turn both off, you need a diode.  But that only applies to one pin connected through two leds to Vcc and Ground.  

Now, at this point, I must admit, I've reached the limits of my knowledge of circuits, but this is the idea that came to me:  If you can do the above... if you can indpendently control two led's from one pin, could you use this to reduce the number of pins needed to drive an array?

What I'm imaginging is an array where every other row has the led's reversed, like so:

(-+)(-+)
(+-)(+-)

The idea being to connect rows 1 and 2 to pin 1, and colums 1 and 2 to pins 2 and 3.  

Setting pin 1 high would then give the led's in row 1 the potential to light, while the leds in row 2 would not conduct.  (I am indexing here with 1,1 in the lower left corner because I am designing a vu meter, btw.)  Then, setting pin 2 low would cause led 1,1 to light, while setting pin 3 low would cause led 1,2 to light.

Of course there is the issue of what happens when you expand this out.  What if there were four leds in each column?  Then you would have two leds in each columnt that would be set high or low. But this is where the charlieplexing comes in.  There's that third state.  Could you set all the unused pins to an input state perhaps to make this work?

What do you think?  Would this allow me to multiplex a 20 x 4 matrix of leds with just 14 pins, or a 10x8 matrix with just 13, instead of the 18 or 24 pins which would normally be required?  And without a bunch of extra diodes? What I like about this idea is that the wiring would be really simple, and I don't think there'd be issues with leds burning out if the code crashes.

Ofcourse that assumes this would work at all.  And I have no idea if it would.

Grumpy_Mike

#1
Feb 18, 2010, 10:21 am Last Edit: Feb 18, 2010, 10:39 am by Grumpy_Mike Reason: 1
Quote
if you can indpendently control two led's from one pin,


No.
One pin can only be in two states (zero or one) therefore you can't control a system that has more than two states. Two LEDs controlled independently can have four states, therefore you need to be able to set four states in software. The minimum number of pins for four states is 2. In general the number of states given n pins is :- 2n .

That second circuit will not work. First off if the pin is low then the top LED is lit. If the pin is high both LEDs are lit. In addition there is nothing to limit the current through the LEDs so they will probably burn out unless something skanky is going on with voltage drops across the diode. It is a very bad circuit don't go there.

Quote
Could you set all the unused pins to an input state perhaps to make this work?

This driving technique is called Charliplexing, google it.
It involves setting a pin as a high impedance, so a pin has three states, high, low, high impedance. This increases the number of states for n pins to 3n

scswift

Quote
No. One pin can only be in two states (zero or one)


Quote
This driving technique is called Charliplexing, google it.
It involves setting a pin as a high impedance, so a pin has three states


Aren't these two statements conflicting?

Also, I don't need to google Charlieplexing, I already did.  That's what gave mt the idea for this technique.  I said so much at the satrt of my post, and even posted a schematic from the article.


Quote
Two LEDs controlled independently can have four states, therefore you need to be able to set four states in software. The minimum number of pins for four states is 2.


I undertsand what you're saying, but when I said I wanted to control the LEDs independently, what I meant was I wanted to be able to turn one or the other on, or both off.  That's three states.  And can't that be done with Charlieplexing and that third input state?


Quote
That second circuit will not work. First off if the pin is low then the top LED is lit. If the pin is high both LEDs are lit.


I don't understand.



If pin 1 is set high (+5v), then electricity should be flowing from it, through the bottom LED, and to ground, which I assume is 0v.  How can the top LED light though?

Oh... wait, I see.  I failed to take into account there is a direct path through the second LED to ground.  DUH.

Hm...


Quote
This driving technique is called Charliplexing, google it.



Okay, but my question, now reworded, still stands:

Can the 2 LED version of Charlieplexing be used to control the rows in an array of LEDs, to reduce the number of pins needed for the rows by half?

Grumpy_Mike

#3
Feb 18, 2010, 01:25 pm Last Edit: Feb 18, 2010, 01:26 pm by Grumpy_Mike Reason: 1
Quote
Can the 2 LED version of Charlieplexing be used to control the rows in an array of LEDs, to reduce the number of pins needed for the rows by half?

Yes.
The MAX6594  uses charliplexing in this way. They have a web page on it:-
http://www.maxim-ic.com/app-notes/index.mvp/id/1880
You can also download a PDF of this page.

This is a very flexible chip capable of operating in several modes of operation. For more examples see:-
http://www.maxim-ic.com/app-notes/index.mvp/id/3210

scswift

Here is the circuit I'm proposing, maybe this will help:



So, looking at this, let's say I I set pin 1 high, pin 2 low, and pin 3 to an input state.  What will happen?

My intuition tells me, that current should flow from pin 1 through the top led, and then down to pin 2, and that the second led below it, on the loopback, shouldn't light.

And if I then reverse that and set pin 1 low and pin 2 high, then the reverse should occur.

And lastly, if I set both pins to an input state, then neither led should light.

Is this correct, and if not, why?

Grumpy_Mike


scswift

I'd like to do this without an extra chip.  Will the above layoput work?  If so, do I need redistors on the columns, or will just the rows suffice?

Grumpy_Mike

Quote
If so, do I need redistors on the columns, or will just the rows suffice


Just one resistor will suffice, remove either one.

scswift

#8
Feb 18, 2010, 01:46 pm Last Edit: Feb 18, 2010, 01:47 pm by scswift Reason: 1
Quote
If so, do I need redistors on the columns, or will just the rows suffice



So that circuit I drew will work?  And I can remove the resistors from either the rows or the columns?  That's great!  

If I remove the resistors from the rows, then that means I can multiplex four 20 segment led bargraphs off my Arduino Pro using just 14 pins and 4 resistors!  (Or just 13 pins and 5 resistors if I got creative with the wiring and treat them like eight 10 segment bargraphs.)

I just hope I can multiplex them fast enough to avoid flicker.  But I'll cross that bridge when I come to it.  A little flicker won't neccesarily be a game killer.

Anyway, thanks for all the help!

scswift

#9
Feb 18, 2010, 02:22 pm Last Edit: Feb 18, 2010, 02:23 pm by scswift Reason: 1
One more question.



If I expand the circuit out like this, and have pin 1 set high, pin 2 set low, and pins 3 and 4 set to an input state, is that still going to light the correct LED?  It's not gonna cause a short or something, will it?


I'm guessing it will work fine, but I don't like guessing. :-)


(Just an aside, I should probably flip the led's around here so the anodes and cathodes are the opposite way, because the indexing pattern will be screwy if I keep them this way.)

Grumpy_Mike

With Pin 1 set High and Pin 2 low then the LED on row 3 will be on.

However, there is also a current path through LED row 3 col 2, to LED row 2 col 2, LED row 1 col 1 to ground.

Now that is 3 LEDs in series so if you have a 5V line providing your LEDs drop more than 1.6V across each one these three LEDs shouldn't turn on.

scswift

Ah.  Crap.  I see the path now.

Is there any easy way to fix that?  I don't suppose setting pin 3 high would stop the led in row 3 column 2 from lighting and prevent the other two from lighting as well.

Go Up