Pages: [1]   Go Down
Author Topic: where do I order the "4051"? + other demuxers?  (Read 1145 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

help?
everyone talks about these 4051 multiplexers. I tried to order them on mouser but got the wrong ones (there are many seemingly applicable results when searching "4051 multiplexer").
also,
does anyone know if it is possible to use other multiplexers? I have been attempting to accomplish this with a 16 channel multiplexer from texas instruments. I am running into this problem:
inputs 1-4 work fine, however input 4-16 read the same regardless of the actual input on 5-16. I am using 10k pots and the following bit of arduino code:

byte data_in = 0;
byte data_send = 0;


int anPin = 0;


byte setPort = 0;


void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
}


void loop() {
if(Serial.available() > 0) {
data_in = Serial.read();
if(data_in == 76) {
for(int i = 0; i <= 7; i ++)
{
setPort = i * 4;
PORTD = setPort;
data_send = analogRead(anPin) / 4;
Serial.print(data_send);
}
Serial.flush();
}
}
}  

this arduino code is used in conjunction with a max patch that looks like this madzach[dot]com/oldmuxing.png

please help!
thanks
Zach
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It depends where in the world you are for ordering stuff, you don't say where you are.

You haven't posted a schematic so it is difficult to tell you what to do but basically there is something wrong with the code to switch the multiplexer so you will keep reading the same values from it. The code will also clobber the serial data lines screwing up the communications.
« Last Edit: October 05, 2009, 05:17:41 pm by Grumpy_Mike » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am located in Santa Cruz, California (I had ordered on mouser). Here's a link to the schematic for the 16 ch multiplexer http://www.madzach.com/ti16chanalogmultiplexer.pdf
How should I change my arduino code to work with this multiplexer?

thank you,
Zach
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry it says the file is damaged and can't be displayed. Can you try and post it on the reply page?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here's the datasheet again for the 16 ch analog multiplexer from Texas Instruments...

http://www.madzach.com/ti16chanalogmultiplexer.pdf
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I meant actually how you were wiring it up. Make sure you also have a decoupling capacitor across the supply of the chip. Pin 15 to ground.
Also please post code between the brackets that pop up with the hash icon in the reply box.

Try this:-
Code:
byte data_in = 0;
int data_send = 0;
int anPin = 0;
byte setPort = 0;

void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
}


void loop() {
if(Serial.available() > 0) {
data_in = Serial.read();
if(data_in == 76) {
for(int i = 0; i <= 0x3C; i +=4)
{
PORTD = i | (PIND & 0x03);
delay(2); // You can try and remove this once it is going but it allows it to settle
data_send = analogRead(anPin);
Serial.print(data_send, DEC);
}
}
}
}  
So make data_sent an int, make the loop count as you want the output bit pattern to be. Set the port by masking out the bits other than the serial I/O bits and ORing the result then output direct to the port.

Try that.
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since you're near Silicon Valley,  there are lots of surplus places nearby,  some of which do mail order.  A couple of the ones where I was a regular in my San Jose days appear to have gone to the Great Parts Yard in the Sky,  but I believe a few remain.

One of my favorites is Alltronics.  Unfortunately,  Dennis closed up his amazing storefront operation a few years back,  and is now exclusively doing mail order from Morgan Hill.  But Halted is probably still selling its assortment of the weird and wonderful in Sunnyvale,  as well as doing mail-order at prices not as exciting as you get in person.

It appears that JDR has closed its storefront,  too.  And added a nasty $50 minimum order policy.  Ah,  well:  they've largely switched over to the PC parts business,  anyway...

Here is some additional info on Silicon valley sources.  Alas,  I heard from a friend that Triangle Tool (a wonderful source of mechanical stuff) has also gone bye-bye,  and ACE's website says they've moved from the address listed there,  so double-check any info on that page before making any travel plans.

Ran
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what kind/specification decoupling capacitor is appropriate?

thank you,
Zach
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what kind/specification decoupling capacitor is appropriate?

0.1uF ceramic.

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
unfortunately the code you posted renders a confusing and seemingly un-usable stream of numbers on all the pots. the wiring notes you made were very helpful, I have hooked up the capacitor and also pin 15 to ground. Does it matter what voltage capacitor? the one I am using is .1uF 100v multilayer ceramic. When I use my old arduino code with the new wiring, pots 1-7 work perfectly, but they seem to control directly the readings of pots 8-16 (i.e. whatever pot 1 reads is the same as the reading for pot 9 but pot 9 doesn't do anything.) I feel closer, but am still far from successful at getting this to work. Any ideas?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

to be specific, I hooked the capacitor to buffer the 5v power to the multiplexer
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does it matter what voltage capacitor?
Yes, but "too high" is only a problem if the higher voltage rating makes the capacitor too big to fit on the board (e.g.,  a 50V electrolytic will usually be significantly larger than a 15V one of the same capacitance.  If the parts are closely spaced,  there might not be room for the 50V one).  It's "too low" that gets you into trouble.  Especially with big electrolytics:  if you whack a 15V cap with a 50V spike,  it could short out,  or even explode.

To avoid surprises,  I usually go for caps with a voltage rating double or more the normal range in the circuit.  But keep in mind that I'm mostly a software guy,  and it's rare for anything I design to get built in quantities of more than about 5.  For high-volume production,  I let the hardware specialists figure out where and how to save the pennies by deciding what the real "safe minimums" are.

Ran
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

okay, got it working.. used the original arduino code but changed the i <== 7 to 15. Also followed your advice on the wiring and de-coupling. thanks so much I really appreciate the help!

--> Zach
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
unfortunately the code you posted renders a confusing and seemingly un-usable stream of numbers on all the pots

ok so time for some fault finding.
First off remove the PORTD assignment (comment it out). It should then just read the same input 16 times. If you add lines to set all the outputs to zero ( digitalWrite(2, LOW);  and so on for all the multiplexer addresses), then you should read channel zero. If this is not a steady stream of the same number then I suspect there is something wrong with the hardware.
Check the wiring, it sounds like you originally had not got A2 connected to the multiplexer.

You may have disturbed other things, that fault sounds like there is no connection through to the analogue input of the chip, or the chip is not enabled.

EDIT Cross posted there. Glad you have it working but you are still clobbering the serial input to the chip with the way you are writing out to the address to the multiplexer. That is causing all sorts of rubbish to be entered into the serial buffer and is why you need the serial flush command. Best fix it.
« Last Edit: October 07, 2009, 02:44:02 am by Grumpy_Mike » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am unsure of how to do that, where in the code does it write the address of the multiplexer?
Logged

Pages: [1]   Go Up
Jump to: