Multiplexing was first used in the 1870s, but what is it and how is it used? What are the various types of multiplexing? What about keyboard matrices and Charlieplexing?
The opposite of MUXing is DEMUXing, which is a way of separating all the combined signals at the other end.
These days it is used in TV and radio stations, telephone networks, satellite communications, you are even using multiplexing to read this article and watch this video as you are sharing the Internet with billions of other users.
In electronics there are three common methods of employing multiplexing; Time, Frequency and Space.
- TDM - Time Division Multiplexing.
- FDM - Frequency Division Multiplexing.
- SDM - Space Division Multiplexing.
Time Division Multiplexing
Frequency Division Multiplexing
Space Division Multiplexing
With SDM, signals are combined within the space space…
There's also several other sub methods:
Polarization Division Multiplexing
Code Division Multiplexing
CDM, is something you have been using for many years and is seen in the humble mobile phone. Often also referred to as CDMA, it employs frequency hopping or DSSS to achieve multiplexing.
Orbital Angular Momentum Multiplexing
Finally, OAM, is a very recent technology that takes PDM further by using the orthagonal quantum states of light to multiplex signals. I won't go into this here as it's still only in research.
Whichever method you look at, they all have one common goal, which is to do more, with less.
When it comes to electronic circuits there are several semiconductors that use multiplexing.
Multiplexing is also used in keyboards.
So, instead GPIOs are arranged in a matrix and keys placed at every point where X and Y meet.
Keyboard ICs will scan across columns within the matrix at a certain rate to determine which key has been pressed.
There's also another form of keyboard multiplexing, where it relies on a resistor divider to determine which key or keys have been pressed.
This works as a voltage divider where the buttons are tied to Vcc and the common line connected to the GPIO pin of your MCU, which is also tied to ground.
The incremental resistor values will effectively give you base-2 and since it's a resistor ladder, the formula to calculate resistors in parallel is:
Rtotal = 1 / ( 1/R1 + 1/R2 + 1/R3 + 1/R4 ...)
Any switch not pressed will, of course, not be involved in the calculation. Once you have calculated the resistor value, then use the standard voltage divider formula to determine the output voltage to be expected. Here I use 5v as the voltage level.
5 * (Rtotal / ( Rtotal / 1000 ) )
If you work through each of the columns you'll see that not one of the button press combinations are repeated. The downside is that you'll need a fairly accurate DAC as you'll expect to see a 0.01v resolution, which means you'll need at least 500 steps.
5v / 0.01v = 500
500 steps means at least 9 bit resolution.
2 ^ 9 = 512
Matrix multiplexing is also used in displays with the switches replaced by LEDs at each point. A microcontroller will scan through the matrix lighting up a row at a time. This relies on Persistance of Vision in the human eye to fool us into thinking all LEDs are light up at the same time.
There is another form of multiplexing display called Charlieplexing.
Like keyboard multiplexing, Charlieplexing relies heavily on a GPIO pin's ability to drop into tri-state mode. That is: High, Low, or not connected.
At it's basic level Charlieplexing can be used to control 2 LEDs with only two GPIOs.
- Setting GPIO1 to high and GPIO2 to low will light up LED 1.
- Setting GPIO1 to low and GPIO2 to high will light up LED 2.
- Setting both GPIOs to tri-state mode will turn both LEDs off.
But there are a few disadvantages.
- There are no diagonal LEDs available, so you have to translate X and Y co-ordinates within software.
- LED brightness is much harder to control.
Much like dedicated keyboard controllers, you can also buy dedicated Charlieplexing ICs.
So as you can see multiplexing is actually very important within electronics, to allow sharing of minimal resources.
Copyright notice: Some of the images in this article have been taken from Wikipedia under the Creative Commons license.