I was looking for a way to add a human interface to my projects at low cost. Using touch sensitive inputs means that there are minimal wiring requirements, as all the components can be included during pcb manufacture.
My projects may be battery powered, so I cannot rely on the project and the person sharing the same ground – when they touch an input having a different ground reference they are unlikely to be recognised.
With battery powered projects, it is necessary for the capacitance of the finger to affect a measurement made with respect to the project ground. One way is to create an oscillator, and have the capacitance of the finger change the tuning of the oscillator to make it oscillate at a different rate. Counting the number of oscillations in a given time gives an indication of whether a touch is occurring or not.
I chose to use the capacitance divider method, as it was simple to understand and to wire up.
The process is to charge up the ADC capacitor, which is present on the input of the ADC on all micro-controllers, and then parallel it with the capacitance of the touch plate.
The charge on the ADC capacitor will be divided between the capacitance of the ADC capacitor and the touch plate capacitance. If they are equal, the initial charge on the ADC capacitor will be divided equally between the two capacitors and the voltage will therefore halve. If the capacitance of the touch plate is increased by the presence of a finger, the resulting voltage measured will be lower.
First we charge the ADC capacitor up. In this case, we use the internal 4.096V reference. At the same time, we discharge the touch pad by switching that pin to operate as an output, and switching it to ground.
Next, we switch the pin to be an input and select it to connect to the ADC. The capacitors are now in parallel, and the initial 4.096V charge is shared.
Here is the design of the touch pad on the pcb. The aim was to minimise the touch pad capacitance.
Here are the resulting pads on the manufactured pcb.
Running some test code, the measured voltage is 645mV with no finger present, and 555mV with a finger pressing on the pad.
These figures provide excellent recognition of a direct key press. Ideally, averaging over time should be used to determine the “no press” voltage, and the confirmation of a key press should be only after a number of valid readings to prevent spurious detection of a key press.
The typical ADC capacitor value is around 15pF, so starting with a voltage of 4.096V, and dropping to 645mV when paralleled with the touch pad, suggests that the combined capacitance of the touch sensor and ADC capacitor is (4.096/0.645)*15pF= 93pF, or that the touch pad on its own has a capacitance of 78pF.
When the pad is touched, the total capacitance changes to (4.096/0.555)*15pF=111pF. The finger therefore adds a capacitance of 18pF.
Unfortunately, with the current design, if a 1.6mm plastic enclosure covers the keypad area, a valid keypress only results in the voltage charging from 645mV to 638mV. Sensitivity would be increased if the touch pad capacitance is reduced when untouched, and increased whilst touched. For instance, if the touchpad capacitance were reduced to 15pF, the ADC voltage would be 4.096V charged, 2.048V when paralleled but untouched, and 1.36V when touched.