Servos work by listening for 20ms, then adjusting the position based on the duration of the high pulse.
The high pulse (X
below) can be between 1ms and 2ms long, with 1.5ms as the neutral or centre position.
|------------20ms-----------|
|-X-|
___ ___
_| |_______________________| |___ ...
Depending on your servo, -90° (left of centre) is usually ~1ms, 90° (right of centre) is ~2ms.
If it's at 0° and you send it a 1ms signal, it will try to turn to it's -90° position as fast as it can. The maximum speed varies from servo to servo (data sheets often specify a 0-60° time), and also depends on the voltage you give it (Hitec HS-422 at 4.8V takes 0.21 sec, at 6V takes 0.16 sec).
If you want to vary the speed (not just as fast as it can), you need to tell it to change it's position gradually.
You can do this by sending a series of position signals (each 20ms long with an X
ms high pulse).
If we send 50 pulses, slowly from 1.5ms to 1ms stepping down 0.01ms each time, X will equal:
1.50ms, 1.49ms, 1.48ms, ... , 1.02ms, 1.01ms, 1.00ms
then, assuming that it can turn as rapidly as we want it to, it'll take 50 (number of 20ms signals) x 20 ms (length of pulse) = 1s
to get from 0° to -90°.
Send a 20ms pulse with x ms high: (psudocode)
function send_signal (x):
set output high
wait x ms
set output low
wait (20 - x) ms
Make a servo slowly pan from left (-90°) to right (90°)
Psudocode:
loop x from 1 to 2, step 0.01
send_signal(x)
Or if you prefer, in C (99):
for (float x = 1; x <= 2; x += 0.01) {
send_signal(x);
}
Using my favorite search engine I found https://www.servocity.com/html/s9602_hi-speed_mg_bb.html
It's a close match. However frustratingly the page does not contain the current required. So now you have to find the Data Sheet from Futaba in this case ... Which I could not find either....
So now I drop back on the Plan B and measured the current when loaded!
Take that value and multiply by the number of servo's
So whatever the total value is in Amps and you want it to run for an hour (Say 2A) then you need at least a capacity of 2Ah (Amp hours) at 4.8 to 6 Volts for your battery.
If you only want it to run for 30 minutes divide by 2 etc ...
Will it be exact, Probably not but good enough to get you up and running in the right direction.
Connect the battery negative to the Arduino
The Battery positive to the servo positive only.
Then the signal wire to the Arduino.
This is the simplist way, don't connect the Arduino positive to the servo battery positive as the servo will introduce a lot of noise and cause more problems (random resets and the like)
You can get round this with filters and regulators but that is more work.
Best Answer
While a datasheet for this servo does not seem to be readily available after a quick Google search, I would say you should be fine. All hobby/RC servos such as the SG90 that I have come across use that same protocol. Unless they specify they are a digital servo, which use a greater pulse frequency, the 1.5ms pulse width = center position standard is followed.
The best thing to do would just be to test it and see what happens. The pulses are just control signals. If you give the motor a pulse that is too short or too long, it will just turn to its minimum and maximum angles.