Go Down

Topic: At a loss. What's going wrong with my code/wiring of multiplexing chip? (Read 645 times) previous topic - next topic

May 02, 2012, 07:17 am Last Edit: May 02, 2012, 07:22 am by bradleygriffith Reason: 1
So Im following the diagram here for wiring up a MC14067BCP:
http://fluidforms.eu/docs/MultiplexedArduinoWiringDiagram.pdf

The only difference being that I am doing one set of 16 sensors and not four. Additionally, my sensors are 5k - 250k LDRs (light sensitive resistors) that I have connected to ground on the end opposite of those connected to the connections shown in the diagram above.

When I run my sketch, the serial line shows output that is similar to what would be shown if no wires were connected to my analog in at all. (see the question here to see what I mean by that: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238854387)  This is really stressing me out and it would be amazing if someone could enlighten me as to what is going on.

Here is my code:
Code: [Select]


int CONTROLpin1 = 2;
int CONTROLpin2 = 3;
int CONTROLpin3 = 4;
int CONTROLpin4 = 5;
int analogPin = 0;


// Variables:
int actualSensorValue = 0;             // value from the analog input


void sendCommand(int value) {
 Serial.println(value);
}


void setup() {
 //  set the states of the I/O pins:
 pinMode(CONTROLpin1, OUTPUT);
 pinMode(CONTROLpin2, OUTPUT);
 pinMode(CONTROLpin3, OUTPUT);
 pinMode(CONTROLpin4, OUTPUT);
 pinMode(analogPin, INPUT);

 Serial.begin(9600);
}


void loop() {
 int i;
 int j;
 for (i=0; i <16; i++) {
   
   // set control pins on the multiplexers
   digitalWrite(CONTROLpin1, (i&15)>>3);//bit4
   digitalWrite(CONTROLpin2, (i&7)>>2);//bit3
   digitalWrite(CONTROLpin3, (i&3)>>1);//bit2
   digitalWrite(CONTROLpin4, (i&1)   );//bit1

   // read the analogue inputs and send the values of the sensors.
   
   Serial.println(i); // print which pin we are on
   actualSensorValue = analogRead(analogPin);
   sendCommand(actualSensorValue);
   
   
   delay(1000);
 }
}


Additionally, I have tried cutting it down to the bare minimum and only wiring up a single sensor. When looking at the output, there appears to be no change.
Here is a picture of the bare bones wiring (but to be clear my end goal is still the diagram at the top of this post).


(large version of same image: http://i.imgur.com/IaTD1.jpg)

johnwasser

I don't see anything obviously wrong.  Perhaps a delay(1) just before the analogRead() would help get stable readings.

What is the value of the fixed resistor?  It should probably be 100k or lower.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Grumpy_Mike

Quote
So Im following the diagram here for wiring up a MC14067BCP:

You might be following it but you haven't reproduced it. You have no pull up resistors like it shows in the diagram. So yes it will look the same as if nothing were connected to the analogue input.

Go Up