-
Notifications
You must be signed in to change notification settings - Fork 3
Controlling a servo #5
Description
I read up on controlling servers and it seems like 50hz should be the frequency, which will produce a signal length of 20ms. A 1ms pulse should cause the servo to go to 0 degrees, 1.5ms pulse to 90 degrees, and 2ms pulse to 180 degrees.
What I did was divide 4096 by 20, to get the value for a single ms, with a result of 204.8 representing 1 ms.
To go to 0 degrees, I'm sending an offStep value of 204.8 (1ms), and onStep of 0.
To go to 90 degrees, I'm sending an offStep value of 307.2 (1.5ms), and onStep of 0.
To go to 180 degrees, I'm sending an offStep value of 409.6 (2ms), and onStep of 0.
This approach "works", but the servo is not operating in the full 180 degree range - each of these values produces movement constrained within about 75 degrees in total.
When I expand the range (by guessing), and use the following values it works:
100 for 1ms, 500 for 1.5ms, and 1000 for 2ms.
Obviously, I'd prefer to have this operating using math that is backed by reasons!
Any suggestions are most welcome! Thanks.