Controlling a 360 degree motor.

I am trying to controll a 360 degree servo motor using the arduino uno but there seems to only be code examples for using a 180 one. Does anyone know how i an find some good examples of how i use a 360 motor?

Presumably this is still a normal servo, just with a full circle of movement?

I've never used one, but I'd advise getting hold of the maker's datasheet and see what signal it requires. Instead of servo.write() there's servo.writeMicroseconds() which means you can send exactly the pulse it needs. Then you don't need to mentally convert (say) 180 degrees to 360 or whatever.

If not, and it's continuous rotation, then the degrees you send are speed and direction, not position.

This i have tried but the servo seems to do whatever it wishes, i have a 360 continously going servo motor. According to the datasheet the range is 700-2300 but whatever i tell it to do the outcome is the same, the motor goes on and off as it wishes.

mackesacke:
I have a 360 continously going servo motor

Do you mean a continuous rotation servo? if so you cannot control the position, only the speed and direction.

On the other hand if you have a servo that can rotate 360 deg but NOT 361 deg I suspect it should be controlled like any normal servo except that servo.write(180) would actually make it move to 360 deg.

Post a link to the datasheet for your servo.

…R

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Robotics/FS5106B%20specs.pdf

Some is in chinese but everything is in english as well. It is not a regular servo, i would like to know how i control the speed and direction.

Page 2 of that document says it is a 180 deg servo - which seems like a regular servo to me.

Tell us exactly what happens when you use each of the following, one at a time

myServo.writeMicroseconds(700);
myServo.writeMicroseconds(1500);
myServo.writeMicroseconds(2300);

I have taken all of the values from the datasheet.

Use this short program (not tested)

#include <Servo.h>

Servo myServo;
byte servoPin = 8;

void setup() {
   myServo.attach(servoPin);
   myServo.writeMicroseconds(700);
}

void loop() {
}

…R

Some servo test code you might try to find the operating characteristics of your servo. The servo data sheet has some info that might be worth studing.

// zoomkat 12-25-13 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// Send an a to attach servo or d to detach servo
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h> 
String readString; //String captured from serial port
Servo myservo;  // create servo object to control a servo 
int n; //value to write to servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7, 500, 2500);  //the pin for the servo control, and range if desired
  Serial.println("servo all-in-one test code 12-25-13"); // so I can keep track of what is loaded
  Serial.println();
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 

      // attach or detach servo if desired
    if (readString == "d") { 
      while (digitalRead(7)) {} //delay loop until pin 7 is low
      myservo.detach(); //detach servo
      Serial.println("servo detached");
      goto bailout; //jump over writing to servo
    }
    if (readString == "a") {
      myservo.attach(7); //reattach servo to pin 7
      Serial.println("servo attached");
      goto bailout;
    }    

    n = readString.toInt();  //convert readString into a number

    // auto select appropriate value
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n); 
    }

bailout: //reenter code loop
    Serial.print("Last servo command position: ");    
    Serial.println(myservo.read());
    Serial.println();
    readString=""; //empty for next input
  }
}

Using any code supplied with any values written to the servo, the speed and direction is always the same. It goes full speed clockwise. Thanks for the greatfeedback by the way.

I bought the motor online and it said it was a 360 degrees continously going servo motor.

mackesacke:
Using any code supplied with any values written to the servo, the speed and direction is always the same. It goes full speed clockwise.

Then the servo is faulty.

…R

Robin2: Then the servo is faulty.

Bummer...

It just occurred to me that we never asked how you are powering your servo. It should NOT be powered from the Arduino 5v pin. It should have a separate power supply and the servo GND should be connected to the Arduino GND.

…R

Using any code supplied with any values written to the servo, the speed and direction is always the same. It goes full speed clockwise.

Do you have a link to where you got the servo? Most continuous rotation servos need to be calibrated to the desired stopped command value. Does your servo have a pot that can be adjusted?

http://www.electrokit.com/servo-msr640-360%25E2%25B0.52345

I am powering the servo motor through an external power source

Robin2:
Page 2 of that document says it is a 180 deg servo - which seems like a regular servo to me.

Tell us exactly what happens when you use each of the following, one at a time

myServo.writeMicroseconds(700);
myServo.writeMicroseconds(1500);
myServo.writeMicroseconds(2300);

I have taken all of the values from the datasheet.

Use this short program (not tested)

#include <Servo.h>

Servo myServo;
byte servoPin = 8;

void setup() {
  myServo.attach(servoPin);
  myServo.writeMicroseconds(700);
}

void loop() {
}




...R

Robin2:
Page 2 of that document says it is a 180 deg servo - which seems like a regular servo to me.

Tell us exactly what happens when you use each of the following, one at a time

myServo.writeMicroseconds(700);
myServo.writeMicroseconds(1500);
myServo.writeMicroseconds(2300);

I have taken all of the values from the datasheet.

Use this short program (not tested)

#include <Servo.h>

Servo myServo;
byte servoPin = 8;

void setup() {
  myServo.attach(servoPin);
  myServo.writeMicroseconds(700);
}

void loop() {
}




...R

Hi,

I tried this code and even tried to do myservo.write(180); but only myservo.write(0); and myservo.write(700); works which means the servo only rotates CW. But, it doesn’t rotate CCW. Why ? Is it faulty? But I do hear some rotation sound, but it’s not rotating CCW.

UserArduino: Hi,

I tried this code and even tried to do myservo.write(180); but only myservo.write(0); and myservo.write(700); works which means the servo only rotates CW. But, it doesn't rotate CCW. Why ? Is it faulty? But I do hear some rotation sound, but it's not rotating CCW.

You need to post the program that YOU uploaded to your Arduino.

...R

And a link to the "servo" that you are using.

Steve

Hi, this is the code.

#include <Servo.h>
Servo myservo;

void setup() {
  myservo.attach(9); //attaches the servo on pin 9 
  pinMode(2, INPUT);
}

void loop() {
  while (digitalRead(2) == LOW)
  {
  myservo.write(0); //0 being full-speed in one direction, 180 being full speed in the other direction and 90 being no movement.  
  }
  
  myservo.write(90);
}

I used this servo : TowerPro MG995 Servo Specifications and Reviews

Your link is for a regular servo that is available with either 180° or 360° of movement. I assume you have the 360° version. Unfortunately when people refer to "360° servo" they most often mean a continuous rotation servo because regular servos that can operate through 360° are not common.

As far as the Arduino code is concerned if you treat it as a 180° servo it should actually move through 360°

...R

And to confuse matters there are a lot of MG995 copies about including some called 360 degree which actually are continuous rotation motors. So a link to the servo which you actually bought would be more useful than a generic servodatabase link.

But if it rotates for more than 1 turn then it's probably an MG995 copy and possibly one with bad gears. To test exactly what it will do try it with the Knob example program from the IDE.

But one other thing...under-powered servos do all sorts of strange things so how are you powering this servo? If you have it connected to the Arduino 5V pin then that's bad. It is a powerful servo that needs a lot of current so it needs to be separately powered from something like 4 x AA batteries.

Steve

good day everyone

I am having a problem with DS3225mg DIGITAL SERVO

I AM USING EXAMPLE CODE AND IT IS RUNNING tower pro SG90 but when I connect the DS it just humming. it is 360 continuous rotation can anyone help how to run this one

thank you for your time