How to do Capacitance Switches? (traces on circuit board that you touch) - Page 1
Forum section: electronics / beginners

author: K3mHtH
author_rank: Regular Contributor
timestamp: February 26, 2021, 05:47:54 am
content: Hey all,I've seen quite a few products that use bare traces on the circuit board as a capacitance switch and thought that was a pretty cool idea (no moving parts!). Is this always done with a dedicated IC or a microcontroller with capacitance sensing capabilities? Or is there ever a way to do this with discrete components?I don't need an analog output based on pressure, I'd be happy with just a logic level hi or low depending on if the trace is being touched.Also if anyone has done this before, are there any guidelines for how the circuit board touch portion should be designed?

author: Psi
author_rank: Super Contributor
timestamp: February 26, 2021, 06:14:52 am
content: All options,You can do it with any MCU + some discrete parts and one of the hardware timers in the chip.You can do it easier with a MCU that supports capacitive touch buttons, a lot of them do.You can do it even easier with a dedicated chip.Touch buttons do have some disadvantages.- They don't like water on them, they get really glitchy and trip randomly.- They can get a bit intermittent/troublesome some days and fine others because they depend on external factors that can change day to day. Some of them do an auto calibrate to try avoid the issue a little.- They give no user tactile feedback which makes them a little annoying sometimes.Google Arduino Capacitive Touch for more info

author: james_s
author_rank: Super Contributor
timestamp: February 26, 2021, 06:47:28 am
content: It's certainly possible to do with discrete components, although there are numerous dedicated ICs available to do it and many microcontrollers that have it built in.Personally I really don't like touch buttons though, they have no tactile feedback at all and I find myself often having to jab at it multiple times and not knowing whether it's not responding because of a software issue on the host device, or because I didn't touch it hard enough or in the right spot, or because there's a hardware fault or some other issue. I don't know if I have dry fingers or moist fingers or some other aspect that affects it but touch controls and touchscreens always seem to give me problems.

author: kjr18
author_rank: Regular Contributor
timestamp: February 26, 2021, 07:17:08 am
content: There is one example board in these arduino sensors kits. As you can seehere (step 14)it's not that complicated as far as circuit goes.But as mentioned earlier, it's not very stable. You can cheaply buy single touch pad boards for little money, they use TTP223 chip, you can configure it as a momentary or normal switch, default on or off, with only two jumpers. You can also tweak sensitivity by adding small capacitor. It also auto calibrates. It's not really hard.

author: Psi
author_rank: Super Contributor
timestamp: February 26, 2021, 07:31:40 am
content: YeahTouch buttons are easy to doTouch buttons that work reliably in all situations are quite hard. You're best to use a dedicated IC for this reason and let it deal with some of the tricky stuff. Then you just need to worry about touch pad layout and tracks rather than the detection system.

author: K3mHtH
author_rank: Regular Contributor
timestamp: February 26, 2021, 03:20:59 pm
content: Okay thanks guys, I didn't realize there were changing variables that need to be considered, etc. But that makes sense...If I am using a Teensy 3.2 - does it do these automatic calibration stuffs by itself like a dedicated IC would (like TTP223 as mentioned) or would that then be something I have to code?Thanks for the replies so far - and I definitely understand the drawbacks of capacitance switches, especially the lack of tactile feedback. However this is for a very weird situation where the switch cannot make any noise.

author: Manul
author_rank: Super Contributor
timestamp: February 26, 2021, 04:26:20 pm
content: If MCU does not support capacitive touch, you can still do it, even without external components. It is not rock solid, but works reasonable. It needs low level port manipulation. What you do is set pin to output, drive low, set back to input, set pull-up and read the port after some calibrated period of time, usually from a few up to 10's of machine cycles. Or just loop reading the port and count the actual cycles it takes for the pin to get high. This is how you can measure capacitance of pin and determine is it above threshold. Possible to implement some auto calibration too. This is also efficient, takes very little time to read a button. Some additional software methods like debouncing would make it quite robust.

author: noobiedoobie
author_rank: Regular Contributor
timestamp: March 09, 2021, 10:12:37 am
content: I have been busting my ass to get working a proper touch switch with reasonably large size pads and I spent more than an year on it.As others have pointed out its very to do but it will not work well in all conditions. Specially if there is a lot of electrostatic/EM noise. There are dedicated chips like the TTP223 and microchip has a whole line of products for touch solutions; like the MTCH101 is a dedicated single channel touch ic that does the calibration. The calibration is not reliable in though in AC environments, it can get too sensitive and trigger by itself at times.Regarding guidelines on designing the touchpads check this out:https://www.microchip.com/stellent/groups/sitecomm_sg/documents/devicedoc/en542979.pdfThere are more docs on the microchip/atmel site regarding touch switches

author: Gyro
author_rank: Super Contributor
timestamp: March 09, 2021, 10:34:51 am
content: I remember a design for a large area single capacitive touch switch project that simply used a 4000 series cmos counter (probably a CD4040 or 4060) that actually relied on the AC environment. It simply counted a sensible number of capacitively coupled mains cycles (probably a couple of seconds worth) before toggling.Just a though, no good for isolated battery devices of course.

author: noobiedoobie
author_rank: Regular Contributor
timestamp: March 09, 2021, 10:50:12 am
content: Nice! How large was the pad? Approx dimensions?Thats what I was saying... Its hard to get a touch switch thats so robust that works reliably in all all environments. Even the the touchscreen of smartphones trigger things if the live earphone cable touches it.

author: Gyro
author_rank: Super Contributor
timestamp: March 09, 2021, 10:56:53 am
content: It was around normal light switch size, maybe 50 x 50mm. It didn't use an outer conductive pad, just an area of copper on the back of a piece of FR4 PCB. It's easy to set the sensitivity with a high value shunt resistor on the CMOS input.

author: noobiedoobie
author_rank: Regular Contributor
timestamp: March 09, 2021, 11:10:02 am
content: Quote from: Gyro on March 09, 2021, 10:56:53 amPretty neat!Share the circuit if you have. Also what would be max distance from the AC line one had to be for the touch to work?

author: Gyro
author_rank: Super Contributor
timestamp: March 09, 2021, 11:53:45 am
content: Sorry, I don't have the schematic (but it was pretty much as I said (input to CMOS counter, output driving a relay through a transistor driver. You might find it if you want to trawl thoughhttps://worldradiohistory.com/. I think it was Electronics Today International (ETI UK), but it was aloongtime ago.I can't remember the distances (apart for it being a physical touch to the insulated side of the PCB) but you could maybe do some tests using a scope probe (x10 for 10Minput) and similar sized insulated test pad). A CMOS input is significantly higher input impedance. A I said, even with no direct electrical contact, you would want some form of input protection - at least a high value (1 - 10M) series resistor so that the CMOS input protection could clamp any spikes.

author: noobiedoobie
author_rank: Regular Contributor
timestamp: March 09, 2021, 04:14:44 pm
content: I am sorry I didnt read your first post correctly... Yes I understood the circuit.I dont have a scope that's the biggest problem.Otherwise working on these things would have been a breeze.