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

Thread: touchRead value bouncing all over the place

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    12

    touchRead value bouncing all over the place

    Good day,

    I am working with a motorized fader and have been trying to use to touchRead function as a way to interrupt the fader when it is in motion. I've been experiencing some odd (maybe) behaviour and although I have a work around I wanted to check if this is normal, if there is a problem with my use of touchRead or if maybe I need to improve my circuit. so here's the simplest form of the code that returns the result I'm talking about:

    Code:
    #define TOUCH_PIN A9
    
    void setup() {
         Serial.begin(115200);
         pinModer(TOUCH_PIN, INPUT_PULLUP);
    }
    
    void loop() {
         int touchVAL = touchRead(TOUCH_PIN);
         Serial.println(touchVAL);
    
    }
    I am using a teensy 3.6 and I have the CPU speed (of the teensy) set down to 96MHz as some other parts of my code are unstable when it is running at 180MHz. But basically when the fader is not touched the touchRead function returns a value that is pretty stable around 3800 however, when I touch the fader the touchRead function returns a value that bounces between maybe 200-300 and to over 4000. For the moment I am averaging reads and for the most part it works because touchRead is very stable when not touched however, this introduces a slight delay from when I touch the fader to when it detects a touch. As the motorized fader in this project is mostly snapping from one value to another as quickly as possible I would like to get a more stable read from the touchPin so that, for example, the fader motor stops as quickly as possible if it slams into someone's finger.
    As for the circuit I have the touch sense pin on the motorized fader going directly into the pin A9 on the teensy. The teensy is mounted inside an enclosure with a PC (motherboard, processor, GPU, power supply, etc) and the motorized fader is mounted to the outside of the chasis which is grounded. So maybe there is some interference going on? Any assistance on this would be greatly appreciated as I have not been able to find much documentation on the touchRead function.
    Best regards,
    -Andrew

  2. #2
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Location
    Florida
    Posts
    383
    TouchRead counts on you yourself being grounded to get stable readings, the more grounded you are the higher your touchRead value will be, at the same token the more grounded you are the slower touchReads become and your whole sketch slows down. If you are properly grounded your values should be well above 4000, I’ve found touchRead to be inaccurate at best for reading faders and that’s not to mention the problem of always having to be grounded to get good readings. There is external circuitry that can do a much better job of detecting touchs that doesn’t use a microcontroller and you don’t even need to be grounded in order for it to detect you. The best part is the touches can just be read like a regular button, either low or high with no threshold calibration, I happen to own a system that uses such a circuit for motorized faders so I’m going to be working on reverse engineering a schematic for it. It’s quite a few component for just reading touch, but it’s always been 100 percent reliable for me when I tested it vs touchRead.

    Here’s pictures of the circuit, it’s only a 2 layer board so it’s pretty simple, but the only thing this whole board does is read the touch value, all the other wires you see are routed directly to the ribbon cables.
    Click image for larger version. 

Name:	3B8E25B2-5E16-45F7-B1D1-E0F3C89910B9.jpg 
Views:	6 
Size:	201.8 KB 
ID:	17962
    Click image for larger version. 

Name:	52D8431C-49D7-4353-A856-7F344CC7FC35.jpeg 
Views:	4 
Size:	371.9 KB 
ID:	17963
    With this circuit if you really wanted to you could connect the output from the touch value and directly connect it to the enable pin on your motor driver chip without using the Teensy to turn it off. You would probably need an inverter to do this though since most chips are active low and this circuit outputs low when touched, but again that’s if you really wanted it to be as “real time” as possible.

  3. #3
    Junior Member
    Join Date
    Feb 2018
    Posts
    12
    Hey Vjmuzik,
    Thanks again for the info! I was hoping I could find a simpler solution (even if it's quick and dirty) as things are already pretty cramped in my enclosure as it is and I need some space for cooling the CPU effectively. I don't care so much about accuracy but the problems is sometimes the touch values overlap the non touched values so even with a threshold I get false positives. Averaging gets rid of that but is far too slow as I still have the motor grinding for a few fractions of a second before it cuts. It really is just to protect the motor though, I'm not triggering reads with touch or anything like that. In any case I'll consider your solution and whether it fits into the scope of my project.
    Thanks!
    -Andrew

Posting Permissions

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