Author Topic: Servo making noise while stationary  (Read 1150 times)

0 Members and 1 Guest are viewing this topic.

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Servo making noise while stationary
« on: June 13, 2022, 09:09:00 pm »
I'm using an HS-311 servo to move some peices in a project and it's making "noise" while stationary. It's a kind of weird jittery sound. It was doing it previously sometimes. Mostly in the "closed" position it would make the noise and if I were to fiddle with the piece a little then it would stop. Now after some changes to the setup it's always making the noise.

Any idea what might be causing the noise? Am I trying to have it hold at a position it doesn't like? Perhaps the timing on my Uno's control signal isn't 100% stable so it's constantly shifting position slightly?
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3479
  • Country: us
Re: Servo making noise while stationary
« Reply #1 on: June 13, 2022, 09:19:40 pm »
Noise at rest is common with digital servos as they hunt for center/zero.  The HS311 is an economy analog servo.  I am not surprised that its "dead zone" leads to some hunting and noise.

When you move it to a position, does it still hunt?  Some of the old analog servo controllers caused such hunting whatever the input.  How are you controlling it?
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5878
  • Country: de
Re: Servo making noise while stationary
« Reply #2 on: June 13, 2022, 09:23:14 pm »
The HS-311 is a standard servo for years and has never made any trouble anywhere.
Three possibilities:
1: you've opened the servo and somehow modified the hysteresis.
2: the servo feedback potentiometer is worn/damaged.
3: your PWM signal to the servo is unstable or wrong frequency.

Dunno what a "Uno" is (except an old Fiat car), so perhaps you could provide a bit more informaton?

 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Servo making noise while stationary
« Reply #3 on: June 13, 2022, 09:45:09 pm »
I'm controlling it from and Arduino Uno microcontroller using pin 5 for the servo's control pin. I have not opened or attempted to modify this servo at all (I think).

I have it wired up to a circuit with a button. When the circuit powers up the servo is moved to the "closed" position. When the button is pressed it toggles between the "open" and "closed" positions. I checked and it's only sending a servo.write() once per button press and it's not sending writes at all when the button is not being pressed.

I have a handful of these so I can swap it out tomorrow and see if another one has the same effect.

I'm running the servo and 10 DotStars off the Uno's 5v pin. Is it possible I'm just not giving the servo enough power and it's struggling?
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5878
  • Country: de
Re: Servo making noise while stationary
« Reply #4 on: June 13, 2022, 09:57:41 pm »
Is it possible I'm just not giving the servo enough power and it's struggling?
Not just possible, rather extremely likely. The servo needs up to 800 mA @ +5 V; when just moving without mechanical load 180 mA. I don't think your "Uno" will supply that.
What exactly are you sending as control signal to the servo?
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Servo making noise while stationary
« Reply #5 on: June 13, 2022, 10:05:02 pm »
OK. I'll try powering the breadboard rail from a wall socket instead of my Uno and see if that helps.

What exactly are you sending as control signal to the servo?
I'm not sure what you mean by this. It's using pin 5 which is a PWM pin on the Uno and the standard Servo.h library.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5878
  • Country: de
Re: Servo making noise while stationary
« Reply #6 on: June 13, 2022, 10:12:24 pm »
I'm not sure what you mean by this. It's using pin 5 which is a PWM pin on the Uno and the standard Servo.h library.
I mean which timing parameters have been set.
Powering from somewhere else is a very good idea. Always keep power and control separate.

« Last Edit: June 13, 2022, 10:14:03 pm by Benta »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Servo making noise while stationary
« Reply #7 on: June 13, 2022, 10:16:46 pm »
I mean which timing parameters have been set.
Since I don't know what you are talking about I'm gonna guess none.

Here's my file. The "LED_CONTROL_PIN" is a pin that powers an LED I put in there for my initial testing so I could have a visual representation of if the circuit thought it was open (i.e. LED on = open)

Code: [Select]
#include <Arduino.h>
#include <Servo.h>

#define LED_CONTROL_PIN 7
#define BUTTON_READ_PIN 6
#define WAVE_PIN 5

