Author Topic: decoupling capacitors for encoder  (Read 2586 times)

0 Members and 1 Guest are viewing this topic.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 10
decoupling capacitors for encoder
« on: October 30, 2014, 11:58:33 AM »
Hi all,

I'm working on an encoder-to-arduino interface.  I have arduino Unos, which means that its two interrupt pins are right next to each other.  I am using a quadrature encoder with 200 counts per revolution, rotating at around 200 rpm.  This is apparently *really* fast for an arduino (40K interrupts per second) especially when also using serial.  My arduino tends to crap out (it freezes and serial is not longer sent), and this problem occurs arbitrarily (it may happen in one second of turning it on, it may take a full minute). 

I've soldered a decoupling cap. between the two interrupt pins and this *appears* to fix the problem, but I'm not sure if the problem actually got fixed or if I just magically happened to get it to work for a few days and it will fail again.  Does it make any sense at all that a capacitor between two digital pins that are beside each other and toggling rapidly would help?  Would that setup (without the cap) be a recipe for killing the circuit, or could it be something else?

Mike
Current project: tactile sensing systems for multifingered robot hands

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: decoupling capacitors for encoder
« Reply #1 on: October 30, 2014, 12:48:49 PM »
If the encoder signals have noise then the cap would help buut a cap on each line to it common (ground?) line would typically be better.
How long are the lines to the encoders?
Are they in a noisy environment (attached to motors)?

Are you running the Atmega's UART for serial or using 'soft serial"?
I would use the UART and write interrupt driven UART routines so that the processor runs as little code as possible for serial.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 10
Re: decoupling capacitors for encoder
« Reply #2 on: October 31, 2014, 09:38:29 AM »
Good suggestions.  A cap between the two lines (and another try with a cap to ground) helped, but it turns out that the problem wasn't the interrupts at all.  The circuit was connected to motors and the motors were giving HUGE voltage spikes into the arduino (hence why the caps helped, I assume that the encoder signals weren't the issue).  However, curiously, once the motor was put onto another circuit (but was still in close proximity to everything else), the spikes remained.  Could this be RF interference or is it more likely to be a wayward wire shorting something out?

Mike
Current project: tactile sensing systems for multifingered robot hands

Offline Billy

  • Robot Overlord
  • ****
  • Posts: 132
  • Helpful? 2
Re: decoupling capacitors for encoder
« Reply #3 on: November 01, 2014, 04:10:47 PM »
Could this be RF interference or is it more likely to be a wayward wire shorting something out?

It could easily be RF (likely is) and it may or may not still be on the encoder lines. It could just as easily be coupled directly on to your scope probes. Put a cap across the motor terminals to limit the RF generated at the motor. A small one like 0.01uf ceramic rated for double the voltage of the motor voltage. If possible, ground the case of the motor as well.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 10
Re: decoupling capacitors for encoder
« Reply #4 on: November 01, 2014, 08:14:33 PM »
Your post brought up some big questions I've had for a while.  I'm putting them in another thread, since I think it goes far beyond the original question.  Thanks for the insight!
Current project: tactile sensing systems for multifingered robot hands