Go Down

Topic: Servo SG90 micro movement error! (Read 1 time) previous topic - next topic

andrea080690

Hi everyone, I hope it is the correct section for my problem.

I am trying to move a servo after a fingerprint recognize a finger. I have done it, the problem is that the servo make micro movement, like shake, continuously.
I have used the same servo for another project and it had not this problem. The project were simply, the servo just moved when a button were pressed.


The code I wrote is this:
Code: [Select]

#include "FPS_GT511C3.h"
#include "SoftwareSerial.h" // usata dalla FPS_GT511C3.h
#include "Arduino.h"
#include "Servo.h"

Servo myservo;  // create servo object to control a servo


int pos = 0;    // variable to store the servo position

FPS_GT511C3 fps(8, 7);

void setup() {
  // put your setup code here, to run once:

    Serial.begin(9600);
  delay(100);
  fps.Open();
  fps.SetLED(true);


    myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
//delay (700);

  // put your main code here, to run repeatedly:
  if((fps.IsPressFinger()) == true)
  {

    fps.CaptureFinger (true);         // cattura l'impronta del dito sul sensore e la memorizza nella memoria del sensore stesso. Andrà poi confrontata con il DB per individuare l'id. Restituisce true se la cattura ha successo, false se il sensore è vuoto.
      if (fps.Verify1_1(0) == 0 || fps.Verify1_1(1) == 0 || fps.Verify1_1(2)== 0 || fps.Verify1_1(3)== 0 || fps.Verify1_1(4)== 0 || fps.Verify1_1(5)== 0 || fps.Verify1_1(6)== 0 || fps.Verify1_1(7)== 0 || fps.Verify1_1(8)== 0 || fps.Verify1_1(9)== 0 || fps.Verify1_1(10)== 0 || fps.Verify1_1(11)== 0 || fps.Verify1_1(12)== 0 || fps.Verify1_1(13)== 0 || fps.Verify1_1(14)== 0 || fps.Verify1_1(15)== 0 || fps.Verify1_1(16)== 0 || fps.Verify1_1(17)== 0 || fps.Verify1_1(18)== 0 || fps.Verify1_1(19)== 0)
      // int Verify1_1(int id): verifica se l'impronta catturata con la funzione CaptureFinger corrisponde all'impronta memorizzata nello slot identificato da id (da 0 a 199). Ritorna: 0 se corrispondono, 1 se la posizione non è valida (id < 0 o id > 199), 2 se l'id non in uso (vuoto), 3 se l'impronta non corrisponde a quella nello slot id
      {

        pos =0;
        myservo.write(pos);              // motore in posizione 0 gradi
        delay (2000);             
        }
   
             pos =75;
              myservo.write(pos);              // motore in posizione 75 gradi
              delay (600);         
  }
         
}



And here you can see what hasppen:


https://youtu.be/vxnQHaX2LfA

skywatch

What power supply are you using?

You need a good one (say 2A or 2000mA) for this type of work. Also, power the servo direct from the supply and not via the arduino.

That should solve your issue! :)

andrea080690

#2
May 27, 2017, 01:12 pm Last Edit: May 27, 2017, 01:19 pm by andrea080690
Thank you for the answere. I am using a 9V power supply for the arduino but just the arduino power supply for the servo and the fingerprint, so probably the problem is this.
In to the servo specifications i saw it use 4.8V, but could I use 9V fot it?
I have tryied with 3 battery of 1.5 V but it does not work correctly.
Or do you know some servo that need less power? Because I would like to use this project just witha battery, one or 2 9V battery or 1, 9V and 3, 1.5V (4.5V totally) for the servo.

slipstick

No 9V is too much for that servo. But 3 x AA batteries should run it. Exactly what type of "3 battery of 1.5V" did you try? They need be able to provide enough current for the servo, it's not just the voltage that counts.

Steve

TomGeorge

Hi,
Quote
I am using a 9V power supply for the arduino but just the arduino power supply for the servo and the fingerprint, so probably the problem is this. 
If you are using the 5V pin of the Arduino to power the sensor ans servo, but supplying 9V to Vin or the DC socket, you are using the on board 5V regulator.
This is a linear regulator and is not designed for load like the servo.
The solution is to provide 5V to the board from a power supply capable of outputting the current for the servo.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

andrea080690

I have used alkaline battery so it should have 2700 mAh, I have also bought 2 battery tipe C (8000 mAh) but the problem is the same, the servo works randomly. When I connect the battery, the servo moves like 10 degree to the left, when I put some finger the servo goes to the right until it block (last position).

andrea080690

