# Eliminating Electrical Noise from my motor driver

Background:

I am using an Arduino Mega connected to a RoboClaw 2x60A motor driver. I asked this question about the system, but I have since narrowed the scope of the problem. I tried adding a bunch of different size capacitor between the 5v and gnd, when the RoboClaw is switched off then a 470 micro farad capacitor seems to eliminate all noise but when I turn on the RoboClaw no capacitance valued I tried, (4.7,10,100,220,320,470,540,690,1000,1100)microfarads seems to eliminate any noise. I even tried hooking up a 12v battery with a 5v regulator to the logic battery on the RoboClaw and connecting it to the ground on the Arduino. Then I tried using a separate battery for the pots and connecting the AREF to the +5v on the battery.
No matter what I try when the roboclaw is on the potentiometer value will vary as much as +-6 degrees. I found the degrees using:

In addition I took a bunch of data and graphed it and found that if I took 25 instantaneous data points and averaged them together it would help significantly reduce the variance. I chose 25 because it take 2.9 ms, 100 worked really well but it took 11 ms. To help explain the averageing of analog read, here is my code:

unsigned int num = 0;

for (int i = 0; i<25; i++){

num+=analogRead(A0);


}

My Question:

What is my next step in eliminating this noise? Is there a formula I can use to find a better capacitance value? Should I try putting capacitors on each potentiometer between 5V and gnd? Any other IC I should try to help with this? On my previous question someone mentioned optocouplers, what size would work best and where in the circuit do they go? Is there code I can write to help eliminate the size of the variance beyond what I have written?

Thanks so much for any help, Joel

First off, you should probably replace all electrical connections between the motor driver and other circuitry with optocouplers (I hope you aren't using the analog interface). Then, make sure that the power supplies are completely isolated. You should probably keep the grounds tied together with a 500k or one meg resistor the keep them form varying hugely.

If you still get problems you could try shielding the motor driver and cables. I've never had rf interference problems with arduino(s), but it might be worth a try.

Also, if nothing else, make sure that the power cables aren't daisy-chained. If you have to drive them off the same battery, make sure that you are using a star configuration. You should also probably try a ferrite choke on the power supply line if you don't separate the power supplies.

• I just picked up a few 4n35 optocouplers I will use them for the slave select and for the main tx line. Why do I need to keep the grounds tied together if the circuits never interact? – Joel Jan 19 '15 at 4:33
• I used optocouplers and a .1uf ceramic cap between gnd and the input to analog read. The noise is still there, it used to stop when I unplugged the motor driver, but the motor driver is isolated. the noise is decrease ever so slightly but it is still +- 4 degrees which I cannot use for position feedback – Joel Jan 19 '15 at 19:25
• You want the grounds tied together by the meg resistor so that you don't get kilovolt differences between the circuits. It's for ESD safety. How are you powering the two boards? – David Jan 19 '15 at 20:47
• I am powering the RoboClaw from 2 12v power sources and the arduino from a wall wart to barrel jack cable. – Joel Jan 19 '15 at 20:50
• You should also probably try a ferrite choke on the analog read line as well. I don't suppose you have a spectrum analyzer handy? – David Jan 19 '15 at 20:50

I bought this ADC breakout board I will use a battery for this and put optocouplers on the i2c lines to completely separate the ADC circuit from the rest of the circuits. And it gives me a little better resolution on the potentiometers.

• The ADC board comes thursday in the mail so on friday I will know if this works – Joel Jan 19 '15 at 20:03