My servomotor is out of order

Hello,
I trying to do a project for school, it is a bench test, everything works fine but my servomotor break down and it's the second I bought.

#include <Servo.h>

// crée l’objet pour contrôler le servomoteur
Servo monservo;

// constantes ne change pas. Elles sont utilisées pour donner les pins:
const int BoutonD = 12; //le numéro de la pin du bouton départ
const int BoutonR = 10; //le numéro de la pin du bouton RAZ
const int LedF = 2; //le numéro de la pin de la Led fin de cycle
const int LedV = 6;//le numéro de la pin de la Led verte
const int LedJ = 7;//le numéro de la pin de la Led jaune
const int LedR = 3;//le numéro de la pin de la Led rouge
const int ReedV = 4;//le numéro de la pin du capteur REED vert
const int ReedJ = 5;//le numéro de la pin du capteur REED jaune

// les variables vont changées :
int etatBoutonD = 0;//état du bouton de départ
int etatBoutonR = 0;//état du bouton de RAZ
int etatReedV = 0;//état du capteur reed vert
int etatReedJ = 0;//état du capteur reed jaune
int pos = 0;//variable pour stocker la position du servomoteur


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup() {



  // initiliser les LEDs en tant que sortie :
  pinMode(LedF, OUTPUT);
  pinMode(LedV, OUTPUT);
  pinMode(LedJ, OUTPUT);
  pinMode(LedR, OUTPUT);

  //initiliser les boutons en tant que entrer :
  pinMode(BoutonD, INPUT);
  pinMode(BoutonR, INPUT);

  //capteur Reed en tant qu'entrer :
  pinMode(ReedV, INPUT_PULLUP);
  pinMode(ReedJ, INPUT_PULLUP);


  //initialisation du servomoteur
  monservo.attach(9);  // utilise la broche 9 pour le contrôle du servomoteur
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void loop() {

  //Contrôle du reed jaune avant cycle (détection capteur bloqué fermé)
  { etatReedJ = digitalRead(ReedJ);
    if (etatReedJ == LOW) {
      digitalWrite(LedR, HIGH);
    }
  }
  //Contrôle du reed vert avant cycle (détection capteur bloqué fermé)
  { etatReedV = digitalRead(ReedV);
    if (etatReedV == LOW) {
      digitalWrite(LedR, HIGH);
    }
  }

  //Lit la broche d'entrée du bouton départ
  etatBoutonD = digitalRead(BoutonD);

  //Si le bouton est HIGH alors...
  if (etatBoutonD == HIGH) {

    //Demande au servo de se déplacer à ... puis attendre ...
    for (pos = 0; pos < 135; pos += 1);
    {
      monservo.write(pos);
      delay(500);
    }

    //Contrôle du capteur reed vert, on lit la broche puis si elle est LOW alors on allume la Led verte sinon on éteind
    { etatReedV = digitalRead(ReedV);
      if (etatReedV == LOW) {
        digitalWrite(LedV, HIGH);
      } else {
        digitalWrite(LedR, HIGH);
      }
    }

    //Demande au servo de se déplacer à ... puis attendre ...
    for (pos = 135; pos >= 5; pos -= 1)
    { monservo.write(pos);
      delay(20);
    }

    //Contrôle du capteur reed jaune, on lis la broche puis si elle est LOW alors on allume la Led verte sinon on éteind
    { etatReedJ = digitalRead(ReedJ);
      if (etatReedJ == LOW) {
        digitalWrite(LedJ, HIGH);
      } else {
        digitalWrite(LedR, HIGH);
      }
    }

    //Demande au servo de se déplacer à ... puis attendre ...
    delay(500);
    monservo.write(80); // demande au servo de se déplacer à cette position
    delay(200); // attend 1000 ms entre changement de position

    //Allumer la led de fin de cycle
    digitalWrite(LedF, HIGH); //Allumer la Led en fin de cycle
  }


  // lire l'état du bouton RAZ
  { etatBoutonR = digitalRead(BoutonR);

    //Si le bouton RAZ est HIGH alors éteind les leds
    if (etatBoutonR == HIGH) {
      digitalWrite(LedF, LOW);
      digitalWrite(LedV, LOW);
      digitalWrite(LedJ, LOW);
      digitalWrite(LedR, LOW);
    }
  }
}

This is my code and the electrical schematic
Schematic_banc test_2023-07-24-3.pdf (42,9 Ko)

Somebody can help me for find the thing who break my servomotor, please ?

PS : When I say break down, the servomotor just turn all time

What’s your +5Vcc power supply?

Also many forum members prefer the schematic to be inserted inline as a graphic.

I use an adaptor AC/DC
Input 100-240VAC - 50/60Hz

Output 12V 1A

Looks good .
What’s changed, and why do you think the servo has died since it first worked ?

1 Like

The servomotor is an SG90 from the Tower PRO brand, it is normally clamped at 180° but now it rotates continuously without ever stopping as soon as I plug it in. :sweat:

Are you sure that you have a servo and not a so called "continuous rotation servo" ?

You can control the angle of the former but only the speed and direction of the latter

Did it ever behave in the way that you expect

I'm almost sure it's a 180° servo and not a continuous rotation one, and yes it has already worked correctly many times during the testing phase.

I searched a bit on the forum and people have already encountered the problem, the solution was that a defective servo

It would be interesting to know what happens when you run the Servo library Sweep example using the suspect servo

It's likely defective now. I've found with the 'Tower Pro' and similar el-cheapo servos that keeping them in a very restrictive range(e.g. not 0 to 180, but 30 to 150), and limiting the amount of force at those endpoints is critical to keeping them working.
They're garbage out-of-the-box.

What servomotor could I use ?

When I run Sweep, the servomotor rotates continuously, slow and stop and again rotates slow and stop.
But it heats up very quickly

Hello nat_bc

Some time ago I had a delivery of faulty SG90 servos with the described behaviour. I was able to send them all back.

Your schematic does not really show how the power-supply is connected to the servo.
And the schematic has no numbers that would say what the supply-voltage is.

Are you supplying the servos with 12V?
This is is a way too high voltage. Standard-servos need a power-supply of 5V.
12V is more than double than 5V and will damage a 5V-servo.

If you drove your servo to the mechanical endstops with 12V it might be that the internal potentiometer is broken caused by the high force that you create through the 12V and now the servo is rotating continiously.

best regards Stefan

The SG90 is a DC motor with a circuit card and gearbox creating the servo motion. The gearbox has uncoupled. Take it apart and refurbish it.

[edit]
You are using an Arduino to power 4 LEDs at full power and a servo. Consider using external power for the servo, like is required by the MG996R.

Hello,
No, I do not power my servos with 12V but with the 5V from the Arduino.
But I power my arduino with 12V

Being a beginner in electronics and not having much time left to finish my project, I would prefer to buy a new one given its very low price.

What do your mean by an external power supply?

Anything except the Arduino itself. Something like 6 AA cells, for instance

1 Like

Can the servo break because of my 12V power supply on the arduino ?

No, but the Arduino can break because of the total current drain of the servo and LEDs on the 5V output of the Arduino.

Leds will never all shine more than 1min, because they are just here to know if the REED captor work,
But I don't have the space to put an external supply in my project, what can I do to fix this problem ?