Odd behavior in 360 degree servos

Hi folks,

I am building a two servo tank or car, and for that I have made a 2 potentiometer system that rotates the servos full speed oe way , then slows down as you pull the pot down, and then turns full speed the other way at the other end.

It runs fine on my Power AR-360HB servos. I get nice acceleration and smooth operation.

But I also got TowerPro mini digital MG90 servos. They'd be optimal because of small size and gorgeous sound.

However, when I use the same code tha runs the other smoothly, the Tower first turns one way, then sits down to a very slow crawl abruptly, waits until the pot is almost at the other end, and jumps at it to blast full speed the other way.

See the video here for behavior.

The code is simply:

#include <Servo.h>                           // Include servo library
#include <Math.h>
Servo myServo;

int sensorValue;
float voltage;

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(A0, INPUT);
  digitalWrite(A0, HIGH);
  myServo.attach(2);
  
  
}

void loop() {

  sensorValue = analogRead(A0);
  voltage = map(sensorValue, 14, 1023, 600, 2400);
  Serial.print(sensorValue);
  Serial.print(" - ");
  Serial.print(voltage);
  Serial.println();
  myServo.writeMicroseconds(voltage); //1505
  delay(10);
  
  }

The internal electronics and mechanical parts of servos from different manufacturers are very different, so you should not expect the same behavior.

Even if they are similar,

voltage = map(sensorValue, 14, 1023, 600, 2400);

why would you expect magic numbers to be appropriate for both types of servo?

The electronics in a servo are not intended to provide smooth speed transitions. They are intended to provide usable position holding.
Servos that have been modified to be continuous rotation are no longer servos. They are nicely packaged motor/gearboxes with marginally functional control electronics.

Your application uses the nicely packaged motor/gearbox.
You can either accept the behavior of the electronics that come with it, or replace the electronics with something that you can control. A commercial ESC or some H-bridges come to mind.

  voltage = map(sensorValue, 14, 1023, 600, 2400);

The result of that mapping is NOT a voltage.

PaulS:

  voltage = map(sensorValue, 14, 1023, 600, 2400);

The result of that mapping is NOT a voltage.

Agreed, the mapping is the 10-bit Analog reading, converting to frequency, and as vinceherman said, not every servo maker follows the exact standard. I even ran across a couple of different RC-Plane grade servos which varied off by as much as 100Hz. (Examples: though almost identical inside, Futaba S-2003 & the constant rotation servos market by Parallax for their kits, the parallax servos have a 5K Vertical PC-mount pot in place of the servo pot, and have a hole through the side to fit a small Phillips screw driver to adjust.) I've tried modifying a couple of the S-2003's (cut the limit tab, and replace the pot with either a pair of 2.2K resistors, or 5K PC mount. ), and I still need to adjust the values, even using the old SERVO.H library to match them. This also explains why a lot of the RC plane/car/boat transmitters have a trim for the servos at the transmitter side.

Okay okay okay guys, I get the point.

My code is just a hack and the names are a mess etc, but I was just interested in the non-linearity of the small servo behavior in relation to the smooth operation of the other.

I'll keep trying to see what the values are that work for the miniservo are and try to figure out if it does indeed always go full or not at all.

Thanks for the pointers!

Hi,
How are you powering the Arduino and the servo?

Thanks.. Tom... :slight_smile: