Servo library repeat writeMicroseconds

Hi,

I have a really big code and I have no space left in it. I decided trying to remove some codes I dont need and there is something that maybe I can fix: I see this code uses at least 8 lines to avoid calling Servo.writeMicroseconds(x) every loop time.

If the X value only changes once per second, is there any problem executing Servo.writeMicroseconds(x) at every "loop" call (it will probably trigger that function thousand times per second)? I mean, can I have the risk of calling this function so many times that it may end up losing "sync" and not sentind the right pulse that it was told to send?

What code?

When you use Servo.writeMicroseconds(value); the servo library will keep producing that output indefinitely until you send it a different value.

...R

I mean, can I have the risk of calling this function so many times that it may end up losing “sync” and not sentind the right pulse that it was told to send?

You have, of course, experimented, and found that this is a likely outcome . . . right?

You have the source code. You could look at it.

When I did I saw that the only risk was a short period where interrupts were disabled:

    uint8_t oldSREG = SREG;
    cli();
    servos[channel].ticks = value;
    SREG = oldSREG;

That can add a little jitter to your servo timer interrupts and the more frequently .writeMicroseconds() is called the more often the jitter will occur. If the value has not changed then there are no other side effects.

So if the value that I use in writeMIcroseconds(x) never changes, calling writeMicroseconds(x) as many times I want will never generate a problem? I am using this code in a quadcopter, so I reallly appreciate a reliable answer cause I use this writeMicroseconds to send data to the receiver of the quadcopter, and if calling this funtion too many times can cause any kind of out of "sync", I will not call this function so many times.