I am using a 2WD mobile robot platform with two dc motors with optical encoders for reading speed. The arduino website and rbbotshop website from where I bought the encoders and motors from, both contains the encoder code which uses CHANGE external interrupt. Unfortunately, the motor movement causes magnetic field which causes electrical noise in interrupt line. I checked with an oscilloscope and the noise seems very low in amplitude but is frequently occurring. For the CHANGE interrupt, even a low change from noise will cause the interrupt to fire which is causing my encoder to read wrong values when the motor is running. The encoders work perfectly when the motor is not running.
I am using Arduino Motor shield V3 and used both Arduino Uno and Arduino Due. I tried using capacitors, but the noise still didn't eliminate. What I don't understand is how come this problem is not faced by other people? If so, why is the solution not posted in arduino website? If it posts the encoder code using interrupts, they must have tested that code working with running motor. Encoders are no use if it does not work when the motor is running. I have been searching online for about a month and there is no mention of people facing the same problem and there is no mention of this problem in any website. How do people not have the same noise problem when they are using the same Arduino shield V3 and same motors? If anyone can help me with some advice, it will be really appreciated.