Go Down

Topic: [Resolved] Resistance problem affecting pin reads (Read 801 times) previous topic - next topic

tachyonimpact

Mar 29, 2011, 05:53 am Last Edit: Mar 29, 2011, 08:23 am by tachyonimpact Reason: 1
My USB Duemilanove-328 is about 2 years old. I haven't done much with it.

I pulled it out a couple days ago to play around with, and I noticed what I first thought were bugs in my software, but after some testing, I discovered that there was a hardware problem.

Polling a random pin several times per millisecond, I find that the pin state is fluctuating rapidly. The pin state strobes between high and low, whether the pin is connected to anything or not. This problem seems to be occurring on all pins on my Arduino. However, I find that by touching certain metal parts of the circuit board with my finger, I can stabilize the reads and get the correct input. This leads me to believe that there is a resistance imbalance somewhere on the board.

Is this a common problem? Is there anything I can do about it, or do I need to replace the board?

Coding Badly

Focus on the pins that are connected to something.  What are they connected to?  How do they behave?

tachyonimpact

The connected pins are connected to push switches. When not pushed, the poll on pin 2 gives about 50% "HIGH" readings. When pushed, the poll gives 100% "HIGH" readings, as expected.

Pin 3, however, always gives 100% "HIGH" readings.

Everything is connected through a breadboard.

If I touch the groundwire while polling pin 2, I will get 100% "LOW" readings, as expected. This persists as long as I am touching the groundwire. However, if I tap and release the pushbutton while holding the groundwire, I will get 100% "HIGH" readings from then on, until I let go of the groundwire for a moment.

The Arduino seems to be remembering the ground resistance. This doesn't make any sense.

Perhaps I made a mistake in the past and shorted something.

Coding Badly

What value are you using for the pull-down resistors?

CrossRoads

Sounds like floating inputs.

Enable the internal pullups:

pinMode(pinX, OUTPUT);
digitalWrite (pinX, HIGH);

then use your switch to connect to ground, and look for Lows to initiate your action.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

tachyonimpact

HA
HAHAHA
HAHA
HA

Ok. I'm not an electrical engineer or anything. I mostly just tinker around with this thing for fun. Now I feel stupid, because I was not using any resistors on the groundwire connection. What value is best? I have many resistors of various values on hand, so I'll put one in the circuit and see if it solves my problem.

CrossRoads

1K.
Or use the internal pullups - do you still have your sketch that is running?
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

tachyonimpact

#7
Mar 29, 2011, 07:31 am Last Edit: Mar 29, 2011, 07:43 am by tachyonimpact Reason: 1
Enabling the internal pullups on pins 2 and 3 (set to input) just gave them a permanently HIGH input reading, even when the switches are not closed.

The sketch is the BitLash Arduino shell. I am using its internal functions to set pinmodes and read/write on the pins.

Edit: Also, a 1k resistor connected between ground and the circuit had no effect.
Edit2: Touching the 1k resistor while it is connected to ground seems to fix it. I'll try with a 10k.
Edit3: Nope, even a 15k didn't change anything.

Coding Badly

Quote
Now I feel stupid,


Why?  No one is born with a knowledge of "floating pins".

Enabling the internal pullups on pins 2 and 3 (set to input) just gave them a permanently HIGH input reading, even when the switches are not closed.


Did you change the switch to ground the pin when closed?  For pull-up resistors, the switch is connected to GND.  For pull-down resistors, the switch is connected to VCC.

Quote
Edit2: Touching the 1k resistor while it is connected to ground seems to fix it. I'll try with a 10k.


Your circuit is not correct.  You still have a "floating pin".

Does this help...
http://www.arduino.cc/en/Tutorial/button

tachyonimpact

Thanks! I was just doing it wrong. The inputs are fine now.

Go Up