0

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:

map(analogRead(A0),0,1023,0,300)

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);

}

potReading = num/25;

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

Joel
  • 155
  • 6

2 Answers2

1

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.

David
  • 420
  • 4
  • 12
  • 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 04: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 have been debugging and realized that there grounds are still connected, how is this possible no ground cable are touching; however both power supplies are plugged into the same power strip. Could that link the grounds? – Joel Jan 19 '15 at 20:52
  • I don't have a spectrum analyzer but the new ADC I bought has ferrites, I think that will solve that problem because it eliminates everything except the ADC. But now I am wondering why the grounds on the Roboclaw and arduino are still connected. – Joel Jan 19 '15 at 20:55
  • Good wall power supplies are isolated, but not all are. You should try measuring the resistance between the ground lines of the two power supplies. – David Jan 19 '15 at 21:24
  • its not registering resistance but they have a voltage difference of .441 I am extremely confuse by this. – Joel Jan 19 '15 at 21:32
  • are they on? also, should we move this to chat? EDIT: Wait, you can't turn wall warts off. Try measuring the resistance between their output ground and input neutral – David Jan 19 '15 at 21:37
  • Let me know if the chokes work. I'm curious to know what the issue is – David Jan 20 '15 at 00:41
0

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.

Joel
  • 155
  • 6