Go Down

Topic: Simple 4051 analog multiplexing circuit not being so simple... Help appreciated (Read 1 time) previous topic - next topic

exoro

I'm trying to build this project.

This project is supposed to cycle through each analog input, output each signal individually to the A0 pin of the Arduino, and then Serial.print the value of each analog input.

I can't seem to get it working after many tweaks and tries.

What happens is that as the code cycles through the analog inputs of the 4051, each input gets an arbitrary number. If I connect a single potentiometer to the 4051 and ONLY check the single input it is on, it works fine. But when I introduce another potentiometer I immediately start having problems again.

I'm using 100k potentiometers if that matters. I'm also using the CD74HC4051E version. In the tutorial, the M74HC4051B1 version is used. I don't believe there is a difference between them, is there?

If there is a difference between the two 4051 chips, how can I change my circuit to allow for it?

Grumpy_Mike

Quote
I'm using 100k potentiometers if that matters.
Yes it matters, use a 10K one.

Quote
If there is a difference between the two 4051 chips,
Not one that will give you problems.

Note all the inputs must be connected to something, do not let them float.

exoro

Before I purchase a set of 10ks, is there any way I can get the 100ks to work?

Grumpy_Mike

You can try reading the same channel twice in a row and only using the second reading.


Grumpy_Mike

Use 10 in parallel.
And watch them burn as the wiper for one is at one end and another wiper is at the other.  :)

Wawa

Before I purchase a set of 10ks, is there any way I can get the 100ks to work?
Use 100n caps from each mux input to ground, one for each pot (no cap at the output of the mux).
When the mux switches to the relevant input, the Arduino sees the low impedance of the cap instead of the high impedance of the pot.
Now you can use any pot value, even >1Megohm.
Reading the analogue input twice (or more), and discarding the first read is always wise.
Maybe also wise to ground any unused mux inputs, and not select them in your code.
Leo..

raschemmel

There's nothing wrong with the circuit. You are connecting something wrong. Draw a schematic of how you are connecting the voltages to the inputs of the 4051.


Post a photo of YOUR circuit, drawn based on your actual circuit. Show you pot connections to the MUX inputs.


Are you aware that the addressing of the mux (S1,S2,S3) is binary and input 1 is 000, input 2 is 001 , input 3 is 011
where "000" = s0=0,s1=0,s2=0
        "001" = s0=1,s1=0, s2 =0
         "011" = s0=1,s1 = 1, s2 = 0

Are you aware of that ?


Quote
Instead of having to read each signal individually, we can send a number, in binary, to the multiplexer over 3 digital pins (3 bit binary number, depending on the high/low state of these three pins), then, the multiplexer will redirect the signals it gets from the potentiometer we want to the common pin, where we can finally read it.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

exoro

I got the 10k pots in the mail today and it still does the exact same thing:(

I've also tried connecting 8 pots to every single mux input. I'm still getting weird numbers.

The last thing I tried was grounding all mux inputs except for mux input y5. When I look at the serial monitor, I'm getting interesting results. y1 and y5 are outputting the same exact value even though y1 is grounded!

Would the 100n capacitor trick still work in this case? Also, would reading the analog pin twice or more help? I tried that by repeating analogRead(0) but it didn't seem to  work.

Wawa

Time to post a picture of YOUR setup, and the code you're using now.
100n caps is not a "trick" but a "must" if you're working with impedances >10k.
Leo..

MarkT

You clearly have noise somewhere, or have a weird power/ground setup.  We can't tell unless
you show us your setup in detail.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

exoro

YES! Got it working. Thank you all for helping out. I appreciate it greatly. The most important problem that I didn't even realize was that there was a row of pins on my breadboard that was completely dead. After I moved the 4051, it started working!

raschemmel

Quote
YES! Got it working. Thank you all for helping out. I appreciate it greatly. The most important problem that I didn't even realize was that there was a row of pins on my breadboard that was completely dead. After I moved the 4051, it started working!   
Depending on which breadboard type you purchase, some of them have TWO sections on the same side, which MOST people jumper together (one jumper for blue, one jumper for red).
Evidently, you have one of those breadboards. the smaller ones have continutiy all the way across.
This falls under the category "Learning how to use a breadboard".
There is nothing wrong with your breadboard. You just don't have the jumpers installed, like everyone else does.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

exoro

It's not even that surprisingly. I have a breadboard similar to the one above, but twice the length. The row (or I guess column depending on how you're looking at it) doesn't complete a circuit almost like there's no metal below. Then again, I did by the breadboard for next to nothing on Aliexpress.


raschemmel

You can remove the paper underneath and look at it so see if the metal clips are missing in that row.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up