Go Down

Topic: programing and wiring 2 Multiplexer / demultiplexer with arduino (Read 8280 times) previous topic - next topic

angoo

hello I am very pleased to participate in this community!
I recently developed an autonomous airship project. For this project I wish to receive information from 30 sensors and send commands to actuators 18.
I have a Arduino mini pro 328  three multi / demultiplexers 74HC4067  buy from Sparkfun
I learn about their installation and programming but I do not see:
1) how the physical cable to the card (ie if the 2 multiplexer and demultiplexer are on the same digital inputs?)
2) how to manage these two groups in programming

thank you to you!
to help me in this project

Grumpy_Mike

You cannot use a 74HC4067 to multiplex outputs. Well you can but only one output can be active at any one time and all the rest of the outputs will be high impedance. You are not the first to be caught out about this but there is a lot of wrong information about.
To get multiple outputs you need to use either a shift register, port expander (like the 23S17), or something with a latch.
For examples of these see my projects:-
http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html - uses port expander
http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html - uses latched multoplexer

CrossRoads

To control these, you connect 4 arduino outputs to the S0-S1-S2-S3 pins, that will select which I/O path thru the device will be connected.
Then you will have 4 more arduino outputs that will function as chip selects. You will write out S0-S3, then enable one device at a time.

Connect the common I/O pin (pin 1) for the 2 sensor selector parts together and connect to your digital input pin.
The combination of S0-S3 and the 2 enable pins will select which of the 32 outputs will appear at your digital input pin.

Connect the common I/O pin for the 2 actuator selector parts together and connector to your digital output pin.
The combination of S0-S3 and the 2 enable pins will select which of the 32 outputs will follow the actions of the digital output pin.
Be aware that when no outputs are selected, the pins will not be Hi or Lo, you will need a  pullup or pulldown resistor to put the actuator in its Off state.

If you want to use just 1 arduino pin to both read the sensors and drive the actuators, that is possible also.
Connect the common I/O pin from all devices to the arduino.
Your code will have to change the mode of the pin as you use it:
for reading, pinMode(ioPin, INPUT);
set S0-S3, enable one of the sensor input parts
then read the signal

for writing, pinMode(ioPin, OUTPUT);
set S0-S3, enable one of actuator output parts
then write your actuator signal  hi/lo, or lo/hi, as needed.

Does that make sense?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

angoo

great!
thanks Grumpy_Mikegood projets...

CrossRoads
yes that make sense to me!
2 solutions . can you make a drawing of them ?
because y dont read english very well and y dont want too make mistake
y dont need 32 actuator only 18 that s why y try to use only one demultiplexer

y  try to use   tree     74 hc 6067 bread bord



thanks a lot and have a caribeean sun










CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Grumpy_Mike

This is the way to do it with latched outputs, so that once you have set an output to a level it stops at that level.
Note this was drawn for an old computer, the reference to a "User Port" is what you would call an arduino pin. Note you can use any arduino pins but avoid pins 0 and 1 as they are for the serial comms.

angoo

hello
my loggin name is angoo
and y am talking with you  in the forum about multiplexing/demultiplexing
i m work on it
but i dont know how to post image and code
there is some information on the old forum but i dont find in this one
thanks for help!

Grumpy_Mike

Just sent you a PM but for others.
For code click the # icon above the reply box and paste the code between the brackets that pop up.
For a picture click the Additional Operations... below the box and brows for your picture.

angoo

thank
Grumpy
for the explication

the code downside it made by  SHYWODD
on the french forum




Code: [Select]
/*
S0 -> digital 7
S1 -> digital 8
S2 -> digital 9
S3 -> digital 10
Z -> analog 0

E -> 0v
gnd -> 0v
vcc -> 5v
*/

void setup(){
Serial.begin(9600);
pinMode(7,OUPUT);
pinMode(8,OUPUT);
pinMode(9,OUPUT);
pinMode(10,OUPUT);
}

void loop(){
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y0
Serial.println(analogRead(A0));

digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y1
Serial.println(analogRead(A0));

digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y2
Serial.println(analogRead(A0));

digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y3
Serial.println(analogRead(A0));
// etc .....
}





angoo

it s ok for the code part but not for picture !
what i do
click on insert image
it give me brows like that/img / /img/ (/ are for explication)
clik on additional options
there is attach
i make "parcourir" and find my picture
for example :  C:\Users\tauliaut\Desktop\demux-demo.jpg
i paste it on the /img]C:\Users\tauliaut\Desktop\demux-demo.jpg[/img/

i make prewiew
it wrong!

CrossRoads

I don't believe you  can use
[ img ] link to your desktop [ /img ]
for images on your computer. You need to use the Reply and Additional Options to attach pictures that will then upload as part of your post.

This is used to link to images you have uploaded to the internet somewheree
[ img ] http://www.link to flickr.com/your_picture.jpg [ /img], that knd of link.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Grumpy_Mike

OK angoo I see your picture and your code now what is your question?

angoo

i started from the CROSSROAD picture
and make a one that s close off my mind

2 multiplexer and one demultiplexer
do you thing it s  good?
thank a lot

Graynomad

You do realize that you can't use 4067s for outputs unless you only need one output on at a time, it's been stated a couple of times but I'm not sure you've pick up on it.

BTW, your picture links to your C drive, that ain't gonna work :)
______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Grumpy_Mike

#14
May 19, 2011, 08:28 am Last Edit: May 19, 2011, 08:30 am by Grumpy_Mike Reason: 1
The select inputs to the first level of multiplexers are not going anywhere, so there will be no way to control them. Unless that is they are joined to the others. When drawing a schematic you should not have lines that cross and join together unless you put a dot on the intersection.

You also need supply decoupling as well.

Go Up