Hi,If you are using the 5V pin of the Arduino to power the sensor ans servo, but supplying 9V to Vin or the DC socket, you are using the on board 5V regulator.
This is a linear regulator and is not designed for load like the servo.
The solution is to provide 5V to the board from a power supply capable of outputting the current for the servo.

Tom... :)
Thank you for the answere. I have not an external power supply so I could provide the power with battery. I have tryed to do it with 2 battery type C and 1 type AA but the servo was shaking as well.
How tipe of battery you think are necessary to fix the problem?

andrea080690

I have found 2 battery type D, 2 type C and 4 type AA, I have tryed many combination of this batteries bat with no results. I have tryed as well to use 2 line of 4.5V battery in parallel to have more current but nothing, the servo is still shaking.

slipstick

From all the work you've done it seem not to be a power problem.

I have sometimes had servos that would continually "hunt" when pushed past their normal limits though those TowerPro servos are usually good. But the Servo.h library does write extreme values at the limits. It is also sometimes a specific position on the internal feedback pot that causes the problem so one thing you can try is instead of writing 0 then 75 change it to 50 to 125 or 35 to 110. It will be moving the same amount (75) but starting from different places.

If that does nothing it is probably time to try a different servo.

Steve

andrea080690

I have tryed to change the degrees whit no positive results. It could be an interference problem because I have tryed to disconnect the fingerprint, powered with arduino out as well, and the servo works (with another simple code).

I have tryed as well to power the fingerprint with external power supply (3 batteries) and  the problem is the same, servo shake.

vinceherman

Your video makes me think that you have a timer conflict.  Google 'servo softwareserial conflict'
Consider using servotimer2

andrea080690

#11
May 28, 2017, 08:16 pm Last Edit: May 28, 2017, 08:56 pm by andrea080690
Your video makes me think that you have a timer conflict.  Google 'servo softwareserial conflict'
Consider using servotimer2

I have tryed using the library but with no positive response. The shake is the same. The new code is this:
Code: [Select]

#include "FPS_GT511C3.h"
#include "SoftwareSerial.h" // usata dalla FPS_GT511C3.h
#include "Arduino.h"
#include "ServoTimer2.h"  // the servo library

#define rollPin  9// define the pins for the servos
int pos = 0;    // variable to store the servo position
FPS_GT511C3 fps(8, 7);
ServoTimer2 servoRoll;    // declare variables for up to eight servos

void setup() {
  Serial.begin(9600);
  delay(100);
  fps.Open();
  fps.SetLED(true);
  servoRoll.attach(rollPin);     // attach a pin to the servos and they will start pulsing
}

void loop()
{
  if ((fps.IsPressFinger()) == true)
  {

    fps.CaptureFinger (true);         // cattura l'impronta del dito sul sensore e la memorizza nella memoria del sensore stesso. Andrà poi confrontata con il DB per individuare l'id. Restituisce true se la cattura ha successo, false se il sensore è vuoto.
    if (fps.Verify1_1(0) == 0 || fps.Verify1_1(1) == 0 || fps.Verify1_1(2) == 0 || fps.Verify1_1(3) == 0 || fps.Verify1_1(4) == 0 || fps.Verify1_1(5) == 0 || fps.Verify1_1(6) == 0 || fps.Verify1_1(7) == 0 || fps.Verify1_1(8) == 0 || fps.Verify1_1(9) == 0 || fps.Verify1_1(10) == 0 || fps.Verify1_1(11) == 0 || fps.Verify1_1(12) == 0 || fps.Verify1_1(13) == 0 || fps.Verify1_1(14) == 0 || fps.Verify1_1(15) == 0 || fps.Verify1_1(16) == 0 || fps.Verify1_1(17) == 0 || fps.Verify1_1(18) == 0 || fps.Verify1_1(19) == 0)
      // int Verify1_1(int id): verifica se l'impronta catturata con la funzione CaptureFinger corrisponde all'impronta memorizzata nello slot identificato da id (da 0 a 199). Ritorna: 0 se corrispondono, 1 se la posizione non è valida (id < 0 o id > 199), 2 se l'id non in uso (vuoto), 3 se l'impronta non corrisponde a quella nello slot id
    {
      pos = 20;
      servoRoll.write(pos);              // motore in posizione 0 gradi
      delay (2000);
    }
    pos = 95;
    servoRoll.write(pos);              // motore in posizione 75 gradi
    delay (500);
  }
}

I think the problem is in the comunication conflict. When I disconnect just tx or rx fingerprint the servo stop to shake.

andrea080690

If that does nothing it is probably time to try a different servo.

Steve
Whic kind of servo do you recomend me?

TomGeorge

Hi,
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 picture of  your complete project so we can see your component layout?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

Go Up