Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Using touch inputs on Teensy LC, 3.0, 3.1, 3.2 & 3.6

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274

    Using touch inputs on Teensy LC, 3.0, 3.1, 3.2 & 3.6

    Hi, if I want to use the touchRead(pin) function with Teensy LC, 3.0, 3.1, 3.2 & 3.6 do I just connect a wire to a touch enabled pin or should I use a series resistor of some sort?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Oh if only my memory worked . . . I have asked this before but never followed up . . . here are some useful links for anyone finding this:
    Capacitive Touch Hardware Design Guide
    Capacitive sensors with the Teensy 3.0

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    However . . . would it still be best practice to include a series resistor to protect the input from electrostatic discharge? Anyone?

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,540
    No! As you can see in the reference manual, the Kinetis touch engine (TSI) works with switched constant current sources and charge/discharge thresholds for pure capacitive detection. Series resistors would create a constant voltage drop due to the constant current driving, so that the thresholds would never be reached.

    If you want to protect the pins, use diodes with small reverse junction capacitance as follows: GND -|>|- PIN -|>|- 3V3 . The reverse junction capacitance (i.e. 4pF for a 1N4148) will add an offset of about 200 to your touch readings, but that can easily be compensated in software.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,929
    This PJRC page: https://www.pjrc.com/teensy/td_libs_...iveSensor.html

    Has a sample assembly … and some details on usage:
    … The receive pin may be connected with a wire, but a 1K or higher resistor will help protect the Teensy's pin if a user directly touches the object and delivers an electro-static shock. The safest construction uses an insulating layer, such as the clear tape in the example above.
    Multiple sensors can share a single send pin, but each must have its own receive pin.
    Teensy's ground pin should be connected to earth ground for best results. Normally the USB cable connects to a PC, which connects to earth ground by its power code. But when using a laptop on battery power or running without a computer, you may need to make a dedicated connection to earth ground.
    Teensy LC, 3.0, 3.1, 3.2 & 3.6 have superior hardware-based capacitive touch sensing circuitry on specific pins. They do not require this library. To read capacitance on those pins, simply use touchRead(pin). Hardware-based sensing offers much faster measurements with better stability over temperature variation.

  6. #6
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by defragster View Post
    This PJRC page: https://www.pjrc.com/teensy/td_libs_...iveSensor.html

    Has a sample assembly and some details on usage:
    The above is designed to use the CapacitiveSensor library not the native touch pins of the Teensy LC, 3.0, 3.1, 3.2 & 3.6, it is a completely different beast that is why I started this thread.

  7. #7
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,540
    Yes, you wanted to use touchread() which uses the native touch pins through the TSI engine. So, my reply above should answer your question.

  8. #8
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by Theremingenieur View Post
    As you can see in the reference manual
    Could you post a link to that manual please?

    Quote Originally Posted by Theremingenieur View Post
    If you want to protect the pins, use diodes with small reverse junction capacitance as follows: GND -|>|- PIN -|>|- 3V3 . The reverse junction capacitance (i.e. 4pF for a 1N4148) will add an offset of about 200 to your touch readings, but that can easily be compensated in software.
    I just wondered if I should protect them or maybe this is already taken care of internally.

    So I just connect the pin directly to a wire or pad and that's it?

  9. #9
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,540
    All data sheets and reference manuals for the different processors are here: https://www.pjrc.com/teensy/datasheets.html
    I'd not rely on the weak internal protection and add the diodes. And yes, just a pad to connect (besides the diodes). If the pad is large enough to produce enough capacitive surface with the finger, a very thin insulation layer might also do the job.
    Afterwards, like all capacitive sensing, it's sophisticated. Grounding resistance of the circuit and of the one who touches plays a role, as do ambient humidity and the moon phases...
    Just give the different variants a try. A German word play says "Versuch macht kluch" (Experimenting will make you smarter)

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,929
    Quote Originally Posted by Experimentalist View Post
    The above is designed to use the CapacitiveSensor library not the native touch pins of the Teensy LC, 3.0, 3.1, 3.2 & 3.6, it is a completely different beast that is why I started this thread.
    Indeed it is clearly detailing 'CapacitiveSensor' - but the included text - where "1K or higher resistor will help protect" and usage of "insulating layer" was noted also notes: "To read capacitance on those pins, simply use touchRead(pin). "

    YMMV - as noted … "Versuch macht kluch" (Experimenting will make you smarter) … in experiments here it was with and without resistor and both worked.

  11. #11
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by Theremingenieur View Post
    I'd not rely on the weak internal protection and add the diodes
    Sorry if this is a simple question but can you explain the theory behind the diodes. I guess if the input pin goes more negative than Gnd by approx 0.6V then it sinks to ground and vice versa if it goes more positive than around 3.9V it sinks to the 3.3V pin. I kind of get the Gnd side but not the 3.3V side, could you explain please?

    Quote Originally Posted by Theremingenieur View Post
    A German word play says "Versuch macht kluch" (Experimenting will make you smarter)
    I totally agree, hence my username, I just like to check out what might fry it before starting my experiments (o:

    Thanks for your help.

  12. #12
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by defragster View Post
    in experiments here it was with and without resistor and both worked
    Interesting but seems to contradict this quote:
    Quote Originally Posted by Theremingenieur View Post
    No! As you can see in the reference manual, the Kinetis touch engine (TSI) works with switched constant current sources and charge/discharge thresholds for pure capacitive detection. Series resistors would create a constant voltage drop due to the constant current driving, so that the thresholds would never be reached
    The diode option seems very straight forward so I guess I'll give that a go, thanks for responding

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,929
    Quote Originally Posted by Experimentalist View Post
    Interesting but seems to contradict this quote:
    ...
    To some degree it does - reading the linked library page it appears those are PJRC added details specific to Teensy. That makes clear the choice of resistor value will have an affect on the timing and measured response - which is what Theremingenieur was it seems focused on? It suggests min value of 1K … and refers to the issues of using 1 Mega Ohm. So there is a continuum of usable range bounded on the low Ohm end by not protecting the MCU from shock and on the upper end where higher resistance could lead to too much sensitivity not requiring true touch. { edit: "Larger values allow more sensitivity, but with slower response".}

    as noted YMMV - if a touched or not touched state is all that is needed there will be a combination of resistor that will likely give a usable threshold value to determine that. If something more specific is desired … perhaps determining a proximity value with certainty then the usable sensitivity of the hardware could be lost. But changing weather/humidity proximity to desired GND plane will also it seems affect fine measure …


    Test here was some combinations of copper tape touching wires to Teensy - with and without a tape covering, also resistors directly in female headers and even bare wire in female headers - all seemed to give usable touch. And just found a proto board with copper tape punctured by resistors and soldered and the resistor to wires to feed the Teensy - it was a fleeting experiment interrupted by something else with just enough understanding to know it worked. Also a sketch looking for detect threshold that showed the initial read value was not the same as repeat readings once the touch was established because both touching and reading are active elements of the process of measuring the capacitance.
    Last edited by defragster; 10-07-2019 at 11:01 PM.

  14. #14
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,929
    Quote Originally Posted by Experimentalist View Post
    Sorry if this is a simple question but can you explain the theory behind the diodes. I guess if the input pin goes more negative than Gnd by approx 0.6V then it sinks to ground and vice versa if it goes more positive than around 3.9V it sinks to the 3.3V pin. I kind of get the Gnd side but not the 3.3V side, could you explain please?

    ...
    Would be interesting to see this for sure: assuming the diode would allow current flow OUT of the Teensy to the touch area which would allow the capacitance measure to function - and be so aligned to as to prevent any touch area discharge from passing the diode into the Teensy pin?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •