Touch Sensor Teensy3.1 v Arduino Uno

Status
Not open for further replies.

Teenfor3

Well-known member
I had a project running on Arduino using external pullups (20 Megohm), set the pins used as digital inputs and used digitalRead to detect high or low. It all worked well. The touch pad actually needed split half connected to ground and half connected to the pin. It worked as resistive sensing when touched the pin was Low.

I have tried the same project using Teensy 3.1 but cannot get the Teensy to detect touch by the resistive method. I have tried 10, 20, 30, and 40 Megohm. I can get it to work by bridging the pad with a resistor. say 10 Megohm. (10/(40+10) x 3.3 volt ) gives about 0.66 volts and it works and reads logic 0. But not all the time.....If I go to the next pad it may not work. If I measure the voltage on the pad when the resistor is bridging it, it works and I get 0.6 volts OK but for some reason some times the pad sits at 3.00 volts with the resistor connected and volts doesnt drop. If I go to another pad and come back may work OK and give 0,6 volts next time. It is as if the pin outputs 3.00 volts at times for some reason...?????

I can get touch to work OK on Teensy3.1 using touchRead and it works very well and doesn't need ground.

I am using the same pins to try out the resistive sensing ( pins 15, 16, 17) so everything is connected the same except for the external pullups.



This is snipits of the code I am using..........

This bit is before SETUP

int tch15 = 0;
int tch16 = 0;
int tch17 = 0;

int tchpin15 = 15;
int tchpin16 = 16;
int tchpin17 = 17;


PinMode is in SETUP........

pinMode(tchpin15, INPUT);
pinMode(tchpin16, INPUT);
pinMode(tchpin17, INPUT);


This bit is in LOOP......

tch17 = digitalRead(tchpin17);
delay(1);
tch16 = digitalRead(tchpin16);
delay(1);
tch15 = digitalRead(tchpin15);
delay(1);

......................................................
I also serial.print out the values to see changes.

Just wondering if anyone has tried resistive touch sensing and got it working. Or are the electrical characteristics of the Teensy3.1 different from the Arduino and maybe wont work. The Arduino seems similar to CMOS inputs and it works OK on them.
 
Or are the electrical characteristics of the Teensy3.1 different from the Arduino and maybe wont work.

Yes, it seems so. I just recently ran into this while porting the Capacitive Sensor library. It seems to be a function of the 5V tolerant pins. When the input is high, there's a very weak pull to about 3V. But it's much too strong to be using a 20 Mohm resistor.

The analog pins, while configured as analog inputs, might work. That is, if you can wait for analogRead() to read the pin.
 
Thanks Paul for reply, Yes I thought it was behaving funny.......
I wonder does it matter what GND pin I use....I used the one beside pin0.

I briefly tried the analogRead but I think doesnt work well (need to try again) with the resistances involved in touch switch pads. ( 500k upwards depending on dry or moist contact)

touchRead works well but I think about 1-2 milliseconds per pin read so if reading 8 in a row and checking if high or low and storing them in a byte variable can take 15+ milliseconds.
Is there anyway I can read touchReads as a byte using the way I can with digitalReads.....
Example ........ mybyte = ((PIND & B11000000) >> 4) | (PINB & B00000011);
Where this checks the registers directly at processor speed and not at digitalRead Speed.
I am only interested in whether the pad is touched or not, don't want to measure the actual resistance
 
Status
Not open for further replies.
Back
Top