Servo not moving below 9° steps

Hi guys. I'm new to Arduino, so please excuse if the answer to this question should be obvious...

I am trying to run an RC servo with the "sweep" sample code from this page: https://docs.arduino.cc/learn/electronics/servo-motors/

My problem is that the servo does not make any steps below 9°. So when I run the code, the servo makes the movement to 180° but in approx. 9° steps and not 1° steps. I tried to manually set the "pos" value to 1, 2, and so on - nothing happens until I set the value to 9° and then the servo moves...

I am using an Arduino Uno R4 and tried with and without the motor shield R3. Same result (not surprisingly).

I tried with two different (digital) RC servos, using pin 6, pin 9, pin A2: always the same result. I powered the servo from the orange out6 connector of the motor board and from the "gnd" and "5V" connectors on the "power" section of the Arduino - always the same result.

Do you know what could be causing this?

Thanks for you help!

If You post the code according to How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum You will more likely get answers.

Ok, thanks for this hint. I checked it and added the Arduino board (and motor shield) version that I use.

I didn't find a category/topic where my question would fit in better and I provided the code (in the link) and the wiring situation is described (I also clarified this more).

Is there anything missing or not according to the rules now?

You should also try the sweep example that is installed with the IDE. Still waiting to see your code. It's important you post exactly the code that relates to the problem you're describing. Too many times, "but I didn't change anything...important" becomes "well, just that, but that couldn't be the problem, could it?" Guess what.

That's the same sample than the one I used. This code makes my servo move in 9° (or similar) steps.

How are you measuring the change?

The change of the servo position? I just look at the lever... The 9° "quess" comes from the fact that when I set the "pos" value to 8, nothing happens and when I set it to 9 the servo moves. So the "critical" value is somewhere between 8 and 9.

Interesting. Thought you might be measuring change in pulse width, which runs IIRC around 6 us/degree.
Sorry, can't help until I get to the lab, won't be tonight. Maybe, others?

Are you sure you have a 180 degree servo, not a sailwinch or continuous type.

Which servo, and how exactly are you powering it. What motor board.
Leo..

Please add new information in a reply, not in the original post. It makes the conversation look confusing.

Please post code here, not via links. Many helpers can't pick that up. Reading the code here might be the only option.

The servo (one of the two I tried) is this one: DS125MG Digital Metal Gear Servo 10mm 7Kgf.cm 0.12sec for Glider Wing – KST-Servo

I limited the total travel angle to remain in the field that the servo can handle. See code below. Now the servo makes the travel in four steps (of approx 9°) and then the same on the way back.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

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

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

void loop() {
  for (pos = 45; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(85);                       // waits 15 ms for the servo to reach the position
  }
  for (pos = 90; pos >= 45; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(85);                       // waits 15 ms for the servo to reach the position
  }
}

I am (now) powering the servo with an external power source of 5V. Ground of the external power source is connected to the ground of the Arduino Uno R4. The yellow wire of the servo is connected to pin 9.

I just read on another site that other people also had problems with servos on the Uno R4. Including a user that also had movement in 10 degree steps. Are you libraries up to date.

I would put the R4 in the back of a drawer for now.
Get the R3 out, and give that a try.
Leo..

Sounds like you've run into this problem:

A fix has been merged to the library, but a new release hasn't been done to include it. So you won't get the fix by installing the library through the Library Manager.

But you can manually install the library with the latest fixes from the link below and your servo should rotate as smooth as silk.

You could also try the MoToServo class of the MobaTools library. This library can move the servo slowly by itself without the need of a for loop. And it runs smoothly on R4. The library can be installed via the library manager.
There is also a sweep example.

For the benefit of anyone who is interested in what is going on, who doesn't have an Arduino Uno R4 and/or an oscilloscope, here is a video showing how the pulse width varies using the IDE example 'Sweep'.

The IDE Example 'Sweep' has been modified by changing the delay(15) to delay(100).
The pulses are repeated every 20ms.

The width of the pulse can be seen to jump in steps of 100µs.

Compare that with exactly the same code on an Arduino Uno R3:

The change in pulse width is far smoother.

I am glad that my question wasn't a stupid one :wink: It was the problem of the servo library not working properly on the R4.

Thanks @van_der_decken, downloading the new servo library and installing it solved the problem.

@MicroBahner: When I tried downloading the ZIP of the moba tools library, Windows didn't allow the download, telling me that a virus was detected... :thinking:

You don't need to download the zip. Just install it with the library manager ( typing MobaTools in the search field ).
I never had a problem with a virus when downloading the zip ... :innocent:

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