Saturday, July 28, 2012

Multiplexing

Multiplexing is a very efficient technique for controlling many components wired together in a matrix/array.  In this example, I'll be talking exclusively about multiplexing an array of LEDs, but the same basic principles apply to other multiplexed components (sensors, buttons, etc).

   
In a multiplexed array of LEDs, only one row of LEDs is on at any given time.  It seems like this would limit the types of shapes we can display on the LED matrix, but it actually doesn't.  This is because the arduino (or whatever is sending data to the array) is switching through each row so quickly (hundreds or thousands of times a second) that we do not perceive the flashing on and off of each consecutive row.  You can read more about this phenomenon, called persistence of vision, on wikipedia.            

            multiplex1.gif                      

So how do we send data to one row at a time?  If we connect five volts (red) to one row and connect ground (blue) to the other three rows and cycle through each row one by one, it will look something like figure 1.  Now image that while one of the rows is at +5, we connect one of the columns to ground.  As shown in figure 2, this will cause the LED at the junction of the +5 row and GND column to light up.  This way, we can address each of the 16 LEDs in the matrix individually using only eight leads (four to the rows and four to the columns).



Now look at the image below.  Imagine if we very quickly turn on the LED in the upper left corner (position 1,1), then the LED at (2,2), then (3,3) and (4,4), and we cycle between these four LEDs very quickly (hundreds of times a second).  It will appear that all four of these LEDs are on a the same time (as shown in right image in the image below).  Study the diagram below and convince yourself that this is true.
                    

No comments:

Post a Comment