This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How should you test the capacitive touch library?

I was able to write the code and put it to work on AN5 pin , and I found out that whenever I approach to the DK board he see it as a touch.

I connected to the pin a 10cm exposed wire, and when i touch it nothing happens, only when I touch the plastic of the connector.

What kind of touch the library expect ?

I am trying to understand in terms of hardware, what really is going on here ? should I touch directly the analog pin , or should it be through an isolator ?

and how to make it faster ? what are the tresh holds values means ( of 400 ) ?

Thanks a lot.

  • Although I've not used the capacitive library of this device, I have of others. A capacitive sensor works by measuring changes to the electrical field that is generated around or between the sensor area and a ground plane.

    They don't require actual touch to work, but the design of the sensor area (where you are trying to detect the presence of a finger say) can be tricky.

    Texas Instruments have a very detailed section on their site covering this.

    Ideally you should attach a small conductive area (say some copper tape) to your wire (attached to the detection pin - AN5). This should have another area connected to a ground, common to the MCU, placed underneath it with the two separated by a non-conductive material (even dry paper will work, but go with something around 1 - 2mm thick.) The higher the dielectric constant of the material the better - air is 1, PCB FR4 is around 4, polyester may be 5 etc.

    Ideally you want to have the ground layer slightly larger in comparison to the "live" area otherwise you'll find that your not detecting your finger, approaching the sensor area but it approaching the ground layer!

  • Thanks a lot, that's strange because everywhere I read , you require only 1 pin for it to work, and you say I need also to connect a ground plate and put a dielectric material between them, I am not sure I still understand how it works and why you need 2 plates. Touching the pin should change capacity and hence change the frequency measured by the PPI . Why putting 2 plates instead of just using a real capacitor to get the same effect?

  • The main issue that you have is direction of detection and field strength. From experience I have found that the ratio of mass of conductive material between the processor pins and the sensing area has an effect on how sensitive the sensing area can be in relation to the wire connected to it. A ground plane behind the sensing area, on the opposite side to the area of detection helps to, reduce the sensitivity of false detections from that side. A typical problem during development would be laying the sensing area, be it wire, plate whatever on a desk and finding that the movement of the sensing area in relation to the desk or even the tester touching the desk may have a greater effect than placing your finger onto or near the area in question. The ground plane when connected to a common ground that the MCU uses ensures that the dielectric field in that direction is constant. This need not be a pin on the MCU just to the PCB ground. You'll also find that changing the dielectric constant of the area between sensing area and your finger say will change the sensitivity in that direction hence a bare wire will have different sensitivity to a covered one. The technology typically works by sending micro-pulses to the sensing pin and then measuring the decay rate when compared to an internal reference. This means that there is a limit to the capacitance of the sensor area and parasitic capacitance of the connection to it that the MCUs can cope with.

  • Thanks very much! great explanation, so what would be a good way to simulate at home (before making the pcb) how the touch works? just 2 plates separated by cardboard, where one goes to ground ?

  • Yes that would be a start, just don't make them too large. I apologise for posting a competitor's page on here, but check out this page for some interesting information on sensing basics: link text

Related