adafruit / Adafruit_FreeTouch

A QTouch-compatible library
41 stars 15 forks source link

How to handle multiple sensors at once #12

Closed zolianek closed 4 years ago

zolianek commented 4 years ago

Hi! I have a bit of a problem. I am trying to make some device that would utilize the touch keys in order to control it. The mcu I am trying to use is the SAMD21E15 one but I've had the exact same problem using your trinket m0.

(I am using the oversample of 8, rest is set as in the example project)

So my problems started right at the beginning when I just ran the freetouch example project. For my device I'd need for it to be able to recognize all the touch keys at once (that mcu has only 6 pins that seem to work but that'd be enough for me) so to eg. do one action when there's only one touched, another action when two of them are touched etc.

However when I ran the freetouch example project it looks like a totally impossible task. The problems start appearing right after I touch only two of them. So when I am not touching any of the copper plates I'm using as sensors the readings vary between 150 and 250 depending on the pin. When I touch only one of them the value for that pin rises up to about 1000 which is plenty enough to set a simple action trigger when the value reaches eg. 500. But when I touch two of them then I am not getting the values of 1000 on both of them, instead it's somewhere around 400 for each pin. The situation gets even worse when I touch 3 plates as then the values read can be used to determine if the button is touched no more - all 3 of the readings drop close to the 250 base reading so it seems impossible to set any threshold to have 3 buttons activated at once and it's just half of the pins I wanted to utilise.

I can't believe that this is a proper working setup. Do I need to configure the freetouch pins in some special ways? Changing oversample and series resistor values gets it even worse as the readings for 3 pins touched at once drop below the base value, with any other resistor set they drop to less than a 100.

I am thinking that maybe this isn't as simple as just connecting some copper plates into the pins and it needs some more parts in order to get it to work properly?

Thanks in advance

ladyada commented 4 years ago

hi each touch can cause cross talk - this is a reverse-engineered library so we dont have any information beyond whats in this library. for tips and tricks on capacitive touch, there's tons of information online (about pad size, placement, etc :) thanks!

zolianek commented 4 years ago

Thanks for the answer. Is there any way in this library (or any easy way to add it) to disable the sensor that has been already enabled? This way I could measure only one pad at the time so enabling only one sensor while the rest would be completely disabled.

ladyada commented 4 years ago

not at this time - you could add a disabling function as a PR!