0
\$\begingroup\$

I have recently started to fiddle with an Arduino UNO R3 kit I bought some time ago, and I got so hyped that I have decided to build a robotic arm.

This robotic arm which I found on Thingiverse requires to use 4 servo motors. I got some cheap SG90 motors off amazon. Since these servos require a rather large current to run, I am going to use an external power supply to power them at the same time, and a PCA9685 16-channels servo controller.

Now... I have come to the understanding that the position of a servo motor horn can be chosen using pulse width modulation (PWM) at 50Hz, with 1ms pulse widths corresponding to 0° and 2ms to 180°, according to the data sheet of my SG90 servo.

However, I have seen that since my motor is rather cheap, it could be that the the servo positions could correspond to a slightly different pulse widths from the data sheet.

How can I determine for certain which pulse width corresponds to 0° and 180° using Arduino?

Also, if I were to send a pulse width that's lower than the one corresponding to 0° to the servo, would it damage the motor?

Thank you very much!

\$\endgroup\$
2
  • \$\begingroup\$ #Andrea Angella, Servo PWM pulse width stuff are the same for Arduino and Rpi. You might find the general knowledge and tricks useful in my answers to the following RpiSE Q&A: (1) How can Rpi move a Servo motor using a GPIO pin in PWM mode? - RpiSE, Asked 1 year, 11 months ago Active 1 year ago Viewed 2k times, raspberrypi.stackexchange.com/questions/98467/…, / to continue, ... \$\endgroup\$
    – tlfong01
    Commented Apr 12, 2021 at 1:35
  • \$\begingroup\$ / cont'd, ... (2) RPi4B PCA9685 PWM Controlling Many Servos - RpiSE, Asked 1 year, 7 months ago Active 1 year, 2 months ago Viewed 587 times, raspberrypi.stackexchange.com/questions/102269/…, (3) How to use Rpi python GPIO pins in PWM output mode to create PWM signals? - RpiSE, Asked 2 months ago Active 25 days ago Viewed 128 times, raspberrypi.stackexchange.com/questions/120452/…. Cheers. \$\endgroup\$
    – tlfong01
    Commented Apr 12, 2021 at 1:36

2 Answers 2

1
\$\begingroup\$

How can I determine for certain which pulse width corresponds to 0° and 180° using Arduino?

You cannot. To begin with, no hobby servo, even expensive ones, have exact 180° travel. Cheap servos almost guaranteed to have it different. Also, some cheap servo electronics depends on frequency, so 0 position at 60Hz can be different from 0 at 65Hz.

if I were to send a pulse width that's lower than the one corresponding to 0° to the servo, would it damage the motor?

It should not, at least not immediately. But most likely the servo will try to get there, drawing rather high stall current and heating up.

To address both your questions, you need to calibrate minimum and maximum duty cycles for each servo individually. There is good description of this procedure at the Adafruit site. When you have calibration data you can then scale the control command proportionally for each servo to get into desired position.

\$\endgroup\$
0
\$\begingroup\$

When in doubt, consult the spec sheet.

0 deg = 1.5ms
-90 deg= 1ms
+90 deg = 2ms

Did you report the error % at a 50 Hz frequency ? Show actual errors. The error may be computed or classified as offset and/or gain, subject to component tolerances (unspecified).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.