Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorials:multiplexing_inputs_to_a_microcontroller [2022/03/20 21:26] – created brady.boettchertutorials:multiplexing_inputs_to_a_microcontroller [2022/03/22 18:43] (current) brady.boettcher
Line 5: Line 5:
  
 =====  Multiplexer operation and considerations  ===== =====  Multiplexer operation and considerations  =====
-A multiplexer acts as a switching circuit that selects one of several inputs to send to the single output. Both analog and digital values can be used as inputs for these devices, as the multiplexer acts only as a gate for the input voltages. Inputs are selected using the selection pins on the device, which are controlled using digital binary values that represent the input pin to send through to the output. In the image below, a 4-1 multiplexer takes in 4 inputs, and the 2 selection inputs determine which is passed through. Using the binary encoding, multiplexers with ''n'' selection inputs are able to switch between ''2^n'' inputs, and one must consider that the multiplexer's selection inputs also take up digital output pins from the microcontroller.+A multiplexer acts as a switching circuit that selects one of several inputs to send to the single output. Both analog and digital values can be used as inputs for these devices, as the multiplexer acts only as a gate for the input voltages. Inputs are selected using the selection pins on the device, which are controlled using digital binary values that represent the input pin to send through to the output. In the image below, a 4:1 multiplexer takes in 4 inputs, and the 2 selection inputs determine which is passed through. Using the binary encoding, multiplexers with ''n'' selection inputs are able to switch between ''2^n'' inputs, and one must consider that the multiplexer's selection inputs also take up digital output pins from the microcontroller.
  
 {{:tutorials:multiplexer.png?400|Multiplexer pinout, from https://www.circuitbasics.com/what-is-a-multiplexer/}} {{:tutorials:multiplexer.png?400|Multiplexer pinout, from https://www.circuitbasics.com/what-is-a-multiplexer/}}
Line 14: Line 14:
 The decision of the multiplexing ratio (inputs per output) must be informed by the requirements of the sensor and the limitations of the microcontroller being used. Multiplexing more inputs per pin may expand the number of values that can be read, but can also degrade the sampling rate to a point where the data isn't as useful. The decision of the multiplexing ratio (inputs per output) must be informed by the requirements of the sensor and the limitations of the microcontroller being used. Multiplexing more inputs per pin may expand the number of values that can be read, but can also degrade the sampling rate to a point where the data isn't as useful.
  
-=====  Multiplexer devices  ===== +=====  Device interfacing  ===== 
- +Multiplexer chips are available from common sources such as [[https://www.digikey.ca/|Digikey]] and [[https://www.mouser.ca/|Mouser]] for several configurations of inputs and outputs. Some chips contain multiple multiplexer circuits, which can be useful to perform multiple smaller expansions (eg. 4 instances of 2:1) instead of a single larger expansion (eg. 1 instance of 8:1) to preserve a higher sampling rate. Interfacing a multiplexer to a microcontroller involves synchronizing the selection pin changes with the output readings in software. Many libraries abstract this process away from the developer with libraries or capes ([[https://www.arduino.cc/reference/en/libraries/analog-digital-multiplexers/|Arduino]], [[https://learn.bela.io/products/accessories/multiplexer/|Bela]]). If performed manually, developers should consult the datasheet of the multiplexer to determine the read and write delays of the chip for proper synchronization.
- +
- +
- +
-=====  Summary  ===== +
- +
-This document provided an introduction to basic sensor interfacing circuits, introducing the two major classes of sensor and providing methods of conditioning the signals from the sensors to provide a useful voltage range for analog-to-digital conversion.+