Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

74HC4067 Multiplexer with arduino uno

Status
Not open for further replies.

hemnath

Advanced Member level 3
Joined
Jun 24, 2012
Messages
702
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Activity points
6,588
Hi,

I am planning to get data from 16 channel multiplex(74HC4067) input into arduino uno.

I have connected I0 to I15 as +5V, on the serial monitor some of the pin values are showing as 0. Why is it 0 instead of 1?
Code:
// control pins output table in array form
// see truth table on page 2 of TI 74HC4067 data sheet
// connect 74HC4067 S0~S3 to Arduino D7~D4 respectively
// connect 74HC4067 pin 1 to Arduino A0
/*
byte controlPins[] = {B00000000, 
                  B10000000,
                  B01000000,
                  B11000000,
                  B00100000,
                  B10100000,
                  B01100000,
                  B11100000,
                  B00010000,
                  B10010000,
                  B01010000,
                  B11010000,
                  B00110000,
                  B10110000,
                  B01110000,
                  B11110000 }; 
                  */

byte controlPins[] = {B00000000, 
B00010000,
B00100000,
B00110000,
B01000000,
B01010000,
B01100000,
B01110000,
B10000000,
B10010000,
B10100000,
B10110000,
B11000000,
B11010000,
B11100000,
B11110000 }; 
 
// holds incoming values from 74HC4067                  
byte muxValues[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};

int inPin = 8;     // pushbutton connected to digital pin 0
 
void setup()
{
  Serial.begin(9600);
  DDRD = B11111111; // set PORTD (digital 7~0) to outputs
    pinMode(inPin, INPUT);        // sets the digital pin as input
}
 
void setPin(int outputPin)
// function to select pin on 74HC4067
{

  PORTD = controlPins[outputPin];
}
 
void displayData()
// dumps captured data from array to serial monitor
{
  Serial.println();
  Serial.println("Values from multiplexer:");
  Serial.println("========================");
  for (int i = 0; i < 16; i++)
  {
    Serial.print("input I"); 
    Serial.print(i); 
    Serial.print(" = "); 
    Serial.println(muxValues[i]);
  }
  Serial.println("========================");  
}
 
void loop()
{
  for (int i = 0; i < 16; i++)
  {
    setPin(i); // choose an input pin on the 74HC4067
    muxValues[i]=digitalRead(inPin);
    delay(100);
  }
 
  // display captured data
  displayData();
  delay(2000); 
}
 

Hi,

Show us your complete schematic. It may be hand drawn.

Please check: Don´t let any input pin floating. Not analog pins and not digital pins.

What about the "/E" connection of the HC4067.

Code:
Code:
  for (int i = 0; i < 16; i++)
  {
    setPin(i); // choose an input pin on the 74HC4067
    [COLOR="#FF0000"]delay(10);[/COLOR]    
    muxValues[i]=digitalRead(inPin);
    delay(90);
  }
Add the delay beween changing the MUX and performing a conversin for the analog value to settle.
Is the delay value in "milliseconds"?

I recommend to put a capacitor (at least 1nF) to each MUX input with connection to GND. And a 1M Ohms resistor in parallel to it to prevent the input from floating.
(C and R values depend on application)

If you want to connect any external circuitry to the analog inputs then don´t forget ESD protection and EMC filtering.

If you want to process AC signals, then you need anti aliasing filters, too.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top