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

Thread: Digital inputs switching on their own in a very electrically noisy environment

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    6

    Digital inputs switching on their own in a very electrically noisy environment

    I have a Teensy 4.1 in a shielded environment, with a 25 foot cable run connected to many switches in a very electrically noisy environment (acoustically, too). Have previously used Teensy 2++ and one of the Teensy 3 models (I forget which) successfully at least a dozen times; not sure if that is a factor or if this environment is just different. I believe these were all 5v devices and the Teensy 4 is obviously 3.3v. I'm basically using every single digital pin available.

    The buttons have a common ground and are wired to Teensy digital input pins with pull up turned on. Pressing a button closes the circuit. The cable shield is not connected to anything, my understanding was this would just funnel noise from the outside into the shielded enclosure.

    I'm using the Debounce library with a 20ms debouce time. Teensy spits out serial data on the rising edge using the debouce library functionality. There is NO hardware filtering currently (because to date I never needed it!).

    Problem:
    The inputs are triggering without the buttons being pressed. I don't have the opportunity to get a scope on the lines either because I can't get into the facility, so working blind here. I took two years of computer engineering classes twenty years ago, so my memory is really foggy re possible solutions.

    I'm trying to think of solutions and appreciate ideas. What came to mind was:
    1) Go back to Teensy 2++ in the hope that somehow 5v makes the SNR better -OR- come up with some circuits so the signals are 12v or some other higher voltage
    2) Add lots of RC filtering, since humans can't press buttons very fast anyway. This is a bit problematic because of the component count. I could just throw big caps (1000uF) across each input like a Cro-magnon electrical engineer, or do the math and figure out a combo of resistor-capacitor to get a 1st order filter with a more predictable cutoff frequency.
    3) Clamp on ferrite beads
    4) Differential signaling is probably too complicated.

  2. #2
    Senior Member manicksan's Avatar
    Join Date
    Jun 2020
    Location
    Sweden
    Posts
    294
    You could try to use external pull-up:s . As the internal pull ups are very weak in your case.
    You could try different values 10k 4k7 3k3 1k and see where the random clicks dissapear.

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,345
    If it is for buttons only, just use a low value for the pullup. 1K sounds good. Or try even less.

  4. #4
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    419
    Normally shield should be grounded at one end.

    Another option is to use current signalling, like MIDI.

    Button closure send a 5mA current through an optoisolator, this should be much more resilient to electrical noise.

    The optoisolator is in shielded environment and can convert 5mA to 3.3V

  5. #5
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,255
    10nF is plenty for catching spike noise - that shield should be grounded at one end (the Teensy end) or it won't shield anything.
    You want the noise to be conducted to ground along the outside of the shield, not capacitively coupled direct to the wires by
    the shield. Capacitive coupling imposes a current, so a lower impedance circuit is more immune (hence lower value pullups).

  6. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    I ended up using a combination of software and low pass filtering.

    Since I had so many input lines to filter, I couldn't use very big caps. I tried three different combos of cap and resistor and was able to determine the cut off frequency needed to filter out the noise.

    Added functionality to vary the software debounce on each line.

    Turned out the interference was coming from one nearby piece of equipment.

  7. #7
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    What value cap and resistor did you use? The info could be useful to others.

Posting Permissions

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