Servo vibration issue

Hello!!! ummm? can someone help with this weird servo related issue? So the first two front servos vibrate very much during the "animation", and the two at the back don't have a same issue(they are attached the same with the same screws). Is it a code or servo issue?(if yes I will have to buy new ones[sg90 servos])

code:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#define SERVO_FREQ 50
//AXLE SETTINGS
#define START_POSITON_AXLE 300
#define AXLE_POSITON_CHANGE 320
#define AXLE_POSITON_CHANGE_a 280
//LEG SETTINGS
#define START_POSITON_LEG 450
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

uint8_t servonum = 0; 

void setup(){
  Serial.begin(9600);
  pwm.begin();
  pwm.setOscillatorFrequency(27000000);
  pwm.setPWMFreq(SERVO_FREQ);
  delay(10);
  startAxle();
  startLegs();
}

void loop(){
  axelMovament_a();
  delay(750);
  axelMovament_b();
  delay(750);
}

void axelMovament_a(){
  for(uint16_t pulselen = START_POSITON_AXLE; pulselen > AXLE_POSITON_CHANGE_a; pulselen--){
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(3, 0, pulselen);  
  }
  delay(250);
  for(uint16_t pulselen = AXLE_POSITON_CHANGE_a; pulselen < START_POSITON_AXLE; pulselen++){
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(3, 0, pulselen);  
  }
  delay(250);
}

void axelMovament_b(){
  for(uint16_t pulselen = START_POSITON_AXLE; pulselen < AXLE_POSITON_CHANGE; pulselen++){
    pwm.setPWM(1, 0, pulselen);
    pwm.setPWM(2, 0, pulselen);  
  }
  delay(250);
  for(uint16_t pulselen = AXLE_POSITON_CHANGE; pulselen > START_POSITON_AXLE; pulselen--){
    pwm.setPWM(1, 0, pulselen);
    pwm.setPWM(2, 0, pulselen);  
  }
  delay(250); 
}

void startAxle(){
  pwm.setPWM(0, 0, START_POSITON_AXLE);
  pwm.setPWM(1, 0, START_POSITON_AXLE);
  pwm.setPWM(2, 0, START_POSITON_AXLE);
  pwm.setPWM(3, 0, START_POSITON_AXLE); 
}

void setServoPulse(uint8_t n, double pulse) {
  double pulselength;
  
  pulselength = 1000000;   //1,000,000 us per second
  pulselength /= SERVO_FREQ;   //Analog servos run at ~60 Hz updates
  Serial.print(pulselength); Serial.println(" us per period"); 
  pulselength /= 4096;  //12 bits of resolution
  Serial.print(pulselength); Serial.println(" us per bit"); 
  pulse *= 1000000;  //convert input seconds to us
  pulse /= pulselength;
  Serial.println(pulse);
  pwm.setPWM(n, 0, pulse);
}

video: https://drive.google.com/file/d/11L1OhFrI1hX-o10rUGwQUNQFVaVdZ_Kn/view?usp=sharing

If you swap them, do the same ones still vibrate?

Yes, some of those SG90 servos are quite bad and vibrate a lot when moving, especially when moving slowly.

Hello, so I only have 8 servos, and I'll probably buy 3 new ones and then I'll check. I was just wodering if it is a probelm with code or something.

I had one or two servos which vibrated a lot, jumping around on the desk, while others are smooth. That out of a batch of six,

I manually spun the bad ones with the horn back and forth a few times (not recommended unless you are prepared to damage it) and it improved a lot - actually became usable.

1 Like

How are you powering these servos?

I've found servos vibrate with insufficient power. Also, running the servo power through a breadboard or using the MCU's power can cause servo vibrations.

I, also, dumped using plastic geared servos for projects.

Hi,
Can you tell us what/how you are powering your project please?

Can you post a circuit diagram showing power supplies, component names and pin labels?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I would try putting a tiny delay (5 to 15 milliseconds) in the loops to give the servos more time to react to the position change on each step.

post#8 makes a good point.

the time between those 2 commands is not much time for the motor to get to position.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.