Go Down

Topic: Erratic behavior when I'm not holding circuit (Read 69 times) previous topic - next topic

soloasch

Dec 20, 2014, 04:56 am Last Edit: Dec 20, 2014, 04:58 am by soloasch Reason: adding picture
Hi guys,

This is my first post! I'm having a problem with my circuit that I can't seem to describe or research, so I figured I'd ask the resident experts:

I'm trying to use a 4051 multiplexer to read 8 different voltages sequentially. I'm using analogRead and potentiometers to accomplish this, but there is also a switch wired with the circuit to allow for zero volts to be read by the Arduino (Nano, but it's got the ATmega328 processor).

The problem I'm having seems to come from the hardware. Basically, if I'm setting my breadboard down on a table or surface, the behavior of the multiplexer is completely erratic, even if I'm only alternating between two LEDs. If I'm holding it with my hands, behavior seems to be normal.

I'm not sure how to even Google this problem, really. As you can see in the picture, I've tried adding some decoupling capacitors but that doesn't seem to help. This seems like a really easy, stupid question. Can anyone point me in the right direction on how to fix this, or what this issue is called?

I've attached a (simplified) picture of the circuit and a pastebin link for the code I'm using. The circuit has some wires removed so you can see it better - I've only wired up one of the mux outputs, and I haven't connected anything to the Arduino. However, I hope that the code clarifies how the circuit is wired - pin A0 is wired to pin 3 of the lower 4051 IC, digital pin 3  is wired to pin 3 of the upper 4051 IC, and digital pins 10-12 are wired to the selector pins of the 4051 ICs.

http://pastebin.com/BJiwQD4F

EDIT: imgur link for picture, it's not letting me attach the picture on the forum
http://i.imgur.com/gXePt85.jpg

Please let me know if there's any way I can clarify this issue, because I'm not completely sure what this issue is! Thanks!

MorganS

It's very difficult to debug a circuit if you take wires out of it and then just tell us you removed some wires. Post a photo with the real wiring. As it is, it looks like there's nothing wrong because the Arduino Nano is only connected to 5v and GND.

Maybe use Fritzing to create the schematic of the breadboard?

TomGeorge

#2
Dec 20, 2014, 09:08 am Last Edit: Dec 20, 2014, 09:11 am by TomGeorge
Hi,

Can you please post a copy of your sketch, using code tags?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
Also a picture of your project, it sounds like you have some gnd referencing problems.

Thanks Tom..... :)
Please attach the files here please and not off on another site.
Your picture is too big to post on forum.
Everything runs on smoke, let the smoke out, it stops running......VK3DMK

Peter_n

#3
Dec 20, 2014, 09:37 am Last Edit: Dec 20, 2014, 09:38 am by Peter_n
Hi, welcome to the forum.
There is something with the wiring on the breadboard, but I like to comment on the sketch as well  ::)
Start by reading Nick Gammon's page about the mux : http://www.gammon.com.au/forum/?id=11976

The sketch
I think the "writeMux" function is okay. It sets all three address bits. The parameter is the channel from 0 to 7.
There is some delay needed to stabilize the analog voltages. It could be 1ms or 50us. Perhaps you can add 20ms delay after setting the mux.

Instead of using the variable 'k', please call it 'channel', since the 4051 datasheet uses the term 'channel' for the inputs.
The SystemLed on an Arduino board uses pin 13, so using pin 13 would be the first choice to add a led  :smiley-kitty:
A pin is often used with the 'const' keyword, it is just to remind the compiler and yourself that it's value is not going to change.
const int potPIN = A0; // analog pin

The wiring
Could you setup a normal circuit with the potentiometer ?
Just a single 4051
The Arduino should set the three address lines. They are not connected to the Arduino at the moment.
The 4051 pin 3 is the common pin, it should be connected to A0 of the Arduino.
The green wire is connected to channel 0 and the slider of the potentiometer, that is okay. But the other pins of the potentiometer should be connected to GND and 5V (one side of potentiometer is connected to resistor which is connected to GND, I don't mind the resistor, the other side is connected to channel 0 of other mux ?).

Magic hands
When you hold it in your hands, your hands can be a shield, and a capacitance, or they could introduce mains noise (50Hz or 60Hz) into a circuit. If something changes, it is most likely a (high impedance) floating input. So you have to check your circuit for that.

Grumpy_Mike

A typical case of floating inputs, that is unconnected inputs picking up signals.
See this for how to stablise matters
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Go Up