MUX 8 Channel Analog Multiplexer 74HC4051 Purple

74HC4051
ID: #99189007 In stock, 5pcs
14.00 AED
Description:

CJMCU-74HC4051, 74HCT4051 is a single-pole octal-throw analog switch (SP8T) suitable for
Use in analog or digital 8: 1 multiplexer/demultiplexer applications. The switch features
Three digital select inputs (S0, S1, and S2), eight independent inputs/outputs (Yn), a
Common input/output (Z) and a digital enable input (E). When E is HIGH, the switches are OFF
Inputs include terminal diodes. This allows the use of current-limiting resistors
Interface inputs to keep voltages in excess from VCC.



Multiplexing:

is choosing from one of the various lines (one at a time) and forwards its contents down a single line.

Example:



In this case, by setting the A/B/C lines to have 2 (in binary), that is 010, then line 02 (pin 15) is chosen to be the "active" line, and whatever voltage is on it is forwarded to the "common" in/outline (pin 3).

Note: A is the low-order bit. So therefore if you set A and B high, and C low, you would activate channel 3, not channel 6.


Demultiplexing



Demultiplexing is doing the reverse operation. A single input line is forwarded to one of many output lines.

Example:



In this case, by setting the A/B/C lines to have 7 (in binary), that is 111, then line 07 (pin 4) is chosen to be the "active" line, and whatever voltage is on the "common" in/outline (pin 3) is forwarded to it.


How does it know which direction to go?



The device is bi-directional. If you have a signal on one end of the pair (the selected line, and the common line) then that signal is echoed on the other end.

Effectively the selected channel has around an 80-ohm resistance (between the selected pin and the common pin) achieved by side-by-side MOSFETs (one P-channel and one N-channel). The unselected channels have a very high resistance between them and the common pin.

So you could use it, for example, to connect up 8 analog inputs, and connect them up to a single analog port on your microprocessor (eg. your Arduino). The Arduino does not generate analog outputs (the so-called analogWrite function actually does digital pulse-width modulation or PWM) so the device isn't quite as useful as an output device.

However, you could conceivably connect up LEDs to some of the pins and flash them from time to time, interleaving with taking analog readings.


example Code with wiring for MUX 16 Channel Analog Multiplexer 74HC4051 Purple

CD4051BE CMOS Analog Multiplexers/Demultiplexers with Logic Level Conversion (Analog Input)


/************************************************************************
Mux_Analog_Input
Multiplexer Analog Input Example
Hardware Hookup:
Mux Breakout ----------- Arduino
     S0 ------------------- 2
     S1 ------------------- 3
     S2 ------------------- 4
     Z -------------------- A0
    VCC ------------------- 5V
    GND ------------------- GND
    (VEE should be connected to GND)

The multiplexers independent I/O (Y0-Y7) can each be wired
up to a potentiometer or any other analog signal-producing
component.
******************************************************************************/
/////////////////////
// Pin Definitions //
/////////////////////
const int selectPins[3] = {2, 3, 4}; // S0~2, S1~3, S2~4
const int zInput = A0; // Connect common (Z) to A0 (analog input)

void setup() 
{
  Serial.begin(9600); // Initialize the serial port
  // Set up the select pins as outputs:
  for (int i=0; i<3; i++)
  {
    pinMode(selectPins[i], OUTPUT);
    digitalWrite(selectPins[i], HIGH);
  }
  
  // Print the header:
  Serial.println("Y0\tY1\tY2\tY3\tY4\tY5\tY6\tY7");
  Serial.println("---\t---\t---\t---\t---\t---\t---\t---");
}

void loop() 
{
  // Loop through all eight pins.
  for (byte pin=0; pin<=7; pin++)
  {
      for (int i=0; i<3; i++) {
          digitalWrite(selectPins[i], pin & (1<<i)?HIGH:LOW);
      }
      int inputValue = analogRead(zInput);
      Serial.print(String(inputValue) + "\t");
  }
  Serial.println();
  delay(100);
}