I am a newbie here. I have got myself a continuous servo (Power HD Continuous Rotation Servo AR-3606HB) and I am testing it with Arduino due. My connection only uses 3 pins (5V, GND and pin 9 as PWM).
To test it, I used the sweep example from the servo library. I understand that servo.write(angle) is controlling the speed of the continuous servo rather than specifying its angle.
Everything works fine when I used angle from 0 to 70. But then I used angle from 71 and above, the USB disconnects. What is the issue? Am I missing out something? I tried to connect a 12V DC wall adapter to it (with the USB attached), the servo slows down and changes direction eventually as I increase the angle slowly. However, the the wall adapter shows signs of change in direction of current (it LED indicator changes color) and the USB connection still disconnects with the same pattern (the USB disconnect sound is played in windows).
Another observation is the decrement of speed is not proportionate even from angle 0 to 70 when using servo.write
Am I missing out some crucial electrical components? Any advise would be very much appreciated!
Don't power servos from the arduino as it may cause the arduino to reset when the servo draws current. Below is servo test code that might be of use testing your continuous rotation servo.
// 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") {
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
}
}
zoomkat:
Don't power servos from the arduino as it may cause the arduino to reset when the servo draws current. Below is servo test code that might be of use testing your continuous rotation servo.
Thank you for your quick reply:)
Ok, you mean I have to power it externally without going through the Arduino Due? I have tried connecting the servo's V+ and GND to the positive and negative terminal of the wall adapter respectively. The PWM is connected to pin 7 based on your code.
I have tried to key in angles from 0 to 180 in the serial monitor, but the servo doesn't respond at all:(
I have experimented by typing 'a' and 'd' as well.
You really must not share supplies between Due and servo - its asking to trash
an expensive board.
You power separately, but common-up the grounds.
The Due outputs 3.3V logic signals, this is unlikely to be enough for a servo
signal, so you will need a level-shifter to convert to 5V logic to feed to the
servo control line.
The problem you were seeing was the large current draw from the servo when
under load pulling the 5V rail down towards 0V - this resets the processor.
You need to budget about 1A per servo for small servos, more for larger servos.
I have another problem here. The servo's speed doesn't change proportionately from 0 to 89 and 91 to 180
I have adjusted its potentiometer such that it stops at speed = 90. However, when I tested it from speed 0 to speed 89, I noticed that the servo only slows down from speed 70 onward. Any clue on this?