4
\$\begingroup\$

This is my first attempt to work with a servo and I'm using this tutorial. I have a "TowardPro MG996R DIGI HI TORQUE" servo directly connected to my Arduino Uno as follows:

Servo connected to Arduino

I also created the following code to upload onto the Arduino:

#include<Servo.h>

Servo myservo;
int servoPin=9;

void setup(){
  myservo.attach(servoPin);
}

void loop(){
  for (int i=0; i>= 20; i+=20){ // increment by 20 degrees
    myservo.write(i); 
    delay(1000);
  }
}

After hooking up the servo wires to the Arduino (unpowered), I then hooked up the USB power source to my Mac computer (no code uploaded yet). However when I did this, I noticed a very strange reaction:

  1. The servo motor instantly started rotating in small increments about once every second or so, like a pulsing.

  2. The message "A new network interface has been detected" keeps popping up and closing at the same frequency as the servo's motor.

  3. The periodically appearing message prevented me from uploading my code onto the Arduino.

Of course, I thought something was wrong and promptly tried to disconnect the power source and reconnect it several times with no improvement. So, I tried the following steps:

  1. Disconnect the USB power to the Arduino.
  2. Disconnect the servo wires from the Arduino.
  3. Reconnect the power usb to the Arduino.
  4. Upload the code.
  5. Disconnect USB power source.
  6. Reconnect servo wires to the Arduino.
  7. Reconnect the USB power source.

Now, I'm having the following problem:

  1. The servo motor does not rotate.
  2. A hissing noise is coming from the servo.
  3. The message "A new network interface has been connected" does not appear.
  4. My computer does not recognize anything at all connected to the usb port where the Arduino is connected to.

At this point, I have no idea what the problem is or how to fix it. Any help to understand where I went wrong and how to remedy it would be greatly appreciated.

\$\endgroup\$
  • \$\begingroup\$ What is in servo.h and probably the associated C file? \$\endgroup\$ – Matt Young Dec 15 '13 at 2:49
  • \$\begingroup\$ @MattYoung: See this header file \$\endgroup\$ – Paul Dec 15 '13 at 2:52
  • \$\begingroup\$ I'd try shutting down the PC and physically removing power for 10 seconds or so. I used to have a motherboard and when it detected an overcurrent condition (probably what has happened here) that was the only thing that would clear it. \$\endgroup\$ – PeterJ Dec 15 '13 at 2:56
  • \$\begingroup\$ "High torque" implies high power. Once your USB port cools off, supply external power to the Arduino or servo. \$\endgroup\$ – Ignacio Vazquez-Abrams Dec 15 '13 at 3:47
  • 4
    \$\begingroup\$ Don't run motors / servo's from you USB. They draw too much current and induce noise on the power supply lines. Your USB host may cut off one or more ports when this happens. \$\endgroup\$ – jippie Dec 15 '13 at 7:19
5
\$\begingroup\$

Your servo may behave erratically, and you may find that this only happens when the Arduino is plugged into certain USB ports. This is because the servo draws quite a lot of power, especially as the motor is starting up, and this sudden high demand can be enough to drop the voltage on the Arduino board, so that it resets itself.

If this happens, then you can usually cure it by adding a high value capacitor (470μF or greater) between GND and 5V on the breadboard

http://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves

As others have commented, if your servo requires more current than the Arduino (or your USB port) can supply, you should provide a separate power connection for the servo.

Your USB port may be limited to 100mA or to 500mA, the Arduino may be able to provide slightly more current at 5V if it is connected to a power source through the barrel-jack connector. It depends on the specifications of the 5V regulator on your particular Arduino (or clone).

If you power the Arduino from a regulated 5V supply, you can draw higher currents from the VIN socket.

I note that some retailers of your servo suggest it be used with a motor controller board.

\$\endgroup\$
  • \$\begingroup\$ I tried to fix the problem using a 470 microFarad and a 1000microFarad capacitor between ground and 5v, but this did not work. I then tried to connect the servo to a separate power source with the sensor wire connected to pin 9 on the arduino. This remedied my problem. \$\endgroup\$ – Paul Dec 20 '13 at 21:11
1
\$\begingroup\$

I tried to run the servo with the arduino connected to the PC and had the same issue as you, the servo drains a lot of power and work erratically

I bought a proto board with a power supply (2 outputs: 3.3v or 5v each). If I connected the circuit in one output, it didn't work, then I connect each one in different output and worked like a charm!

\$\endgroup\$
0
\$\begingroup\$
    void loop(){
  for (int i=0; i>= 20; i+=20){ // increment by 20 degrees
    myservo.write(i); 
    delay(1000);
  }

Need to be corrected as follows:

void loop(){
  for (int i=0; i <= 200; i+=20){ // increment by 20 degrees
    myservo.write(i); 
    delay(1000);
  }
\$\endgroup\$
  • 1
    \$\begingroup\$ Actually both are wrong; however this cannot explain the observed behavior. The fundamental problem is not with the code, but with the fact that servos should not be powered from Arduinos or USB ports. \$\endgroup\$ – Chris Stratton Aug 25 '18 at 1:43
-2
\$\begingroup\$

Sorry for the bump but I solved this in a different way.

You can avoid all that by uploading your sketch BEFORE hooking up your servo.

I had this problem while working through the Arduino Starter Kit on the servo projects.

Although while working on my robot today, I forgot unhook the external power supply (4 rechargeable AA - 4.8V) before plugging into my Windows PC computer's USB2.0 and seem to have messed it up. The Arduino Uno works if plugged into a USB-to-wallwart, but not if I plug it into my computer as before. The computer detects it but cannot recognized it.

Perhaps I need to reinstall some drivers on my computer. 8.1 I tell ya.

Good luck to anyone with this problem and doesn't want to do one of the other solutions!

\$\endgroup\$
  • 4
    \$\begingroup\$ While your answer will enable the OP to upload their code, I believe that they will still have the same issue, once the servo is connected, namely, the USB port, alone, can not supply enough power. \$\endgroup\$ – Greenonline Aug 27 '15 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.