Multiplexing: Doing more with less. // Technology
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?
Purpose
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…
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.
Uses
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.
Keyboard 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.
Resistor ladder
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 ) )
Therefore:
1k | 2k | 4k | 8k | 16k | 32k | Calcohms | Voltage |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 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 1 | 1 | 1 | 1 | 0 | 1066 | 2.58 |
1 | 1 | 1 | 1 | 1 | 0 | 516 | 1.70 |
0 | 0 | 0 | 0 | 0 | 1 | 32000 | 4.85 |
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
Display multiplexing
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.
Charlieplexing
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.