Capacitive resistance on analog pins

Status
Not open for further replies.

redon

New member
Greetings everyone,

I'm making a glove with 5 fingers, using Teensy 3.2, where each finger has 3 copper pads which should give out different resistance values.

capacitive.JPG

I tested ADCTouch library from
HTML:
https://github.com/martin2250/ADCTouch/blob/master/examples/Buttons/Buttons.ino
on Arduino Uno, and it worked well, I could divide the values into 3 categories.
But when I tested it on Teensy 3.2, it says "Error compiling for board Teensy 3.2 / 3.1.". My whole project has the Teensy as the brain, so i need it on Teensy. I would appreciate it a lot if someone could help me modify the libraries so I can use the same code on Teensy, or if someone suggests a code with which I can read the capacitive resistance of the copper pads

Buttons.ino
Code:
#include <ADCTouch.h>

int ref0, ref1;     //reference values to remove offset

void setup() 
{
    // No pins to setup, pins can still be used regularly, although it will affect readings

    Serial.begin(9600);

    ref0 = ADCTouch.read(A0, 500);    //create reference values to 
    ref1 = ADCTouch.read(A1, 500);    //account for the capacitance of the pad
} 

void loop() 
{
    int value0 = ADCTouch.read(A0);   //no second parameter
    int value1 = ADCTouch.read(A1);   //   --> 100 samples

    value0 -= ref0;       //remove offset
    value1 -= ref1;

    Serial.print(value0 > 40);    //send (boolean) pressed or not pressed
    Serial.print("\t");           //use if(value > threshold) to get the state of a button

    Serial.print(value1 > 40);
    Serial.print("\t\t");

    Serial.print(value0);             //send actual reading
    Serial.print("\t");
	
    Serial.println(value1);
    delay(100);
}

Thanks
 
On Teensy 3.2, you'll probably get much better results if you use the special touch sensing pins with touchRead(pin). It's built in and works pretty much the same as analogRead(pin), except it reads the capacitance on the pin in 1/50th of a pico Farad. Dedicated hardware inside the chip does all the hard work, so it's fast and quite stable compared to the result you'd get with external resistors.
 
The Teensy 3.x has built in hardware for capacitive touch sense and there's a working library (https://www.pjrc.com/teensy/td_libs_CapacitiveSensor.html), can't you just use that?

[edit] - See Paul's message below. I was on phone and picked a bad link. This one is better: http://njhurst.com/blog/01356576041


On Teensy 3.2, you'll probably get much better results if you use the special touch sensing pins with touchRead(pin). It's built in and works pretty much the same as analogRead(pin), except it reads the capacitance on the pin in 1/50th of a pico Farad. Dedicated hardware inside the chip does all the hard work, so it's fast and quite stable compared to the result you'd get with external resistors.

Thanks for your quick replies. I can read the values now, but they are intersecting. For example, as in the figure, i have used resistors to get different values, but i can't categorize them because the results are very close to each other. What resistors do you suggest using between the 2 pads?
 
No resistors!!! Connect each pad directly to a different (touch capable) pin of the Teensy and handle the readings in a loop. Teensy touch detection is purely capacitive via internal current sources/sinks. That means that each touch pin has already its own internal and individual pseudo-resistor and just detects the capacitance (change) of whatever is connected to that pin with high precision.

That's why resistors have no place in teensy's touch sensing in opposite to other, older, and smaller/cheaper MCUs, where one pin is driven high at regular intervals to detect roughly the time delay of an external resistor-capacitor low pass on a second pin.
 
Greetings, in fact i need to use 30 pads, and i have 10 free analog pins. I think i will be using two MPR121 which give me 24 touch pads, and the rest i will put on analog pins. But i've used the primary SDA and SCL pins for IMU, can I use the secondary SCL and SDA pins of Teensy 3.2 (16 and 17) for two MPR121? Thank you
 
Status
Not open for further replies.
Back
Top