Capacitance in buttons?

I have a project that involves a few panel mount buttons connected to a board which has a Nano plugged into it. Once in awhile, it won't respond to one of the buttons. I put the leads of my multimeter while in continuity mode on the housing of the button wires while it was plugged into the board. When I pressed the button it worked, and continued to work after that. Pulling the Nano and plugging it back in also works when this happens.

Someone suggested that the button has a small amount of capacitance of its own, and was retaining enough charge to hold it HIGH. It's an OFF-(ON) button, and pressing it usually takes the pin from 1 to 0. Putting the multimeter on it let it discharge. Is this a common problem, and how can I design the circuit to prevent it?

That sounds very implausible to me. When the switch is closed then all the important bits should be connected to GND.

But ... it's impossible to say anything without knowing how your switch is wired. My crystal ball is at the cleaners today.

No, there is no capacitance in buttons.
How are they connected to the Nano ? With external pullup resistors ?
Or do you use the internal pullup resistors ?

It's with an internal pullup. One pin is on GND, the other on a digital pin. It's this button - http://www.aliexpress.com/snapshot/6009235380.html.

This is part of a kit, so I've been testing 100+ nanos by plugging them in to the board and running through the functions. Putting the multimeter on the crimps in the housing makes the button jump to life, or just re-seating the Nano. I haven't tried just using a bit of wire to short the crimps, I'll give that a try next time I encounter it. I would like to prevent the problem, rather than give the workaround of reseating the Nano whenever a user contacts me about a button not working.

That sounds more like a connection problem. If the buttons close when pressed, they'd go low regardless of any parasitic capacitance.

What if you just put one multimeter lead on a crimp? Does it go away then, too? Or better, poke it with something non-conductive.

You might have 10 or 20pF in the wiring. Not an issue.

Reading on the internal pullups, I saw this-

Prior to Arduino 1.0.1, it was possible to configure the internal pull-ups in the following manner:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

Does this mean that digitalWrite(pin, HIGH); no longer enables the pullup resistor? If that's the case then I'm not using using pullups after all, and I need to switch those to pinMode(pin, INPUT_PULLUP);

IanJohnson:
Reading on the internal pullups, I saw this-

Prior to Arduino 1.0.1, it was possible to configure the internal pull-ups in the following manner:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

Does this mean that digitalWrite(pin, HIGH); no longer enables the pullup resistor? If that's the case then I'm not using using pullups after all, and I need to switch those to pinMode(pin, INPUT_PULLUP);

It will still enable the pullup. "pinMode(pin, INPUT_PULLUP);" Is just a new way to do it with one function instead of two.

It does sound like floating pins though. Next time don't use continuity, measure the voltage at the (supposedly-pulled-up) pin.

Even better, go and measure the voltage on the pins right now. Make sure they're all pulled up to 5V.

(Assuming you're just using pullups and the switch goes to ground, which you're still not saying...)

It's with an internal pullup. One pin is on GND, the other on a digital pin.

Did you mean something different? One terminal of the button connects to the ground plane, the other one directly to a digital pin. There is a digitalWrite(pin, HIGH); for each of the pins that has a button. It's a SPST momentary "Push for On" button.

Hi, personally, I use external pull up or pull down resistors, gives you a contact on the project to check input state with a DMM.

fungus is asking you with your project the way it is, measure with your DMM in DCVolts the voltage from grn to the input pin you are switching.
Two readings, one with button OFF, one with button ON.

Can you post a pic of your project please?

Tom.... :slight_smile:

And you are sure you have no floating pins and a common ground?

You may be picking up signals on the wires between Nano and front panel.

I'd suggest using 1k or 2k2 pull-up resistors and don't rely on the internal pullups when
connecting to switches at the end of long cables - the internal pullups are high
impedance and no match for EMI.

Also the use of shielded cables is normal for situations like this, or twisted pair
with ground for every signal.

When you connect the multimeter to the button you momentarily pull
the signal line low as the multimeter cables charge up - this effect is only a few
nanoseconds though.

With the multimeter attached you have connected a big loop of wire to the circuit
which can act as an antenna and pick up all sorts of noise, so don't be phased by
mis-behaviour while the meter is connected.

If you have high-current or mains wiring route it away from all sensor and switch
cabling to reduce EMI pickup in the sensitive circuitry.

MarkT:
You may be picking up signals on the wires between Nano and front panel.

If the front panel is a big piece of metal then this is a possibility. Solution: Ground it.

No, not necessarily from the panel, from other wiring in the enclosure.

