Capacitive Touch Controller For FPGAs

Most projects that interface with the real world need some sort of input device. Obviously this article is being written from a standardized “human interface device” but when the computers become smaller the problem can get more complicated. We can’t hook up a USB keyboard to every microcontroller since we often only need a few buttons, but even buttons can be a little bit too cumbersome for some applications. For something even simpler, we would like to turn your attention to capacitive touch controllers.

Granted, these devices are really only simpler from a hardware perspective. Rather than a switch that can be prone to failure either when its moving parts break or its contacts become corroded, a capacitive touch button only needs a certain conductive area on something like a PCB, along with a few passive components, to work. The real difficulty is in the software, so this project aims to make it simpler to bring these sort of devices to any FPGA that needs some sort of interface like this. It can operate in stand-alone mode or in a custom user interface, and was written to be platform-independent in VHDL without the need for any dependencies or macros.

The project’s page goes into a great amount of detail on how capacitive touch sensors like these work in general, and describes the operation of this specific code as well. Everything is open source, so it’s ready to be put to work right away. If you need capacitive touch capabilities on something like a microcontroller, though, take a look at this tiny Atmel-powered musical instrument instead.

10 thoughts on “Capacitive Touch Controller For FPGAs

  1. @ROB said: “[Stephan Nolting] isn’t mentioned.”

    Bryan Cockfield’s article links directly to Nolting’s GitHub site. So what do you want, [Stephan Nolting] to be spelled-out in coveted [ ]s? If yes, that begs an answer to this question: @ROB, are YOU Stephan Nolting?

    Some asides:

    – I came to learn a bit about Stephan Nolting recently when browsing around for RISC-V FPGA cores. See links [1] & [2] below.

    – IMO unless you have a special use-case, cap-sense input is too troublesome to service in small embedded systems unless the microcontroller has on-die hardware to support it. Instead, there are cheap and simple jellybean hardware cap-sense chips available like the TTP22x series, see [3]-[6] below.

    – Personally, I have experienced problems using homebrew microcontroller firmware-based cap-sense solutions in RF rich environments. Less-so with the hardware cap-sense chips. YMMV.

    – My use of the generic “cap-sense” term should not be confused with Cypress Semiconductor’s (now Infineon Technologies’) proprietary CapSense® brand name.

    *References:

    1. The NEORV32 RISC-V Processor

    https://opencores.org/projects/neorv32

    2. The NEORV32 RISC-V Processor

    https://github.com/stnolting/neorv32

    3. One Channel Capacitive Touch Module – TTP223

    https://www.sunrom.com/p/capacitive-touch-module-ttp223

    4. TTP223-BA6 Datasheet:

    http://www.coldtears-electronics.com/images/TTP223.pdf

    5. Four-Channel Version using the TTP224:

    https://www.sunrom.com/p/4-channel-capacitive-touch-module-ttp224

    6. 8/16 Channel Capacitive Touch Module – TTP229

    https://www.sunrom.com/p/816-channel-capacitive-touch-module-ttp2

  2. Interesting article, but regarding the: “a capacitive touch button only needs a certain conductive area on something like a PCB, along with a few passive components, to work” this isn’t entirely correct.

    It also needs some decent software controlling it all, being able to distinguish between signals and noise, decent form of filtering, so the input isn’t triggered 10x times when you’re approaching the “sensor” or nothing at all when you completely touch it with cold fingers. I have a set top box that uses capacitive touch… it is horribly implemented. So you need to tweak it for best performance… never needed to do that on a real button.
    Then there is the LACK OF FEEDBACK which is a big deal to many users (a 10 cent piezo acting like a speaker that generates “click” sound could solve that but is often left out). The fact that you don’t know where the exact physical borders of the “sensor” are makes it slightly annoying. To make a long story short… I love the technology behind it, I can see some benefits, but I hate almost every device that uses it, because of bad implementation. Regarding touch screen on phones, that a different story but works so much better.

    Ever pressed a button on a device that doesn’t respond? Switched on thingy with “touch” buttons but it doesn’t want to turn on… are you pressing in the right spot, is the device broken, is the touch thingy broken, are my fingers too cold? Did I press it too long… or too short… when literally nothing happens it’s hard to draw conclusions. And then there is ESD… but a decent sheet of plastic in front of the touch sensor can solve that.

  3. It’s a useful technique, but often employed when COST is the driving factor. This is what leads to so many poor implementations.

    A robust implementation requires careful consideration of the geometry of the pads. It also requires very good electrostatic protection. You are allowing a user’s finger to directly touch a chip’s high-impedance input. The internal protection diodes are not up to the job. A thick insulator between finger and pad, and a series resistor to the IC input pin is often needed to survive 10KV spikes from petting a cat or walking across a carpet.

    50/60Hz noise will also be injected via capacitive coupling. Ever touched the input of an audio amplifier and heard the lout HUMMM? A finger will inject that same noise into your capacitive sense circuilt. To combat it, pick a sampling time that is some multiple of the AC line frequency to help null it out.

  4. Need some series R between the fpga pin and the caps, to give the fpga IO internal esd diodes a fighting chance. Probably a 2.7v zener at the pin would help, too not too much to add raqther then killing the IO pin.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.