about Arduino control SERVO turning disorderly.

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
Hi,
I used to use SERVO of 180 degree:

SERVO180.JPG




to increase the rotate to 360 degree, I bought:

SERVO_360.JPG




which seems can't be controlled by Arduino?
tested it by Arduino's example sweep, the SERVO just turning irregularly, why? any trick there?

the phenomenon is it turn ~360 when the code asked 180 in CCW, and turn few tuens in the CW when the code just asked 180.
Thanks
Adam

Code:
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15 ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15 ms for the servo to reach the position
  }
// delay(2000);
}
 

Ya’akov

Joined Jan 27, 2019
9,148
Hi,
I used to use SERVO of 180 degree:

View attachment 261986




to increase the rotate to 360 degree, I bought:

View attachment 261987




which seems can't be controlled by Arduino?
tested it by Arduino's example sweep, the SERVO just turning irregularly, why? any trick there?

the phenomenon is it turn ~360 when the code asked 180 in CCW, and turn few tuens in the CW when the code just asked 180.
Thanks
Adam

Code:
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15 ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15 ms for the servo to reach the position
  }
// delay(2000);
}
Since the servo library expects only 180°, if you divide by 2 it might work properly.
 

KeithWalker

Joined Jul 10, 2017
3,091
I couldn't get your program to work properly. Try this one. It doesn't use the servo library. It just generates positive pulses from 0.5 to 2.5 mS long at 17 mS intervals as required by any R/C servo. It should drive your servo the full 360 degrees and back if it's the 360 version of the SG90 :

C-like:
// Program to test a R/C servo through 180 degrees and back


int pos;    // variable to store the servo position

int i;

void setup() {

pinMode (9, OUTPUT);

digitalWrite (9, LOW);  // attach the servo t pin 9 to the servo object

}

void loop() {

  for (pos = 500; pos <= 2500; pos += 10) { // from 0 degrees to 180 in 50 steps

    for (i = 0; i <4; i += 1)   // send 4 pulses to make sure servo gets there

      {digitalWrite(9, HIGH);   // send a positive pulse to the servo

       delayMicroseconds (pos);

       digitalWrite (9, LOW);

       delay(15);  // delay needed between pulses

  }}

  for (pos = 2500; pos >= 500; pos -= 10) { // from 180 degrees to 0 degrees

    for (i = 0; i <4; i += 1);  //send 4 pulses to make sure servo gets there

     {digitalWrite(9, HIGH);    // send a positive pulse to the servo

      delayMicroseconds (pos);

       digitalWrite (9, LOW);

    delay(15);     // delay needed between pulses

  }}

}
 

djsfantasi

Joined Apr 11, 2010
9,163
When a servo is modified for 360-degree rotation, it stops being a servo and becomes speed-controlled DC motor.
if it’s that type of RC servo,you can’t control the degrees. As stated, it becomes a DC motor.

However, from your description and an earlier post, it sounds like a normal RC servo and can only be controlled between 0 and180 degrees. To be honest, I’ve never heard of a 360 degree standard servo. I’ve seen that term used to describe what is known as a “continuous rotation srvo”.
 

KeithWalker

Joined Jul 10, 2017
3,091
if it’s that type of RC servo,you can’t control the degrees. As stated, it becomes a DC motor.

However, from your description and an earlier post, it sounds like a normal RC servo and can only be controlled between 0 and180 degrees. To be honest, I’ve never heard of a 360 degree standard servo. I’ve seen that term used to describe what is known as a “continuous rotation srvo”.
For a 360 deg. servo, the output shaft of a standard R/C servo is geared up to give it 360 deg. rotation. It does not rotate continuously.
 

djsfantasi

Joined Apr 11, 2010
9,163
For a 360 deg. servo, the output shaft of a standard R/C servo is geared up to give it 360 deg. rotation. It does not rotate continuously.
I understand. I was referring to another type of RC servo, the continuous servo, which does rotate continuously. They are often used to drive wheels in robotics.
 

djsfantasi

Joined Apr 11, 2010
9,163
No, because you can choose a position which a speed controlled motor can't do.
I humbly disagree. We are talking about two different types of servos. 360 degree servos (of which I am unfamiliar) and continuous rotation servos. The latter are often incorrectly referred to as 360 degree servos by hobbyists. But in discussions in this thread, I think it’s important to qualify which type we are referring to.

From the Arduino forum:
“When you use a continuous rotation (not really a) servo the value used with servo.write() sets the speed and direction of the servo rotation, not its angle.

You can get real servos capable of 360 degrees (and more) rotation…”
 

Thread Starter

LAOADAM

Joined Nov 21, 2018
879
I couldn't get your program to work properly. Try this one. It doesn't use the servo library. It just generates positive pulses from 0.5 to 2.5 mS long at 17 mS intervals as required by any R/C servo. It should drive your servo the full 360 degrees and back if it's the 360 version of the SG90 :

C-like:
// Program to test a R/C servo through 180 degrees and back


int pos;    // variable to store the servo position

int i;

void setup() {

pinMode (9, OUTPUT);

digitalWrite (9, LOW);  // attach the servo t pin 9 to the servo object

}

void loop() {

  for (pos = 500; pos <= 2500; pos += 10) { // from 0 degrees to 180 in 50 steps

    for (i = 0; i <4; i += 1)   // send 4 pulses to make sure servo gets there

      {digitalWrite(9, HIGH);   // send a positive pulse to the servo

       delayMicroseconds (pos);

       digitalWrite (9, LOW);

       delay(15);  // delay needed between pulses

  }}

  for (pos = 2500; pos >= 500; pos -= 10) { // from 180 degrees to 0 degrees

    for (i = 0; i <4; i += 1);  //send 4 pulses to make sure servo gets there

     {digitalWrite(9, HIGH);    // send a positive pulse to the servo

      delayMicroseconds (pos);

       digitalWrite (9, LOW);

    delay(15);     // delay needed between pulses

  }}

}
Thanks.
I tested your sketch, that made motor CW few turns and then CCW fe turns.
actually it is NOT a SERVO at all.
 

Ya’akov

Joined Jan 27, 2019
9,148
I humbly disagree. We are talking about two different types of servos. 360 degree servos (of which I am unfamiliar) and continuous rotation servos. The latter are often incorrectly referred to as 360 degree servos by hobbyists. But in discussions in this thread, I think it’s important to qualify which type we are referring to.

From the Arduino forum:
“When you use a continuous rotation (not really a) servo the value used with servo.write() sets the speed and direction of the servo rotation, not its angle.

You can get real servos capable of 360 degrees (and more) rotation…”
You are right, I wasn't thinking of hobby servos being different. I haven't used hobby servos much, but I am very aware of continuous rotation servos, and even continuous rotation potentiometers used for position encoding (in the olden times).
 
Top