# Servo motor control

**URL:** <https://forum.core-electronics.com.au/t/servo-motor-control/21670>\
**Category:** Uncategorized\
**Created:** [17 January 2025 04:52 UTC](https://forum.core-electronics.com.au/t/servo-motor-control/21670 "2025-01-17T04:52:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni135859](https://avatars.discourse-cdn.com/v4/letter/t/2bfe46/32.png) [@Toni135859](https://forum.core-electronics.com.au/u/Toni135859)\
**Post date:** [17 January 2025 04:52 UTC](https://forum.core-electronics.com.au/t/servo-motor-control/21670/1 "2025-01-17T04:52:52Z")

</div>

Can someone advise me the formula to convert microseconds to degrees of rotation.

I am using an SG90 and know the range of microseconds required but my code (micropython\_pca9685 Servo) uses servo.angle to drive the servo.

Thanks  
Toni

---

<div class="post-metadata">

**Author:** ![Michael99645](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/michael99645/32/11893_2.png) [@Michael99645](https://forum.core-electronics.com.au/u/Michael99645)\
**Post date:** [17 January 2025 06:20 UTC](https://forum.core-electronics.com.au/t/servo-motor-control/21670/2 "2025-01-17T06:20:15Z")

</div>

Are you talking about the pulse width times here ?

i.e. a pulse width of X uS = Y degrees of movement

If so, the actual number would depend on the servo specs.

Can you supply the part no (or a link to the datasheet) for your survo. from there we should be able to work out the math.

I dont think there will be a golden rule/mapping.

To add some math. example only.  
Lets say you have a servo  
The specs of the servo are from 0 - 360 Deg are 700uS - 2300 uS  
Assuming movement is linear. then my math would be

2300 - 700 = 1600 uS from 0 to 360 Deg  
1600 uS/360 = 4.4444 (rounded) uS per Deg  
so to move 180 Deg.  
700uS + (180 \* 4.4444)  
=\> 700 + 799.992  
= 1499.992 uS (approx due to rounding errors)

Note: made up numbers in the example and some movement assumptions.

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [17 January 2025 06:58 UTC](https://forum.core-electronics.com.au/t/servo-motor-control/21670/3 "2025-01-17T06:58:13Z")

</div>

Hi Toni  
360 will not divide evenly into 1000000 so you will only get an approximation.  
I am still trying to figure out how you get a claimed “precision” servo under these circumstances. Of course if your pulse width can be adjusted in fractions of 1 microsecond you can get closer to “precision” but in most of the text I have seen on the devices used for the hobby market I think the term is used a bit loosely.  
Cheers Bob

Edit add on  
I have not had great experience with servos but most I have seen are between 1mSec and 2mSec (1000µSec) for 180º and at 90 requires a pulse of 1.5mSec or 1500µSec.

That is 5.55555(repeat) µSec per degree I think applies for most common hobby servos. I daresay that more sophisticated applications will have available much better and more accurate servos and the ability to drive them. They probably come with an appropriate price tag also. A bit out of reach for us mere mortals.

---

<div class="post-metadata">

**Author:** ![Toni135859](https://avatars.discourse-cdn.com/v4/letter/t/2bfe46/32.png) [@Toni135859](https://forum.core-electronics.com.au/u/Toni135859)\
**Post date:** [19 January 2025 01:24 UTC](https://forum.core-electronics.com.au/t/servo-motor-control/21670/4 "2025-01-19T01:24:22Z")

</div>

Thanks to both of you.  
I think I was complicating the issue, I didn’t need to do the conversion, just stick to angles throughout the code.  
Its now all working perfectly with the PCA9685/Pico combination driving two SG90 servos via Mosquitto MQTT from the JMRI model rail package on the RPi.  
Cheers  
Toni
