1
\$\begingroup\$

Every time I boot up the board (DFRobot Bluno) the servos start moving without me telling them to. Earlier, it worked perfectly fine but since then, I've change the electronics set up a little bit and now they just go crazy and the only way to stop them moving is to cut the power. The only thing I changed in the setup is the power cables but then I changed them back and the issue persists. See the code below.

This video shows it working fine: https://www.youtube.com/watch?v=zqP4QKaJYns

// Libraries 
#include <Servo.h> 
String command;
// Create a servo object 
Servo ServoHead, ServoRightShoulder, ServoLeftShoulder, ServoLeftLeg, ServoRightLeg, ServoRightFoot, ServoLeftArm, ServoLeftFoot, ServoRightArm;

int servoPin5 = 5;
int servoPin6 = 6;
int servoPin7 = 7;
int servoPin8 = 8;
int servoPin9 = 9; 
int servoPin10 = 10;
int servoPin11= 11;
int servoPin12 = 12;
int servoPin13 = 13;

void setup() { 
   Serial.begin(9600); 
   Serial.println("What part would you like to move?");
   // Attatch servos to pins 
   ServoHead.attach(servoPin10);
   ServoRightShoulder.attach(servoPin8); 
   ServoLeftShoulder.attach(servoPin7);
   ServoLeftLeg.attach(servoPin6); 
   ServoRightLeg.attach(servoPin12); 
   ServoLeftArm.attach(servoPin9);
   ServoRightFoot.attach(servoPin13); 
   ServoLeftFoot.attach(servoPin5);
   ServoRightArm.attach(servoPin11);
   delay(1000);
}
char rx_byte = 0;
String rx_str = "";

void loop(){ 

  ServoHead.write(90);
  ServoRightShoulder.write(0);
  ServoLeftShoulder.write(0);
  ServoRightArm.write(90);
  ServoLeftArm.write(90);
  ServoRightFoot.write(90);
  ServoLeftFoot.write(90);
  ServoRightLeg.write(90);
  ServoLeftLeg.write(90);
  delay(1000);
  
  {
    if(Serial.available() > 0){ //is a character available?
      rx_byte = Serial.read(); //get the character

        if (rx_byte != '/n') { // a character fo the string was received
          rx_str += rx_byte;
        }
          if (rx_str.equals ("Head")){
              Serial.print("Moving ");
              Serial.println(rx_str);
              
              ServoHead.write(90);
              delay(1000);
              ServoHead.write(180);
              delay(1000);              
              ServoHead.write(90);
              delay(1000);
              ServoHead.write(0);
              delay(1000);              
              ServoHead.write(90);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("RightShoulder")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoRightShoulder.write(0);
              delay(1000);
              ServoRightShoulder.write(180);
              delay(1000);
              ServoRightShoulder.write(0);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("LeftShoulder")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoLeftShoulder.write(0);
              delay(1000);
              ServoLeftShoulder.write(180);
              delay(1000);
              ServoLeftShoulder.write(0);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("RightArm")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoRightArm.write(90);
              delay(1000);
              ServoRightArm.write(180);
              delay(1000);
              ServoRightArm.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("LeftArm")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoLeftArm.write(90);
              delay(1000);
              ServoLeftArm.write(0);
              delay(1000);
              ServoLeftArm.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("RightFoot")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoRightFoot.write(90);
              delay(1000);
              ServoRightFoot.write(135);
              delay(1000);
              ServoRightFoot.write(90);
              delay(1000);
              ServoRightFoot.write(45);
              delay(1000);
              ServoRightFoot.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("LeftFoot")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoLeftFoot.write(90);
              delay(1000);
              ServoLeftFoot.write(45);
              delay(1000);
              ServoLeftFoot.write(90);
              delay(1000);
              ServoLeftFoot.write(135);
              delay(1000);
              ServoLeftFoot.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("RightLeg")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoRightLeg.write(90);
              delay(1000);
              ServoRightLeg.write(180);
              delay(1000);
              ServoRightLeg.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
          else if (rx_str.equals ("LeftLeg")){
              Serial.print("Moving ");
              Serial.println(rx_str);

              ServoLeftLeg.write(90);
              delay(1000);
              ServoLeftLeg.write(0);
              delay(1000);
              ServoLeftLeg.write(90);
              delay(1000);
              
              rx_str = "";
              Serial.println("");
              Serial.println("What part would you like to move?");
          }
     
        
    }
  }
  }

enter image description here

The set up is simple really, just the yellow gpio pin going to pin 13 and the +ve and -ve wires to a 10W wall adapter.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ What did you change in the wiring? Are you sure you changed it back exactly? \$\endgroup\$
    – JRE
    Commented Aug 24, 2020 at 20:32
  • 2
    \$\begingroup\$ Where's the wiring diagram and the photo? \$\endgroup\$
    – Transistor
    Commented Aug 24, 2020 at 20:34
  • 1
    \$\begingroup\$ Not exactly, before I had all of the servos connected in a parallel circuit, now im trying with just one servo. But I tried on another servo and same issue. Maybe its some sort of signal problem? I read a but about input floats but cant make much sense of it. Its like the servo is constantly receiving input telling it to move. \$\endgroup\$
    – user255652
    Commented Aug 24, 2020 at 20:36

3 Answers 3

2
\$\begingroup\$

The video doesn't show any details of the wiring. Most likely you have lost the ground connection between your controller and the servo actuators.

  • Check for ground (0 V) continuity between the controller, PSU and servo actuators. It should be less than a couple of ohms.
  • Measure the voltage between the servo grounds and your controller grounds while "going crazy". It should be 0 V.

If either of these show a fault then start tracing ...

\$\endgroup\$
1
  • \$\begingroup\$ Hi, thanks for the answer. Unfortunately I don’t have a voltmeter or anything to measure the resistance. (Haven’t been at this for too long). Is there any other way to test what you’re suggesting? \$\endgroup\$
    – user255652
    Commented Aug 25, 2020 at 7:24
2
\$\begingroup\$

Solved!

Turns out I should've been grounding the input of power to the board as well as the servo.

Thank you all for your responses.

\$\endgroup\$
1
\$\begingroup\$

I have experienced this before, but can't remember how I fixed the problem. Few things that come to mind are:

  1. Check your power supply (looks like your using 2S lipo). Those servos take 6V input. If the supply voltage drop below 6, they get confused and start to play up.
  2. You have got way too many jumper wires to breadboard, you are just inviting problems. Check if your Arduino is supplying 5V to the signal line on the servo. Sometimes, because of these jumper wires, even though the pin goes into the socket all the way, it still may be a loose connection and again the servo will get confused and run for no reason.
  3. I have seen with those cheap 9g (blue) servos, they like to break easily and so 180 degree servos can turn into 360 if they are not well cared for. so you can troubleshoot the motors that are giving problems, rather than troubleshooting the system as one.
\$\endgroup\$
3
  • \$\begingroup\$ Hi, I think you miss understood me. The video is from earlier and shows it working as it should. Its the image, with just one servo and the yellow, green and purple wires that doesn’t work with a supply of 10W through a wall adapter. \$\endgroup\$
    – user255652
    Commented Aug 25, 2020 at 7:16
  • \$\begingroup\$ @beatriz, my bad. I recommend you do some testing with multimeter and check the voltages on pin 14. \$\endgroup\$ Commented Aug 25, 2020 at 7:26
  • \$\begingroup\$ Check EMI from all sources and ground it \$\endgroup\$ Commented Aug 25, 2020 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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