Motor noise causing arduino reset with fully isolated power supplies.

Alright, I am having extreme difficulties with this circuit. A drawing of the circuit is given below, but, in a nutshell, I can't seem to power two 5v motors without the arduino resetting.

  • The Arduino is powered from a 9V or USB power supply.
  • The motors are powered from a x4 AA battery supply.
  • The Arduino and motors are physically separated by an optocoupler so the arduino and motors do not share a ground either.
  • I have used basic diode protection and a capacitor across the motors, though this shouldn't matter because of the optocoupler.
  • Whenever I engage ports from the arduino via serial connection, the motors engage, the arduino resets a bunch of times and then becomes unresponsive until I restart the controller.

Other Note: The arduino is in very close proximity to the motors. Could the motors be causing voltage fluctuations in the arduino PCB due to magnetic/electrical field fluctuations from the motor?

What am I doing wrong?

Hi and welcome.

While starting (resetting), pins 3 and 5 might be undefined.
Maybe some (strong) pull down resistors will help.
Your drawing doesn't help too much, sorry.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a complete copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Your circuit is very low in contrast and hard to make out a lot of components.
In the bottom left is that a RC receiver you have hooked to the arduino?
Is the gnd of the receiver connected to the arduino gnd?
When you activate the monitor on the IDE the controller will RESET, this is normal, but the sketch should then run.

Tom.... :slight_smile:

malaxtom:
Other Note: The arduino is in very close proximity to the motors. Could the motors be causing voltage fluctuations in the arduino PCB due to magnetic/electrical field fluctuations from the motor?

Undoubtedly this is the major problem. If you can't avoid proximity you will need shielding.

Here is an updated circuit diagram, hopefully a little easier to read. Moving the motors away from the arduino does not appear to help the problem.

Also, here is my sketch.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.setTimeout(1000);
  Serial.print("READY\n");

}

void clearSerial()
{
  while(Serial.available())
  {
    Serial.read();
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  while(Serial.available())
  {
  delay(30);
  int command1 = Serial.parseInt();
  if(command1 == 1)
  {
    Serial.println("Motor 1");
    int mspeed = Serial.parseInt();
    if(mspeed <= 255 && mspeed >=0)
    {
      Serial.println(mspeed);
      clearSerial();
      analogWrite(3,mspeed);
    }
    else{
      Serial.println("INVALID SPEED ENTRY");
      clearSerial();
    }
  }
   else if(command1 == 2)
  {
    Serial.println("Motor 2");
    int mspeed = Serial.parseInt();
    if(mspeed <= 255 && mspeed >=0)
    {
      Serial.println(mspeed);
      clearSerial();
      analogWrite(5,mspeed);
    }
    else{
      Serial.println("INVALID SPEED ENTRY");
      clearSerial();
    }
  }
  else
  {
    Serial.println("Initial Command Error");
    clearSerial();
  }
  }
}

That circuit doesn't show the serial connection(s).

Sorry, the serial connection is through the on board usb port.

Hi,
What is the Rx unit that you have powered off the 3.3V from the UNO?

Have you measured the 9V as this problem occurs.
A 9V PP3 battery will not be able to do the job reliably, add 100uF cap across the battery but consider a bigger supply.

Does this happen when you are powered from the USB port.

Tom.... :slight_smile:
Please a picture of your project thanks.

You suspect motor noise. Disconnect the motors, and see if you still have a problem. Run the same script.

Did you add extra capacitors around (on the power rail) yet?

The RC unit is the NRF24L01+. I have tried changing the power supply. I have powered it by 9V, 4 6V AA, and both 9v and USB, all to no avail. Disconnecting the motors fixes the problem completely and there are no hiccups. I have capacitors around the rail. The point here though is that the motors and arduino are NOT ON THE SAME CIRCUIT. Please excuse my yelling. They are on completely separate circuits with separate power supplies and separate grounds. The arduino controls the motors through an LED physically next to a phototransistor (inside an optocoupler package).

"They are on completely separate circuits with separate power supplies and separate grounds"

Maybe that is the key. Would it be safe to connect the grounds (common ground) ?