How to adjust the position for multiple Servo Motors (MG996R) using PCA9685 & ESP8266

Dear Arduino makers,

I'm still new in Arduino programming and hardware. Now I'm doing a project which needs to connect multiple (3) servo motors (MGR996R) with the Node MCU (ESP8266) and the PCA9685. Each servo motors are intended to rotates from 0 degrees to a maximum of 180 degrees. I'm using the external power supplies which set to 5.0 V since the servo motors will be working in range between 4.8V to 6 V.

However, the results are odd. All of the servo motors keep rotating continuously (360 degrees) even though it have been declared in the code to rotates until 180. I searched online for the datasheet of MG996R servo motors and all of the sources stated that it should rotates to 180 degrees max.

I also found another sources mentioned about the FREQUENCY, MIN_PULSE_WIDTH and the MAX_PULSE_WIDTH could determined the min and max degrees position for the servos motors to rotate. I have no clue on how to calculate exactly the MIN / MAX PULSE_WIDTH manually., so I simply adjusted it accordingly by increasing or decreasing the values but the servo motors keep rotating continuously.

Oh by the way, I'm using the Adafruit_PWMServoDriver as well as the Node MCU 1.0 (ESP - 12E Module) board tools in this project since the HCAPCA9685 is not working with servos that I'm using.

I would be much appreciated if anyone in the forums could help me on this.

#using-arduino:motors-mechanics-power-and-cnc #hardware #esp8266 #pca9685 #MultipleServoMotor

The code that I'm using as follows:

#include "Wire.h"

#define MIN_PULSE_WIDTH 600
#define MAX_PULSE_WIDTH 2600
#define FREQUENCY 50

void setup() {
pwm.begin();
pwm.setPWMFreq(FREQUENCY);
// find MIN_PULSE_WIDTH: set angle to 0
// find MAX_PULSE_WIDTH: set angle to 180
pwm.setPWM(2,0,pulseWidth(180)); // 0 or 180
pwm.setPWM(3,0,pulseWidth(180)); // 0 or 180
pwm.setPWM(4,0,pulseWidth(180)); // 0 or 180

}

int pulseWidth(int angle) {
int pulse_wide, analog_value;
pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
return analog_value;
}

void loop() {
}

Regards,

You have continuous rotation "servos" rather than servos and cannot control their position only their speed and direction. Where did you get them from ?

Thanks for your response. The servos were got from the electronics / robotics shop nearby my places.

What do you mean by 'buy real servos' ? Doesn't the servos that I'm using are 'real' ? Am I missing or overlooked on something ?

If you've been wondering. here are the specs for MG996R Servo Moto:

Specifications
• Weight: 55 g
• Dimension: 40.7 x 19.7 x 42.9 mm approx.
• Stall torque: 9.4 kgf·cm (4.8 V ), 11 kgf·cm (6 V)
• Operating speed: 0.17 s/60º (4.8 V), 0.14 s/60º (6 V)
• Operating voltage: 4.8 V a 7.2 V
• Running Current 500 mA – 900 mA (6V)
• Stall Current 2.5 A (6V)
• Dead band width: 5 µs
• Stable and shock proof double ball bearing design
• Temperature range: 0 ºC – 55 ºC

The many many many fake has in sold with this type of servo.
The counterfeit warning is provided on the product page by Tower Pro.
By the way, each genuine item sold by an authorized shop, it's price maybe more than \$10 per one.

What color is the exposed gear of your servo?
If it's a brass-like color, it's a fake.
Genuine one uses high strength aluminum (A6061-T6).
But recently fakes with aluminum gears has been confirmed, so it can't judge by that alone.

The fake seller also sells a continuous rotation type servos.

What you have are electronically controlled motors with no control over their position only their speed and direction. A servo is a device whose position can be set. Hence what you have are not servos

Thanks for the response from both of you @chrisknightley @UKHeliBob.

Oh God. Your response made it clear for now. I guess mine are the fake then because the exposed gear is a brass-like color. I really didn't expect that the seller selling the fake products. Thanks again for your clarification on this,. Really appreciate it.

For clarification, the issue as to whether the servo is a fake or not is separate from whether it is really a servo or not

Hi,
Did you write a bit of code to test your servo before writing your complete code?

Writing code in stages has its merits.

Tom...

Yeah I've done it beforehand. But, the result is still the same.

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