calibrate the servos through serial connection

Forums:

Sorry so many qestions :)

On a raspberry Pi How can I calibrate the servos through serial connection instead of using the GUI ?

TY.

piborg's picture

You can use Python to perform the calibration manually, however you will need to be careful to not drive a servo out of range for too long.
Be cautious using the UB.CalibrateServoPosition commands in particular, they allow you to change the servo output to any possible value without any limit checking at all.

For reference the factory set values are:

  • Maximum: 4000
  • Minimum: 2000
  • Startup: 3000

The absolute limits provided by the tuning GUI are:

  • Maximum: 6000
  • Minimum: 0

We recommend you do not exceed these absolute limits.

1. Start by opening python.

2. Next load the UltraBorg library:

import UltraBorg
UB = UltraBorg.UltraBorg()
UB.Init()

The next steps depend on which servo / connection you are calibrating, I will give the examples for servo #1

3. Start by setting the servo into a position of 3000, this should be approximately central on most servos:

UB.CalibrateServoPosition1(3000)

4. Now slowly increase this number until the servo no longer moves.
Once it stops, or where you can hear it struggling, come back ever so slightly so we are still in the moving range.
For example:

UB.CalibrateServoPosition1(3200)
UB.CalibrateServoPosition1(3400)
UB.CalibrateServoPosition1(3600)
UB.CalibrateServoPosition1(3800)
UB.CalibrateServoPosition1(4000)
UB.CalibrateServoPosition1(4200)
UB.CalibrateServoPosition1(4400)
UB.CalibrateServoPosition1(4350)
UB.CalibrateServoPosition1(4300)
UB.CalibrateServoPosition1(4250)

5. When you are happy set this value as the maximum like this, replacing 4250 with your value:

UB.SetWithRetry(UB.SetServoMaximum1, UB.GetServoMaximum1, 4250, 5)

6. Next set the servo back into a position of 3000:

UB.CalibrateServoPosition1(3000)

7. Now slowly decrease this number until the servo no longer moves.
Once it stops, or where you can hear it struggling, come back ever so slightly so we are still in the moving range.
For example:

UB.CalibrateServoPosition1(2800)
UB.CalibrateServoPosition1(2600)
UB.CalibrateServoPosition1(2400)
UB.CalibrateServoPosition1(2200)
UB.CalibrateServoPosition1(2000)
UB.CalibrateServoPosition1(1800)
UB.CalibrateServoPosition1(1600)
UB.CalibrateServoPosition1(1650)
UB.CalibrateServoPosition1(1700)

8. When you are happy set this value as the minimum like this, replacing 1700 with your value:

UB.SetWithRetry(UB.SetServoMinimum1, UB.GetServoMinimum1, 1700, 5)

9. Now move the servo around until it is where you would like it to go when the power is connected.
Make sure you stay between the minimum and maximum set earlier.
If you do not have a preference then 3000 is usually a good number to pick.
For example

UB.CalibrateServoPosition1(3000)
UB.CalibrateServoPosition1(2800)
UB.CalibrateServoPosition1(2900)
UB.CalibrateServoPosition1(2800)

10. When you are happy set this value as the startup position like this, replacing 2800 with your value:

UB.SetWithRetry(UB.SetServoStartup1, UB.GetServoStartup1, 2800, 5)

To calibrate other servos replace the UB.xxx1 names with 2, 3, or 4 as needed for all of the commands.

Thank u.

Subscribe to Comments for " calibrate the servos through serial connection"