A modern microcontroller has almost everything that’s needed to implement a touch sensor matrix. There are several sensing technologies: IC manufacturers typically advise using certain tech, sometimes they offer ready to use hardware- or software-based solutions. I was curious to try to implement a sensor matrix entirely from scratch all by myself. Here’s how it worked out.
Theory of Operation
I chose QMatrix technology as a basis for my experiment, mostly because I’ve heard about it before and because I liked their whitepaper, which I really recommend to read, here: QMatrix™ Technology White Paper. The point is to transfer the charge through the sensor capacitance to a tank capacitor gradually, until a charge sufficiently large to be measured builds up. After that, a current is applied to the tank capacitor and the time that it takes to reach zero crossing is measured. When sensor surface is being touched, the fingers steal part of the charge to be dissipated by the body and less of it gets transferred to the tank capacitor. This difference can be measured and tried to tell if a button is being touched or not.
he QMatrix Technology Whitepaper already has a perfect illustration of what’s going on, but I drew my own version to aid the explanation. On my drawing: Sdrive is a switch that allows to pump the charge through the sensors; Sslope is what allows the current to the tank capacitor during the measurement phase. Stop and Sbottom are the switches that flip the capactor. Sc connects the analog comparator. Ckey is the sensor, a pattern on the PCB. Ctank is an additional capacitor, 4.7nF in my case. Rslope is fairly large, it is to limit discharge current and make the time measurable.
The process of charge transfer to the Ctank is very similar to the work of a charge pump converter (see Horowitz, Hill: The Art Of Electronics, §6.23).
Read More: AVR-based Sensor Keyboard