boolean pressed = false;
boolean ledOn = false;
boolean waveOpen = false;

Servo myServo;
int plasmaLClosed = 120;
int plasmaLOpen = 80;

void setup()
{
  Serial.begin(9600);
  pinMode(BUTTON_READ_PIN, INPUT);
  pinMode(LED_CONTROL_PIN, OUTPUT);
  digitalWrite(LED_CONTROL_PIN, LOW);
  myServo.attach(WAVE_PIN);
  myServo.write(plasmaLClosed);
}

void loop()
{
  if (shouldSwitch()) {
    pressed = true;
    waveOpen = !waveOpen;
    switchStatus(waveOpen);
  }

  if (digitalRead(BUTTON_READ_PIN) == false) {
    pressed = false;
  }
}

boolean shouldSwitch() {
  if (digitalRead(BUTTON_READ_PIN) == true && pressed == false) {
    return true;
  }
  return false;
}

void switchStatus(boolean waveOpen) {
  if (waveOpen) {
    digitalWrite(LED_CONTROL_PIN, HIGH);
    myServo.write(plasmaLOpen);
  } else {
    digitalWrite(LED_CONTROL_PIN, LOW);
    myServo.write(plasmaLClosed);
  }
}
 

Offline johnboxall

  • Supporter
  • ****
  • Posts: 652
  • Country: au
  • You do nothing, you get nothing.
    • Books, services and more:
Re: Servo making noise while stationary
« Reply #8 on: June 13, 2022, 10:30:05 pm »
Use external 5V power and put a nice capacitor across the power supply rails close to the servo, 470uF would do.

Online Benta

  • Super Contributor
  • ***
  • Posts: 5878
  • Country: de
Re: Servo making noise while stationary
« Reply #9 on: June 13, 2022, 10:44:41 pm »
The HS-311 needs a PWM pulse to operate properly.
This pulse should appear every 20 ms.
For neutral position, the pulse is 1.5 ms wide.
For one end position it is 1.0 ms wide.
For the opposite end position it is 2 ms wide.

Whether your "servo.h" provides this, I don't know, and I certainly won't reverse engineer the "Uno" code.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2256
  • Country: ca
Re: Servo making noise while stationary
« Reply #10 on: June 17, 2022, 05:15:59 pm »
In my experience, analog servos do not make noise when idle, unless torque is applied. Then the motor will need to be active to keep the position, and due to the analog circuits which control the motor, you will hear a buzz at 50 Hz (assuming a 20 ms or 50 Hz servo pulse repeat rate). If the servo is twitchy, then you have either: dirty/noisy power, or a noisy signal. The signal may be noisy due to external electrical/RF noise, or poor quality (not stable) generation of the signal itself.

I just looked at servo.cpp from whatever Arduino version I have here. It uses a single timer interrupt to trigger a digitalWrite() for the servo pulse high/low transitions. This is susceptible to jitter. Basically if the MCU is busy, especially inside another interrupt handler, then this interrupt handler might need to wait, and that can and will result in the servo pulse being +/- at least several microseconds over time.

I built a project for an R/C car which generated two servo outputs using the ATMega328P Timer 1 output compare A and B to generate the two signals, with perfect jitter-free timing. I fiddled with the timer registers directly rather than using a library.
« Last Edit: June 17, 2022, 05:29:31 pm by macboy »
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5878
  • Country: de
Re: Servo making noise while stationary
« Reply #11 on: June 17, 2022, 07:39:46 pm »
I built a project for an R/C car which generated two servo outputs using the ATMega328P Timer 1 output compare A and B to generate the two signals, with perfect jitter-free timing. I fiddled with the timer registers directly rather than using a library.

Which is the way to do it, software/interrupt loops for timing I/O is a no-go.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Servo making noise while stationary
« Reply #12 on: June 19, 2022, 04:09:57 am »
I built a project for an R/C car which generated two servo outputs using the ATMega328P Timer 1 output compare A and B to generate the two signals, with perfect jitter-free timing. I fiddled with the timer registers directly rather than using a library.

Do you have a code sample for this? I'd love to see it and see if I can modify it for my use to find out if it resolves the issue.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf