servo ticks randomly. timer issue?

Well, my last attempt at this issue didnt work so Im starting again from the beginning and from scratch and seeing if anyone can help me. Ive been at this for months now and im getting to the point where Id just pay someone to help me out because its been frustrating me SO much. I have an arduino uno and a hitec servo. the hitec servo is plugged into pin 9 of my board ( i have tried other pins as well to troubleshoot). Power is 6v/2amp from an external source (I have also tried many other power sources even taking my setup to friends houses thinking there might be interference in my houseses AC). Grounds are all connected. Keep in mind that ive tried different Arduino UNO boards and also different hitec servos (the costs are piling) and still getting the same result. Basically the servo ticks/clicks every few seconds or so. There is no horn on the servo so there is no load on it. And as you can tell from the code, its as simple as it gets. Just attaches the servo.Ive also tried using capacitors..no luck.... Now....someone suggested the timsk=0 code and voila! the clicking/ticking stopped for good, BUT its not going to work for me because my project demands lots of somewhat long delays and even with the microsecond delay loops it still wont workout for me. Are there ANY other options anyone can think of? I need to use the Varspeedservo library since i need extremely slow servo movements and Ill need to have about 4-5 servos eventually on that program...Thanks so much.

#include <Servo.h>

Servo myservo;  

void setup() {
  myservo.attach(9);  


}

void loop() {                     
}

Hello,

I've had problems like this, and are generated by delays inserted by other libraries with timers and interrupts.

But luckily I found the servo library via software, you need to call the servo update subroutine (refresh) within a interval of about 10 ms, maybe up to about 20 ms, try it:

http://playground.arduino.cc/ComponentLib/servo

Have you tried writing the servo to one position or another after attaching?

Rtek, I had no luck figuring out how to do that. And Delta, yes I tried writing positions but I still get the random twitching

Hello,

Do not worry, this library has no secrets, this is the example code for the link above:

#include <SoftwareServo.h> 

SoftwareServo myservo;  // create servo object to control a servo 

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 

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

void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 

  SoftwareServo::refresh();
}

Note that the example has a delay of 15ms, ("waits for the servo to get there") this is the point that you can enter your program, if your program has loops that get stuck, then you should let your program flow, and do the control by counting cycles.

If the servo is ticking with just that minimal code then it isn't some other library. There must be something wrong with the servo or the Arduino or the wiring. If there's more to the problem code then you should share that.

You know what you need to do to make it work, maybe program a atiny to run the servo and use your full size to keep everything else going.

Slumpert:
You know what you need to do to make it work, maybe program a atiny to run the servo and use your full size to keep everything else going.

What else is going? He's shown very minimal code that he says exhibits the problem.

Buried in his blob of a post, he wrote.

omartos:
someone suggested the timsk=0 code and voila! the clicking/ticking stopped for good, BUT its not going to work for me because my project demands lots of somewhat long delays..

Just saying , if you figure something out, dont be afraid to spend a dollar to move the project along..

Hello,

Well, the program with a large delay, can usually be redone to become fluid, instead of using a large delay(nnnnnnnn) you can use comparison with millis(), or count cycles (), that's what I had to do in my program,

But even letting the code flow, without long delays keeping the processing, was still having problems with other libraries that were temporarily disabling the interruptions, which ends up causing a little delay in the signal time that the servo will receive, and then the small tick-tick appeared.

So I found the servo library via software, and then it worked.

An alternative could be the detachment of the servo, in moments when it is in rest position

Hi there all, I tried the different options and I need to use the varspeedservo library and I had a hard time using both libraries together so the fix that seems to do it for me is the latest thing Rtek mentioned which is to just use detach/attach everytime the servo moves and ends up in a position. Thanks for all the help everyone

omartos:
detach/attach everytime the servo moves and ends up in a position

Well, have you reported this problem to your library repository?

If I remember correctly, in the library via software, the servo is only parked, it does not come back.