Skip to content

Commit 21bf83d

Browse files
committed
Servo extended servo range
1 parent ea96370 commit 21bf83d

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

programming/servos.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ You can read the last value a servo was set to using similar code:
5050
print(robot.servo_board.servos[1].position)
5151
~~~~~
5252

53+
5354
Disabling servo outputs
5455
-----------------------
5556

@@ -61,15 +62,34 @@ This is the state all the servo outputs are in when the board turns on, where no
6162
robot.servo_board.servos[5].position = None
6263
~~~~~
6364

64-
[How the set position relates to the servo angle](#ServoAngle) {#ServoAngle}
65-
-----------------------------------------------
65+
66+
Extended servo range
67+
--------------------
68+
69+
For an RC servo the angle of rotation is determined by the width of an electrical pulse on the control wire.
70+
A typical servo expects to see a pulse every 20ms, with a pulse width between 1ms and 2ms.
71+
Our API will take the position provided (between -1 and 1) and map it to the correct pulse width.
72+
73+
However there is no standard for the width of this pulse and there are differences between manufacturers as to what angle the servo will turn to for a given pulse width.
74+
The API can be used to change what the limits of pulse width are for each servo.
75+
You should experiment and find what the actual limit of your servos are but be careful not drive them past that.
76+
77+
| Parameter | Min value | Max value |
78+
|-------------------|-------------|-------------|
79+
|Pulse width default|1000 µs|2000 µs|
80+
|Pulse width limit |500 µs |4000 µs|
81+
82+
This code to set the pulse width limits should be done before setting the position of the servo.
83+
84+
~~~~~ python
85+
# set the range of servo output 7 between 500us and 2500us
86+
robot.servo_board.servos[7].set_duty_limits(500, 2500)
87+
88+
# Then move the position of the servo to the upper position
89+
# (pulse width = 2500us)
90+
robot.servo_board.servos[7].position = 1
91+
~~~~~
6692

6793
<div class="warning">
68-
You should be careful about forcing a servo to drive past its end stops.
69-
Some servos are very strong and it could damage the internal gears.
94+
You should be careful about forcing a servo to drive past its end stops as this could damage the internal gears.
7095
</div>
71-
72-
The angle of an RC servo is controlled by the width of a pulse supplied to it periodically.
73-
There is no standard for the width of this pulse and there are differences between manufacturers as to what angle the servo will turn to for a given pulse width.
74-
To be able to handle the widest range of all servos our hardware outputs a very wide range of pulse widths which in some cases will force the servo to try and turn past its internal end-stops.
75-
You should experiment and find what the actual limit of your servos are (it almost certainly won't be -1 and 1) and not drive them past that.

0 commit comments

Comments
 (0)