element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum False triggering interrupts in Arduino Mega2560
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 19 replies
  • Subscribers 395 subscribers
  • Views 4232 views
  • Users 0 members are here
  • interrupt
  • interrupt problem
  • Design
  • interr
  • interru
  • product design
  • arduino
  • arduino avr
Related

False triggering interrupts in Arduino Mega2560

shwetankv007
shwetankv007 over 7 years ago

Hello everyone,

Greetings of the day, i have been working with embedded systems for quite a while now, currently i am working on a project that dispenses water depending upon the balance from rfid card, however the system has start stop and recharge buttons connected to interrupts of microcontroller Atmega2560 with internal pull-ups driven from falling edge. The system works fine mostly however in some cases false interrupts are detected that causes functions to be activated for respective buttons i.e. start stop or recharge. I tried adding a coupling capacitor and a schmitt trigger circuit to stabilize the input but it still detects the false signals of noise.

 

Moreover a small touch on the interrupt terminals(buttons not connected ) also causes the interrupt to be triggered, any suggestions are appreciated.

 

I am using arduino for declaring and defining the interrupt pins and their respective routines. The function just hosts a flag which is then checked in the main loop.

 

Thank you in advance.

 

EDIT:-

As suggested I tried:-

1. Adding an external pullup of values ranging from 1.5k-10k but the issue persists

2. Adding the decoupling capacitor

3. Power supply is fixed and using a bench supply of 24volt stepped down by a MORNSUN buck converter.

4. Not tried the debouncing test since the problem is not related to button press. Even if the button is not pressed, if I touch the open end of wire connecting the interrupt terminal then also it triggers the interrupt.

5. the pin is not routed near a power rail or a high frequency coil/trace.

 

interrupt problem  interrupt arduino avr product design

 

Message was edited by: shwetank vishnu

  • Sign in to reply
  • Cancel

Top Replies

  • jc2048
    jc2048 over 7 years ago +4
    Perhaps try an external pull-up and see if that helps.
  • Jan Cumps
    Jan Cumps over 7 years ago in reply to shwetankv007 +4
    even when it’s not related to the button and debouncing, there has to be something electrical going on. If it happens when you pat the terminal, an oscilloscope with single shot trigger would help to catch…
  • jw0752
    jw0752 over 7 years ago +3
    Hi Shwetank, Here are some ideas. Have you checked to make sure there is adequate decoupling on the power supply to your unit? Poor power quality can make the Arduino glitchy. Another thing to check is…
  • DAB
    DAB over 7 years ago in reply to shwetankv007

    If you are getting interrupt triggers then you have noise in your power system.

    Either switch to batteries or put some big capacitors on your power input.

    If you have access to an oscilloscope look at the power and then look on the switch input lines.

    If the power is clean, but you have noise on the input lines, put in pull down resistor to ground and use the switch to pull the inputs up to vcc.

    If you still have problems, then you must have an issue on the board itself.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • mahmood.hassan
    mahmood.hassan over 6 years ago

    I have once used the button at ~30m with dspic33 and I always had problem in measuring signals when power supply (I mean 24V) was not properly grounded (earthed). And always use twisted pair with shielding.

    Another possible solution is add a simple low pass filter at mcu input (Best, low cost and easy solution) because in long wires you can easily get few V p2p noise which can be sufficient to trigger false interrupt.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • dougw
    dougw over 6 years ago

    As the comments suggest, there are lots of ways that noise can be introduced and trigger an interrupt.

    It can be tough to track down exactly what is happening when the issue is intermittent, but while you are working through all the possibilities, you can also try various fixes, as you have been doing with pullups and capacitors. Another fix is glitch removal. In the interrupt handler, poll the interrupt pin for 20 ms to ensure it is a valid interrupt before accepting it. If it is not valid after 20 ms, simply return without taking any action. This also works as a debounce technique.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 6 years ago

    So, if your system is set up within an Interrupt on a falling edge you need to then think about what is causing a voltage drop that fits the following criteria:

    the Arduino (ATmega) will report LOW if, (a) a voltage less than 1.5V is present at the pin (5V boards) or (b) a voltage less than 1.0V (Approx) is present at the pin (3.3V boards).

     

    Sounds like something is floating and sometimes if you are seeing voltage drop somewhere that is unexplained then it might mean you have a strong current draw somewhere from some peripheral (e.g. does this happen when dispensing water) and your 5V power system is too underrated to supply the current and hence you get a voltage drop.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • slocombem
    slocombem over 5 years ago in reply to dougw

    Hi Douglas

     

    I'm fairly new to arduino and I'm having the same issue. I'm getting phantom button presses due to noise on my inputs, I'm using internal pull up so cant switch to an external pull down as mentioned earlier in this post. I have around 100 buttons at various cable lengths, they all work but some are getting noise and running functions without me pressing them. I have ensured its not my power supply by running the system from a usb battery pack for a while, the issue still occurs.

     

    I'd like to use your idea of polling the interrupt for 20ms, but I'm not sure where to start. I had a look online and haven't seen other people talking about it. Everyone discusses debounce, but thats not going to help me with noise.

     

    How would I go about adding this into my sketch?

     

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • fmilburn
    fmilburn over 5 years ago in reply to slocombem

    Hi Matthew

     

    There is a very clever way of doing it illustrated in this code although it is not Arduino (but could be implemented with Arduino):  AIS Alarm - Debouncing Momentary Button Switches.  Look for the links provided to Hackaday and Jack Ganssle for a complete description of how it works.

     

    If you want to simplify it further then set  a flag inside the interrupt when it occurs and then outside check if the button continues to be pushed for 20 ms or so.  Bouncing and power glitches seldom last this long.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to fmilburn

    Stronger pull-ups than the internal ones could help too for noise (not for bounce though).

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • slocombem
    slocombem over 5 years ago in reply to Jan Cumps

    I have added I/O headers to the end of the cables and they are connected directly to the arduinos. I have 6 arduino's each with between 20-30 buttons plus other sensors. When I said 100 in my past comment I was just suggesting "alot".

     

    Is there anyway of using 1 external pull up resister for the 30 inputs per board. When I looked at this I thought  each switch would need its own resistor, given the number of switches I have I decided against it. I'd rather do it with software.

     

    I am thinking about trying a 20ms delay on a IF after a button press, then checking if the button is still pressed.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mahmood.hassan
    mahmood.hassan over 5 years ago in reply to slocombem

    Resistor network/array are very good alternate of attaching individual resistor with each button. Installing 2 or 3 resistor network is way easier than writing and debugging the code for each individual button. And these are available in both smd and pth packages. Another useful alternate of individual capacitors is capacitor array.

     

    https://www.newark.com/w/c/passive-components/resistors-fixed-value/fixed-network-resistors

    https://www.newark.com/c/passive-components/capacitors/capacitor-arrays

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube