Servo making noise while stationary - Page 1
Forum section: electronics / beginners

author: Youkai
author_rank: Regular Contributor
timestamp: June 13, 2022, 09:09:00 pm
content: 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?

author: jpanhalt
author_rank: Super Contributor
timestamp: June 13, 2022, 09:19:40 pm
content: 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?

author: Benta
author_rank: Super Contributor
timestamp: June 13, 2022, 09:23:14 pm
content: 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?

author: Youkai
author_rank: Regular Contributor
timestamp: June 13, 2022, 09:45:09 pm
content: 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?

author: Benta
author_rank: Super Contributor
timestamp: June 13, 2022, 09:57:41 pm
content: Quote from: Youkai on June 13, 2022, 09:45:09 pmNot 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?

author: Youkai
author_rank: Regular Contributor
timestamp: June 13, 2022, 10:05:02 pm
content: OK. I'll try powering the breadboard rail from a wall socket instead of my Uno and see if that helps.Quote from: Benta on June 13, 2022, 09:57:41 pmI'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.

author: Benta
author_rank: Super Contributor
timestamp: June 13, 2022, 10:12:24 pm
content: Quote from: Youkai on June 13, 2022, 10:05:02 pmI mean which timing parameters have been set.Powering from somewhere else is a very good idea. Always keep power and control separate.

author: Youkai
author_rank: Regular Contributor
timestamp: June 13, 2022, 10:16:46 pm
content: Quote from: Benta on June 13, 2022, 10:12:24 pmSince 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:#include <Arduino.h>#include <Servo.h>#define LED_CONTROL_PIN 7#define BUTTON_READ_PIN 6#define WAVE_PIN 5boolean 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);}}

author: johnboxall
author_rank: Unknown
timestamp: June 13, 2022, 10:30:05 pm
content: Use external 5V power and put a nice capacitor across the power supply rails close to the servo, 470uF would do.

author: Benta
author_rank: Super Contributor
timestamp: June 13, 2022, 10:44:41 pm
content: 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.

author: macboy
author_rank: Super Contributor
timestamp: June 17, 2022, 05:15:59 pm
content: 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.

author: Benta
author_rank: Super Contributor
timestamp: June 17, 2022, 07:39:46 pm
content: Quote from: macboy on June 17, 2022, 05:15:59 pmWhich is the way to do it, software/interrupt loops for timing I/O is a no-go.

author: Youkai
author_rank: Regular Contributor
timestamp: June 19, 2022, 04:09:57 am
content: Quote from: macboy on June 17, 2022, 05:15:59 pmDo 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.