I have on mind to use an arduino duemillanove board to read multiple sensors which use analog pins. Since this board only have 5 analogs pins, i would like to use a multiplex to do it. I have this one: Multiplexor serial TS3A5017 Sparkfun | BricoGeek.com
I saw the example in the arduino playground section: Arduino Playground - 4051, but since the used is different from that one that i already have i am completely lost.
So, anybody could help me lo know how it runs? Any example?
I really appreciate your help guys! Thanks in advance!
it is nearly the same, but it contains two multiplexers for 4 inputs each.
Connect the analog inputs to the chip pins 1S1, 1S2..1S4 and 2S1, 2S2..2S4.
Connect the pins 1D and 2D of the chip to two analog inputs of the arduino.
Connect the pins 1EN and 2EN of the chip to GND (0V). Connect the pins IN1 and IN2 to two digital outputs of the arduino. The code looks something like this:
// the two analog inputs
#define anain1 1
#define anain2 2
// the two digital outputs
#define digpin1 5
#define digpin2 6
void setup()
{
pinMode(digpin1,OUTPUT);
pinMode(digpin2,OUTPUT);
}
void loop()
{
// these variables hold the 8 analog inputs
int aval1, aval2, aval3, aval4, aval5, aval6, aval7, aval8;
// select channel 1S1 and 2S1
digitalWrite(digpin1,LOW);
digitalWrite(digpin2,LOW);
// make sure the analog input has switched
delay(1);
analogRead(anain1,aval1); // Read 1S1
analogRead(anain2,aval2); // Read 2S1
// select channel 1S2 and 2S2
digitalWrite(digpin1,HIGH);
digitalWrite(digpin2,LOW);
// make sure the analog input has switched
delay(1);
analogRead(anain1,aval3); // Read 1S2
analogRead(anain2,aval4); // Read 2S2
// select channel 1S3 and 2S3
digitalWrite(digpin1,LOW);
digitalWrite(digpin2,HIGH);
// make sure the analog input has switched
delay(1);
analogRead(anain1,aval5); // Read 1S3
analogRead(anain2,aval6); // Read 2S3
// select channel 1S4 and 2S4
digitalWrite(digpin1,HIGH);
digitalWrite(digpin2,HIGH);
// make sure the analog input has switched
delay(1);
analogRead(anain1,aval7); // Read 1S4
analogRead(anain2,aval8); // Read 2S4
// now all inputs are read, process them
....
}
Great help and a clear code too.
The unique different is that my chip don't have 1EN and 2EN pins, but i suppose that they are those called GND and GND in my chip, on the side of 1Sx and 2Sx pins.
I will try it soon and post here the result.
Thanks!
in one side there are 6 connexions: 3V3, 1D, 2D, 1IN, 2IN, GND
In the other side there are 10 connexions: 2S1, 2S2, 2S3, 2S4, GND, 1S1, 1S2, 1S3, 1S4 and GND
So i supposes that those called 1EN and 2EN are those called GND in the plate. In fact they should be connected to GND.... right?
and other question: may be 1D and 2D should be go to the digital pins and the 1IN and 2IN to the analog pins? You said in the opposite way, but i am not sure now...
Look at the datasheet. Pin 1 and pin 15 on the IC are the two enable pins, i cant see which connections on the PCB they go to, just follow the traces. 1N1 and and 1N2 are two pins used to select the switch combinations.