6 MC14067B's and a new guy :)

Hey guys, looks look i'm the only one not messing with LED matrices in here. Anyway, I'm new like I said and I'm trying to get 6 multiplexers to cycle through 96 analog signals (pots). Right now I'm just trying to get 2 working. I think I'm close, maybe. I took this http://bildr.org/2011/02/cd74hc4067-arduino/ guys code and changed it a little:

//Mux control pins
int s0 = 40;
int s1 = 41;
int s2 = 42;
int s3 = 43;
int s4 = 34;
int s5 = 35;
int s6 = 36;
int s7 = 37;


//Mux in "SIG" pins
int SIG_pin1 = 0;
int SIG_pin2 = 1;

void setup(){
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT); 
  
  pinMode(s4, OUTPUT);
  pinMode(s5, OUTPUT);
  pinMode(s6, OUTPUT);
  pinMode(s7, OUTPUT); 

  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);

  digitalWrite(s4, LOW);
  digitalWrite(s5, LOW);
  digitalWrite(s6, LOW);
  digitalWrite(s7, LOW);

  Serial.begin(9600);
}

void loop(){

  //Loop through and read all 16 values
  //Reports back Value at channel 6 is: 346
  for(int i = 0; i < 16; i ++){
    Serial.print("Value at channel ");
    Serial.print(i);
    Serial.print("is : ");
    Serial.println(readMux1(i));
    delay(500);
  }

}

int readMux1(int channel1){
  int controlPin1[] = {s0, s1, s2, s3};

  int muxChannel1[16][4]={
    {0,0,0,0}, //channel 2
    {1,0,0,0}, //channel 3
    {0,1,0,0}, //channel 4
    {1,1,0,0}, //channel 5
    {0,0,1,0}, //channel x
    {1,0,1,0}, //channel c
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin1[i], muxChannel1[channel1][i]);
  }

  //read the value at the SIG pin
  int val = analogRead(SIG_pin1);
  
  //Loop through and read all 16 values
  //Reports back Value at channel 6 is: 346
  for(int i = 0; i < 16; i ++){
    Serial.print("Value at channel ");
    Serial.print(i);
    Serial.print("is : ");
    Serial.println(readMux2(i));
    delay(500);
  }

}

int readMux2(int channel2){
  int controlPin2[] = {s4, s5, s6, s7};

  int muxChannel2[16][4]={
    {0,0,0,0}, //channel 2
    {1,0,0,0}, //channel 3
    {0,1,0,0}, //channel 4
    {1,1,0,0}, //channel 5
    {0,0,1,0}, //channel x
    {1,0,1,0}, //channel c
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin2[i], muxChannel2[channel2][i]);
  }

  //read the value at the SIG pin
  int val = analogRead(SIG_pin2);

  //return the value
  return val;
}

I am assuming there is a problem because when I look at the monitor it isn't scrolling through all 32 channels.

I appreciate any help as always.

thanks

tony

Here's what I'd do -

Do you have access to a multimeter or an oscilloscope? If not, you can make a probe with an LED & resistor to check the high/low status of your control lines. (And, you should get yourself a meter.)

Once you are able to read data-lines, I'd make the program stop* (or maybe pause 'till you hit a switch) so that you can read the address/control lines into the multiplexers. You can also loop while you are "pausing" to monitor the A/D readings.

  • You probably don't want to "stop" the program, but you can put it into a "do nothing" loop.

Ok, so I would just be manually checking to see if the control lines are corresponding to the correct signal/input channels? (0,0,0,0) is channel 1, (1,1,1,1) is channel 15 etc.?

I'll give it a try, thanks.