[SOLVED] Continuous rotation servo sometimes stops or goes crazy.


hi,
this first try @ using kind of motor, wanted make simple robot bought 2 of these (so robot drive around):  "servo - generic full rotation (micro size)" https://www.sparkfun.com/products/10189

it's listed running on 4.8 - 6 v, , in comments sparkfun guy says can hook directly arduino, did (hooked directly arduino uno):
power 5v, ground gnd, , control line pin 9 on arduino... i've found off position of servo fine, , spins fine if going in 1 direction. the problem:

if tell spin few secs 1 way, stop half second, spin few secs other way, stop, repeat... random amount of time fine, inevitably either stops, or starts spinning full speed in 1 direction forever.


i can't seem figure out i'm doing wrong... i've tried writing code few different ways. here's think looks correct, i'm getting same problem:

code: [select]
#include <servo.h>

servo serv1;
int serv1_off = 101;
int serv_speed = 20;
int serv_max_speed = 180;
int serv_pulse_time = 20;

void setup()
{
   serv1.attach(9);
}

void loop()
{
   serv_speed = constrain(serv_speed, 0, serv_max_speed - serv1_off);
   for (int = 0; < (2000 / serv_pulse_time); i++)
   {
       serv1.write(serv1_off + serv_speed);
       delay(serv_pulse_time);
   }
 
   for (int = 0; < (500 / serv_pulse_time); i++)
   {
       serv1.write(serv1_off);
       delay(serv_pulse_time);
   }

   for (int = 0; < (2000 / serv_pulse_time); i++)
   {
       serv1.write(serv1_off - serv_speed);
       delay(serv_pulse_time);
   }
 
   for (int = 0; < (500 / serv_pulse_time); i++)
   {
       serv1.write(serv1_off);
       delay(serv_pulse_time);
   }
}


the problem happens both servos, doubt servos defective. guess code wrong, or maybe need run these on separate 6 v supply... i'm hoping more experience me find problem lies.

you need run servos separate power supply can provide 1 amp per servo. remember connect servo power supply ground arduino ground.

when try use arduino 5v pin , servos draw current voltage falls , arduino behaves strangely - , may permanently damaged.

...r


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > [SOLVED] Continuous rotation servo sometimes stops or goes crazy.


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support