I need to use continuously rotating servo for a camera stabilization system. My professor bought servos that have already been modified for continuous motion--there's no stop in the gears, and the potentiometer allows it to spin 360+ degrees.
I am currently using PWM with an Arduino Uno. The servo does spin continuously, but not in a stable way. I've also taken out the potentiometer in another one of the servo, and on a third servo I used a voltage divider in place of the potentiometer.
I've tried static values and a "sweep" from 0% duty cycle to 100% to get a feeling for how they work, but I just cannot figure it out. I greatly would appreciate any tips on this.
Here is my code:
//PWM test for continious motion Servo
int servoPin = 9; // connect servo to pin 10
int pwmVal = 0; // declare pulse width modulation value
void setup(void) {
pinMode(servoPin, OUTPUT); //set up the servoPin as an output pin
Serial.begin(9600); // begin serial monitor
}
void loop(void) {
//for loop that sweeps values from 0 to 255
for (pwmVal = 0; pwmVal <= 253; pwmVal += 1) {
analogWrite(servoPin, pwmVal);
Serial.println(pwmVal);
delay(100);
}
for (pwmVal = 253; pwmVal >= 0; pwmVal -= 1) {
analogWrite(servoPin, pwmVal);
Serial.println(pwmVal);
delay(100);
}
//assign a static pwm value
pwmVal = 0;
analogWrite(servoPin, pwmVal);
}