Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Multiplexer Wiring

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    14

    Multiplexer Wiring

    Hi all,

    Would someone be able to confirm this wiring for an analog multiplexer (74HCT4051) circuit with the Teensy 4.0? I would be reading from potentiometers biased at 0 and 3.3V, but powering the multiplexer from 5V.

    Click image for larger version. 

Name:	Screen Shot 2020-11-04 at 7.31.18 PM.jpg 
Views:	24 
Size:	89.9 KB 
ID:	22315

    Thanks so much!

  2. #2
    Member
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    66
    I don't think you want to use a 5 V device on a Teensy 4. I have had very good luck with the Sparkfun Mux boards with my Teensy 4.1. They will run on 3.3 V (Teensy safe) and have 16 analog or digital I/O lines not 8, but you can use 3 address lines and only use the first 8 I/O lines. These boards have room for .01 inch headers, so they are real easy to interface. In my project, I have two of these boards, giving me 32 I/O lines and only using 7 Teensy pins. The address lines and signal are in parallel across the MUXs and each MUX has its own Ena pin on the Teensy. The code below will work on one or two MUXs. You could remove the select MUX part and just have it work on one. I am using the MUXs for digital signals (buttons), but you could also use it for analog by changing the digitalRead() to analogRead(). You would also need to use an analog pin for Sig.

    On my Teensy:
    Pin 41 - EN, MUX 0
    Pin 40 - S3, MUX 0 & 1 (addr line 3)
    Pin 39 - S2, MUX 0 & 1 (addr line 2)
    Pin 38 - S1, MUX 0 & 1 (addr line 1)
    Pin 37 - S0, MUX 0 & 1 (addr line 0)
    Pin 36 - Sig, MUX 0 & 1
    Pin 35 - EN, MUX 1

    Code:
    void GetButton()
    {
      GotBtn = false;
      
      // Select MUX board
      for(MUXidx=0; MUXidx<2; MUXidx++)
      {
        // Set Ena address on Teensy pins
        for(int i = 0; i<2; i++)
        {
          for(int j=0; j<2; j++)
          {
            digitalWrite(MUXEnaPin[j], HIGH);
          }
          digitalWrite(MUXEnaPin[MUXidx], bitRead(MUXidx,i));
        }
    
        delayMicroseconds(250);
        
        for(BTNidx=0; BTNidx<16; BTNidx++)
        {
          // Set Mux address on Teensy pins
          for(int k=0; k<4; k++)
          {
            digitalWrite(MUXPin[k], bitRead(BTNidx,k));
          }
          
          delayMicroseconds(250);
    
          if(digitalRead(MUXIOPin) == LOW)
          {
            Serial.print("Button "); Serial.print(MUXidx); Serial.print(" "); Serial.println(BTNidx);
            ResetScreenSaver();
            GotBtn = true;
            ButtonTime = millis();
            ProcessButtons();
            return;
          }
        }
      }
    }
    https://www.sparkfun.com/products/9056

  3. #3
    Member
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    66
    Update: I looked up the 74HCT4051, and it CAN be used with a 3.3V supply. If you use it, do not power it from 5V, power it from 3.3V. Sparkfun also makes an 8 channel MUX using this chip.

  4. #4
    Junior Member
    Join Date
    Jun 2019
    Posts
    14
    Thanks! I'll plan to change the bias on that 74HCT4051 chip to +3.3V instead of 5V and keep everything else the same.

    Appreciate it.

  5. #5
    Junior Member
    Join Date
    Oct 2020
    Posts
    8
    It should be fine with 5V too. It is Analog switch MUX, so if you don't supply more than 3V3 on mux inputs, MCU should be fine. And TTL input levels are compatible with 3.3V CMOS output levels.

    In fact, HTC series power supply range is between 4.5V to 5.5V. For 3.3V power supply the HC series will be better choice.

  6. #6
    Junior Member
    Join Date
    Jun 2019
    Posts
    14
    OK. That's what I thought I understood from Paul's comment on Teensy midi page.

    For newer Teensy boards with 3.3V signals, 74HCT4051 chips are best. Power the 74HCT4051 from 5V. If 74HC4051 (without the "T") are used, they should be powered by 3.3V when used with a Teensy that has 3.3V signals, or by 5V when used with a Teensy having 5V signals.

    Sounds like ideally the chip is powered from 5V, but I should bias all the pots at 0-3.3V.

    Thanks!

  7. #7
    Member
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    66
    OK, thanks for the information KIIV, I really appreciate it.
    Len

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •