Categories

How servo motors work and how to control servos using Arduino

Posted on Tuesday, April 24th, 2018 in Arduino, tutorials by DP

p-Arduino-and-PCA9685-PWM-Servo-Driver-600

Dejan Nedelkovski over at HowToMechatronics shared detailed tutorial on how servo motors work and how to control servos using Arduino and PCA9685 PWM driver:

There are many types of servo motors and their main feature is the ability to precisely control the position of their shaft. A servo motor is a closed-loop system that uses position feedback to control its motion and final position.
In industrial type servo motors the position feedback sensor is usually a high precision encoder, while in the smaller RC or hobby servos the position sensor is usually a simple potentiometer. The actual position captured by these devices is fed back to the error detector where it is compared to the target position. Then according to the error the controller corrects the actual position of the motor to match with the target position.
In this tutorial we will take a detailed look at the hobby servo motors. We will explain how these servos work and how to control them using Arduino.

More details at HowToMechatronics.

Check out the video after the break.

 

This entry was posted on Tuesday, April 24th, 2018 at 11:57 pm and is filed under Arduino, tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

3 Responses to “How servo motors work and how to control servos using Arduino”

  1. Max says:

    A thing I wish I knew getting into Arduino-controlled servos is that the typical “180 degrees” servos DO NOT move 180 degrees for the standard 1-2ms pulse width range (only 90ish) and that the Arduino’s 0-180 range servo command DOES NOT mean 0-180 (but 0-90), considering it’s outputting the 1-2ms standard range. Instead, you generally have to go outside that range to get your “0-180” (actually, more like “5-175”) servo to hit its end stops (which is a bad idea by the way). To the credit of this article, they at least mention that this is a thing that does happen…

    • KH says:

      So it’s a servo library designed by a software guy, or a library targeted at embedded newbies, or a learner bike. Given the design of cheap servos, nobody publishes specs for the input signal. Nobody is also going to publish position error graphs given probable non-linearities of the potentiometer etc.

      It is not realistic to easily plug in a servo and immediately command it to move so many degrees. The manufacturer is not going to calibrate the servo and add to his cost. Even if he tries to calibrate it, a position error graph is going to look ugly. So forget that. The onus is on the buyer to calibrate the part for the project. A library that expects to command a servo in degrees upon plug-in is a metric truckload of crock, there has to be calibration setting features.

    • KH says:

      IMHO PCA9685 is not a really good part for this application. It’s a PWM LED driver for goodness’ sake. NXP _does_not_ mention servos in the datasheet! Don’t listen to Alibaba sellers!

      PCA9685 has an internal oscillator, but remember, it’s for LED control, where just the duty cycle is needed. Now get this: the datasheet has no spec entry for the oscillator! They don’t wanna tell! It may well be 5% around room temps and 10-20% over the full range. The oscillator is probably not going to be calibrated during testing either. Every module you use with servos will have to be calibrated, and oh, don’t use it where there are big temp swings and you need accuracy and not bang-bang positioning.

      Folks, read the part datasheet before you buy modules. Make an effort to avoid promoting poor practices.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Wilko: It is a nice idea, but I had to remove it after finding out it constantly takes 20% of the processor. (draining the battery) It...
  • Kuro: :3
  • Fred Fish: me
  • hli: Sunday++
  • Kurt: And so with the sunshine and the great bursts of leaves growing on the trees, just as things grow in fast movies, I had that...