The type of push-button you have is "push-to-break" or "normally closed" type. This type relies on your circuit to do the switching to a logic high and the contacts to switch to logic low. Since the overall circuit relies on a weak pullup resistor in combination with capacitance in wiring, leakage between solder connections, solder resin between contacts, PCB leakage on more than one circuit board, etc, then as Mark suggested, I would use a strong pull-up resistor to get faster/sharper rise time and proper logic level. Since you only have one button periodically acting up ... double check for cold solder and resin between pins.

Other things to consider....

If one contact of the pushbutton is connected to power, then when its depressed, there will be poor fall-time without contact bounce. When its released, there will be a fast rise-time with contact bounce.

If one contact of the pushbutton is connected to ground, then when its depressed, there will be poor rise-time without contact bounce. When its released, there will be a fast fall-time with contact bounce.

If you're using software debounce, most examples work with rising contact bounce by delaying then re-reading the input status to determine if its stable. Software debounce may require some modification to work with the case above where one contact of the pushbutton is connected to power. Also, this case would require the user to hold the push-button until the debounce time-out expires plus the time it tales for the loop to check its status.

From past experience, I've found normally closed type push buttons more difficult to work with than normally open or "push-to-make" type which are much more common.

Well, that's an over analysis of something that should be simple! -dlloyd

Just looked at reply#3 ... another thing to consider:
The type of pushbutton shown is rated 3A,125VAC. This type would probably not have suitable contact flashing for low-level DC switching. I suspect there is (randomly) not enough voltage or electrical energy level required to break through the contact oxidation (been there - done that). Also note that the mechanical energy required is coming from the spring (which might be weak) and not your finger ... another reason to go "normally open" type if possible.
*** Check the detailed spec sheet from the manufacturer for low level DC characteristics, if available.

If you're using software debounce, most examples work with rising contact bounce by delaying then re-reading the input status to determine if its stable.

One of my pet peeves... if you look at the Debounce example, it does it the right way, by checking the switch multiple times to see if it stays down.

But a lot of books on Arduino do this by just using delay() to "debounce". Flawed, at best. All it tells you is that another button press was received after the delay. So a noisy circuit could trigger a false button press.

But a lot of books on Arduino do this by just using delay() to "debounce". Flawed, at best. All it tells you is that another button press was received after the delay. So a noisy circuit could trigger a false button press.

Yes...my pet peeve too.
Hardware debouncing (as in the SAM3X) can sure simplify things. When extreme software debouncing is required (dual-edge and random noise tolerance), I use something like this which emulates 4 flip-flops + one 4-input AND gate and one 4-input NOR gate:

  if ((millis()-StartTime) > (DurationTime/4)){                            // check elapsed duration
  fd4=fd3; fd3=fd2; fd2=fd1; fd1=digitalRead(fdin);                        // shift status then read
  if (( fd1 && fd2 && fd3 && fd4) == HIGH) { digitalWrite(fdout, HIGH); }  // stable when HIGH
  if (( fd1 && fd2 && fd3 && fd4) == LOW) { digitalWrite(fdout, LOW); }    // stable when LOW
  StartTime = millis();                                                    // update start time
  }

However, for IanJohnson 's issue, I strongly suspect that replacing the push-button with a more suitable type would solve the problem. Most 120VAC high current types are not specified to work at or below around 12 VDC ... need to check specifications for minimum DC voltage and current rating.

Most 120VAC high current types are not specified to work at or below around 12 VDC ... need to check specifications for minimum DC voltage and current rating.

That bears repeating. A 10A switch may cause problems with high contact resistance used in a low current circuit like that of an Arduino using the internal pullup.

polymorph:
That bears repeating. A 10A switch may cause problems with high contact resistance used in a low current circuit like that of an Arduino using the internal pullup.

True, but it doesn't explain why it would work most of the time with intermittent failure. Failure being fixed by applying a multimeter.

The wires from the control box to the board at 18" long, so that might be an issue, though the control box is printed plastic rather than metal. The switches aren't ideal but the price was good. Everything else seems to be twice as much. The project is this filament winder- FilaWinder by ianjohnson - Thingiverse

I'm thinking of changing the box with panel mounted buttons to a PCB. Tactile switches would replace the pushbuttons, and a slide switch to replace one of the rockers. I still need to figure out what to do about the other rocker switch, which is the power switch. I'd like to slim down the control box and keep everything PCB mounted, but the power switch needs to support 1A 12v. It would also simplify the wiring since everything could be combined into a ribbon cable and single connection at both ends.