Teensy 4.0 Capacitive Sensing alternative

Hey Adrian, I just downloaded your fastTouch library and I just can’t find any instructions at how to wire the pins to my copper foil that should be the touch pad. Could you tell me how to set it up?

Thanks, and greetings from Germany!

Phil.
 
Hey jrraines, thank you for the quick reply! Do you take any digital pin and connect it with one wire only to the pad? No resistance and ground or 3.3v at all?
 
right. Just a wire to the copper pad and the pin. Any pin I don't need for something else. Typically I've been doing projects with a small speaker mounted on MDF, paste the copper pad with the solder on the inside of the enclosure and wrap the foil around the MDF. I used a little program to read the values while I touched or did not touch to decide on 30 as the threshhold, YMMV.
 
Yeah, it doesn't require anything additional. The way it works is to pull the pin hard to ground using the output transistor on the pin. Then it starts timing how long it takes for that pin to register as a high input value after a built-in pullup resistor is turned on. Since that resistor has to charge whatever capacitance it sees on the end of the wire, the timer value is a good proxy for capacitance. There are lots of articles about how to design the layout of the conductor you connect according to what you want to do - keyboards, sliders etc. I often run ground traces between and under capsense traces to better isolate or control sensitivity.

I have conductive silver pens, conductive fabric and conductive copper tape on hand to quickly experiment before committing to a PCB.
Alice made an inspiring art piece using scraps of conductive fabric and the library:
http://www.adrianfreed.com/content/...fast-portable-low-fidelity-capacitive-sensing
 
Yeah, it doesn't require anything additional. The way it works is to pull the pin hard to ground using the output transistor on the pin. Then it starts timing how long it takes for that pin to register as a high input value after a built-in pullup resistor is turned on. Since that resistor has to charge whatever capacitance it sees on the end of the wire, the timer value is a good proxy for capacitance. There are lots of articles about how to design the layout of the conductor you connect according to what you want to do - keyboards, sliders etc. I often run ground traces between and under capsense traces to better isolate or control sensitivity.

I have conductive silver pens, conductive fabric and conductive copper tape on hand to quickly experiment before committing to a PCB.
Alice made an inspiring art piece using scraps of conductive fabric and the library:
http://www.adrianfreed.com/content/...fast-portable-low-fidelity-capacitive-sensing

Hi

Is there a reason that for the Teensy 4x there's a wait for delayMicroseconds(1); and for the Teensy 3x delayMicroseconds(50); after driving the pin down?
Actually it would be better that the timing would depend on all the pins and thus the last pin that has been input.


Another difference :
As the pin is driven low after the readout, which is good neighbouring pads will be to ground.
On the Teensy 4x this happens when interrupts are still disabled, which seems unneeded.
Also doesn't happen when a goto :eek:ut is called.
 
Some more information: FastTouch is better suited for fast CPU, aka running a teensy 4.1 at 24MHz is not the best choice.
 
The wait's are to be sure any output capacitance is discharged. This is a bit tricky to do right since i don't know how much capacitance load you are going to add with your wiring and sensor.
I also have built some sensors that switch between resistive and cap sensing on the same pin and these delays were tuned for that.

Yes, you can move that write after interrupts are disabled but it is a fast instruction sequence.
 
The wait's are to be sure any output capacitance is discharged. This is a bit tricky to do right since i don't know how much capacitance load you are going to add with your wiring and sensor.
I also have built some sensors that switch between resistive and cap sensing on the same pin and these delays were tuned for that.

...

I find it strange that the Teensy 4x would discharge 50x times faster than the Teensy 3x. Both are rated for 5mA , some Teensy 3x even for more.
 
Adrian

2 questions from reading the source code:

a) on line 75 of FastTouch.cpp :
#elif defined(__MKL26Z64__)|| defined(__IMXRT1052__) || defined(__IMXRT1062__) /* Teensy 3LC */
That seems to me the LC and 4.x (the last will never be selected because the first if statement.
For a T3.6 the function far below is used.

b) for the Teensy 4.x
You don't use the first 2 (no ++i), than use 6 if statements and then follow with a loop.
Why not using all reading and do them all in 1 loop?
(For a Teensy LC the loop unrolling -with 64 statements is faster than a loop. But always takes all the time. Here also the first 3 readings are not used.)
 
Back
Top