servo.Write(150); // should go one directionservo.Write(30); // should go the other direction.servo.Write(90); // should stop.servo.Write(80); // should go one direction slowly.servo.Write(100); // should go the other direction slowly.
I made a test, really didn't work like I want.
The servo pulses are automatically refreshed every 20mS. If the Speed register is zero (0x00) then the servo is simply set to the requested position. On power up the Speed registers are set to zero to give full speed, so unless you need to slow them down the Speed registers can be ignored. If the Speed register is set to something other than zero then that value is added to the current position every 20mS until the target position is reached. If you wish to move from 1000 to 2000 and the Speed register is set to 10, then it will take 2 seconds to reach the set position. The formula for the time it will take to make the move is:((Target position-Start position)/Speed Reg)*20mSHere are some examples:Start Position Target Position Speed Reg Time for Move2000 1000 10 2000mS (2Sec)1000 2000 10 2000mS (2Sec)1000 2000 1 20000mS (20Sec)1000 2000 100 200mS (0.2Sec)1234 1987 69 220mS (0.22Sec)
That is for a servo modified for continous rotation and not an unmodified servo.
void moveServo(int finalPosition, int stepTime);
Quotevoid moveServo(int finalPosition, int stepTime);The hard part is integrating this thing into the rest of the program, so the updates are made on nice even 20-msec time intervals, but it doesn't impact operation of other routines. Probably needa timer interrupt to call the update code.