Two different responses from two 360 degree servos

Hi,

I am building a little tank that has two 360 degree servos for power and two potentiometers for control. I have two types of servos: one is a PowerHD AR-360HB robot servo, and the other one is a TowerPro MG90D 360 servo (see http://www.towerpro.com.tw/product/mg90d-2/).

When I connect them to the Arduino, the PowerHD response is fine: I can stop all rotation with the linear pot at the center, get full speed rotation clockwise at one end, and full speed counterclockwise at the other.

But the TowerPro doesn't act rationally at all: it starts very slow, then accelerates to top speed and returns to crawl, regardless of the potentiometer.

So my question is, does the TowerPro have to be coded some other way from the PowerHD?

This is the code (I am testing one servo at a time, but this code makes the PowerHD act as I
expected):

#include <Servo.h> // Include servo library

int servoRightPin=4;
int servoLeftPin=2;
Servo myServoLeft;
Servo myServoRight;
int speedLeft = 1485;
int speedRight = 1485;

void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
digitalWrite(A0, HIGH);
pinMode(A3, INPUT);
digitalWrite(A3, HIGH);
pinMode(servoRightPin, OUTPUT);
pinMode(servoLeftPin, OUTPUT);
myServoLeft.attach(2);
myServoRight.attach(4);
}

void loop() {

int sensorValueA = analogRead(A0);
int sensorValueB = analogRead(A3);
float voltageA = (sensorValueA * 1.75) +600;
float voltageB = (sensorValueB * 1.75) +600;
speedLeft = map(voltageA, 600, 2400, 1100, 1800);
speedRight = map(voltageB, 600, 2400, 1100, 1800);

Serial.print("speedLeft ");
Serial.println(speedLeft);

roll_left_servo(speedLeft);
delay(10);

}

void roll_left_servo (int rollspeed_left){
myServoLeft.writeMicroseconds(rollspeed_left);
delay (10);
}

MSL:
The Continuous Rotation Servos do not turn in deegrees, they turn just left and right, like their name says, "Continuous Rotation"

You must use this sentences:

servo.writeMicroseconds(1500);     //stop

servo.writeMicroseconds(1300);    //turn right

servo.writeMicroseconds(1700);    //turn left




also are in the *Servo.h*

Incidentally, this works for my PowerHD AR-360HD just fine, but for my TowerPro MG90D Digital 360, it doesn't. The TowerPro just starts off at some speed and doesn't respond to changes in microseconds like the PowerHD.

This leads me to think there must be some other values to be sent to the MG90D, but I can't find them online. Does anyone know?

Actually, I used this code to find out something more:

#include <Servo.h> // Include servo library

Servo myTransportServo;
int speed = 0;
int step = 25;

void setup() {
myTransportServo.attach(2); // Attach transport servo signal to pin2
Serial.begin(9600);
}

void loop() {
rollit(speed);
delay(1000);

Serial.print("Speed: ");
Serial.println(speed);
speed = speed + step;
}

void rollit (int rollspeed){
myTransportServo.writeMicroseconds(rollspeed);
delay (100);

}

Doing this, the servo starts rotating clockwise at full steam, then at 1000 it stops, then jerks counterclockwise until speed > 1700, and then it goes full steam counterclockwise.

This isn't very useful :P, so how can I set the speed and direction of this type of servo?

Rather than running right through all the values from 0 to something (you don't seem to have set an upper limit) I suggest you focus on finding out what particular values are useful to you.

I would expect the useful range of values to be approximately from 1000 to 2000 µsecs with the servo stationary at around 1500.

So see what happens if you just do servo.writeMicroseconds(1000); and let it run for 10 seconds. Then do servo.writeMicroseconds(1500); for another 10 seconds.

There is always the possibility that the servo is faulty.

And, by the way, what you are using are Continuous Rotation Servos, not 360 degree servos. A 360 degree servo would be capable of being commanded to move to a particular angle.

...R

follow up of old thread - Continuous Rotation Servo - Motors, Mechanics, Power and CNC - Arduino Forum

Try this test sketch, connect servo signal wire to pin 9:

/*
 Try this test sketch with the Servo library to see how your
 servo responds to different settings, type a position
 (0 to 180) or if you type a number greater than 200 it will be
 interpreted as microseconds(544 to 2400), in the top of serial
 monitor and hit [ENTER], start at 90 (or 1472) and work your
 way toward zero (544) 5 degrees (or 50 micros) at a time, then
 toward 180 (2400). 
*/
#include <Servo.h>
Servo servo;

void setup() {
  // initialize serial:
  Serial.begin(9600); //set serial monitor baud rate to match
  servo.write(90);
  servo.attach(9);
  prntIt();
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 2400);
    servo.write(pos);
    prntIt();
  }
}
void prntIt()
{
  Serial.print("  degrees = "); 
  Serial.print(servo.read());
  Serial.print("\t");
  Serial.print("microseconds =  ");
  Serial.println(servo.readMicroseconds());
}

@usenetfan, do not cross-post. Threads merged.

Sorry, will not cross post in the future.

I made a couple of videos using the same code but the two different servos.

Servo 1 works perfect with a speed ranging from 1200 to 1800:

Servo 2 has issues:

I'll try the code above and report shortly.

Okay, I tested the code above. Starting from 0 and working up to 90 gives me full spoeed clockwise until 60
65 stops the movement, 70 jerks it counterclockwise maybe 10 degrees as do 75, 80, 85 etc up until 120.

125 starts the full speed counterclockwise and it goes on until 180.

usenetfan:
Okay, I tested the code above.

Which code are you referring to?

If you post the code you are using there is no confusion.

Starting from 0 and working up to 90 gives me full spoeed clockwise until 60
65 stops the movement

Do you mean that when you use Servo.write() with any value from 0 to 60 the motor runs at full speed?

If so, I suspect the servo is faulty.

...R

Yes, I'm beginning to see it as a piece of junk too.

Many thanks for your time and assistance!

usenetfan:
Yes, I'm beginning to see it as a piece of junk too.

I do hope you get a satisfactory result, but it makes it very difficult to help when you don't respond fully to the Replies you receive.

...R