Progress with the switch debouncer

October 12, 2012 12:34:14 AM CDT

Happy news - I've built and tested a working version of the switch debouncer:

(if you're using a browser that doesn't support the HTML5 'video' tag (or your version of Firefox hates you as much as mine hates me), here's a link to the movie)

There are still a few things that need to be tweaked, but this one is just about ready for publication.

This is actually the second version of the circuit I've built. The first one didn't even come close to working, for reasons that ended up being beyond strange.

Bizarre problems:

The chip is a 74HC14 hex Schmitt inverter, one of my favorite digital building blocks. Like all CMOS chips, it has extremely high input impedance.. well above the 30 megohm limit of my multimeter. That's good because it means I can use resistors in the 1-10 megohm range to drive the input. The first version of the circuit used nothing but 10 meg resistors.

When I got the finished circuit on the bench for testing, I was surprised to see that one pair of inverters (the ones that control the green LED above) was doing what BEAM robotics folks call 'saturation': they were toggling between states as fast as they could (about 25 MHz) as if the input and output of an inverter were shorted together.

To make matters worse, the other two switches didn't do anything at all.

Actually, that's not quite true.. pushing the switch for the red LED would make the red and yellow LEDs flash alternately for three beats, then stop. Pushing the button for the green LED would cause all three LEDs to flash, and pushing the button for the yellow LED didn't do anything.

Hooking the circuit up to the oscilloscope just gave more apparent nonsense. The input pins for the inverters in saturation were sitting at a steady voltage halfway between Vcc and GND. Schmitt triggers are specifically designed to ignore signals that sit at a steady voltage -- especially halfway between the rails -- so the input that theoretically shouldn't do anything was doing the exact opposite of what it should.

Worse yet, I was seeing a voltage drop across the resistors that feed into one side of the switches, and the capacitors on the other side of the switch weren't charging the way they should.

After much head scratching and testing every voltage I could think of, I started removing components on the assumption that something was fried.

The light comes on (where it shouldn't):

The first, cheapest, and easiest parts to remove were the switches. If one of those was shorting somehow, it could potentially cause odd input to the chip. Even if they were good, removing them meant there would be no connection between the pads that were apparently shorting together, and the electrical properties of "no connection" are well understood.

.. or so I thought.

After removing the first switch, I tested the board again (it was still wonky), and checked the voltages at all the pads where the switch had been. One of those pads was unconnected to anything (that oval blob in the upper left):

that one in the 
upper left

You can imagine my surprise when I saw .3v between that pad and GND.

Hooking up my ohmmeter confirmed that there was about 5 megohms of resistance between that not-connected-to-anything pad and the one just below it.

As a sanity check, I tested my meter on a sheet of paper, which did indeed have engineer's-infinite resistance (the engineering definition of infinity is "any number large enough that, if it were larger, I wouldn't have to care"). Then I ran a few 1% resistors through it to check the calibration (which was good enough).

Going back to the PCB, I put one probe on the mysteriously-connected pad and the other in the middle of the non-copper space between the pads.

Between 3 and 4 megohms.

Further poking around on the board showed that the parts that didn't have copper still had very faint electrical connections between them.. usually in the high-megohm range, but occasionally dipping down as low as a few hundred kilohms.

That certainly explained the unusual behavior of the switches and the chip. Now I just needed an explanation for the less-than-infinite resistance.

I cleaned the board around the switch pads thoroughly: alcohol, ammonia, 1 mol sodium hydroxide, then acetone. After that, the resistance between non-connected pads was back up to infinity like it should have been. That meant something on the board's surface was causing the trouble.

I always give my PCBs a coat of acrylic after etching to prevent oxidation, but have never had conductivity problems with that before. Still, strange results demand strange solutions, so I checked the resistance between non-copper parts of some smaller boards that came from the same etching run.

Nothing. Infinite resistance, as expected.

The only other thing on the board was flux residue from soldering the parts in place, and as Sherlock Holmes said, when you've eliminated everything else, what's left must be true.

I smeared some flux on a blank piece of FR4 (same thing as the PCB, but without copper), dried it, and checked its resistance:

7.2 megohms.. we have a winner. Sticking the probes directly into the flux pot gave a reading of 2.6 megohms.

I threw the pot onto a hotplate and melted the flux to see if there were any visible contaminants in it, and sure enough: there was a chunk of copper wire at the bottom with a greenish halo around it. Apparently, somewhere in the past, the wire had dropped into the pot and slowly started to dissolve.

That's not as strange as it sounds, actually. Copper is noted for its tendency to migrate through other materials. Chip developers call it 'silicon killer' because it will diffuse into a silicon crystal or the silicon dioxide (glass) insulators that are supposed to isolate parts of a circuit. Getting copper interconnects to exist on an integrated circuit without having them gradually destroy the chip was a major piece of applied materials science.

At a more immediate level, once I knew the problem, I knew how to solve it. That pot of flux went into the trash, and I've resolved to use only freshly-mixed flux (of course I have rosin on hand) for future projects.

The road to recovery:

After pulling all the parts off the board, cleaning it well, and verifying that there were no residual gotchas waiting to confuse me, I rebuilt the circuit the way I should have done it the first time: one part at a time, testing each part for proper function before moving on.

In the process, I decided that 10 meg resistors made the circuit a bit sluggish, so I replaced them with 1 meg resistors. The result, as you see above, works as it should.

Lessons learned:

The only really new thing I learned was that copper does (eventually) dissolve in soldering flux, and can reach concentrations high enough to cause problems in high-impedance circuits. I'm already thinking about ways to get the concentration even higher, and seeing if this can be turned into an absurdly simple conductive ink.

The rest of the lessons are things I already knew, but this served as a healthy reminder:

  1. Our assumptions about infinite resistance between unconnected traces and so forth are just that: assumptions. They can break down, and produce results that defy "according to the circuit diagram" analysis when they do.
  2. Neatness counts.
  3. Test everything.. including your test equipment, and especially the things you "don't need to test" because you "know" what the answer will be.
  4. Test as you build. It's easy to get excited and start placing parts with wild abandon, but it will bite your ass eventually.
  5. Don't stop asking questions until you have a good explanation for every part of every measurement you make. That's one I learned reading Jim Williams's app notes, and every time I'm confronted with it I respect his wisdom more.

Random brain cookies:

Those who educate children well are more to be honored than parents, for these only gave life, those the art of living well. -- Aristotle