Template:ServoCalibration: Difference between revisions

From Phidgets Support
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Each servo behaves slightly differently. The Phidgets API provides calibration parameters for a number of different models of servo motors; however these values are generic with respect to the model and not specific to each individual unit. It is possible to generate your own values through some manual calibration in the event that your application requires very accurate control or if you are using a servo for which default values are not provided. This is done as follows:
Each servo behaves slightly differently. The Phidgets API provides default calibration parameters that will work with many different models of servo motors; however these values are generic and not specific to each individual unit. It is possible to generate your own values through some manual calibration in the event that your application requires very accurate control or if you are using a servo for which default values are not effective. This is done as follows:


{{UGbox6|
Open the Phidget control panel and open the GUI for the servo controller.
Open the Phidget control panel and open the GUI for the servo controller.
|[[File:servocalibrate1.png|link=]]
[[File:servocalibrate1.png|link=|right]]
|Plug your servo in and set the servo type to RAW_us_MODE.
<br clear="all">
|[[File:servocalibrate2.png|link=|right]]
Plug your servo in set the '''Minimum Pulse Width''' to ___ and the '''Maximum Pulse Width''' to the maximum pulse width limit described in the API for your device.
|
Choose the correct servo motor (based on what pins the motor is connected to) and then starting with the target position slider in the approximate middle, engage the motor.  The motor should move into position.


Move the target position slider to the left until the motor stops turning. The servo should stop before the slider hits its limit.  Take note of the value at which the motor stops, the more precise you can be the better but the nearest multiple of 10 is usually sufficient.  This is the  low μs value and will be used later.
Set '''Position at Min''' and '''Position at Max''' to match the '''Min Pulse Width''' and '''Max Pulse Width''', respectively. This will allow you to control the actual microsecond pulse width sent to the servo.


Move the slider to the right and again take note of where the servo stops turning.  This will be the high μs value.
[[File:servocalibrate2.png|link=|right]]
<br clear="all">
Starting with the target position slider approximately in the middle, engage the motor.  The motor should move into position.
 
Move the target position slider to the left until the motor stops turning. The servo should stop before the slider hits its limit.  Take note of the value at which the motor stops, the more precise you can be the better, but the nearest multiple of 10 is usually sufficient.  This is the minimum pulse width value and will be used later.
 
Move the slider to the right and again take note of where the servo stops turning.  This will be the maximum pulse width value.


Using a protractor, measure the actual range of movement of the servo motor.  This should be close to the rated value but it will likely not match exactly.  Accuracy to the nearest degree is good enough.   
Using a protractor, measure the actual range of movement of the servo motor.  This should be close to the rated value but it will likely not match exactly.  Accuracy to the nearest degree is good enough.   


To do this start with the motor at one extreme.  Mark a spot on the motors output shaft in line with 0 degrees and then rotate the motor to its other extreme.  Take the value of where the mark you made now rests and that is the motor’s full range of motion. For linear actuators, retract the arm all the way, mark the position of the end of the arm, extend it to its maximum length, and then measure the distance in millimeters from the end of the arm to the old position.
To do this start with the motor at one extreme.  Mark a spot on the motors output shaft in line with 0 degrees and then rotate the motor to its other extreme.  Take the value of where the mark you made now rests and that is the motor’s full range of motion. For linear actuators, retract the arm all the way, mark the position of the end of the arm, extend it to its maximum length, and then measure the distance in millimeters from the end of the arm to the old position. In either case, the difference between the positions will correspond to the difference between the '''Position at Min Pulse Width''' and the '''Position at Max Pulse Width'''.


Finally, check the motor’s data sheet to see the maximum rated velocity.  Now that all the measurements have been taken, you can use
Finally, check the motor’s data sheet to see the maximum rated velocity.  Now that all the measurements have been taken, you can calibrate for the servo.


====To test your calibration parameters:====


<code>setServoParamters(min_us, max_us, degrees, velocity_max)</code>
Type your new parameters into their respective boxes in the Motor Calibration box, and type Apply.


Next, set the Velocity slider to the rated velocity of the motor.


setSevoParameters has 4 arguments, min_us is the minimum μs value you recorded, max_us is the max μs value, degrees is the range measured with the protractor, and velocity_max is the maximum rated velocity from the data sheet in degrees per second.
The program is now calibrated to the servo motor.
|}}


For example:
For example:


The HITEC HS-322HD used in testing has the following parameters:
The HITEC HS-322HD used in testing has the following parameters:


{| style="border:1px solid darkgray;" cellpadding="7px;"
{| style="border:1px solid darkgray;" cellpadding="7px;"
Line 37: Line 39:
! Argument || Value
! Argument || Value
|-
|-
|style="background: #f0f0f0" align=left|min_us
|style="background: #f0f0f0" align=left|Min Pulse Width
|style="background: #f0f0f0" align=left|630
|style="background: #f0f0f0" align=left|540
|-
|-
|style="background: #f0f0f0" align=left|max_us
|style="background: #f0f0f0" align=left|max_us
|style="background: #f0f0f0" align=left|2310
|style="background: #f0f0f0" align=left|2370
|-
|-
|style="background: #f0f0f0" align=left|degrees
|style="background: #f0f0f0" align=left|degrees
Line 53: Line 55:


So for example, in C# to initialize the specific HS-322HD tested the following change would be made to the  
So for example, in C# to initialize the specific HS-322HD tested the following change would be made to the  
AdvancedServo example code in the advServo_Attach function:
RCServo example code in the servo_attach function:




<div class="source">
<div class="source">
<syntaxhighlight lang=csharp>
<syntaxhighlight lang=csharp>
         void advServo_Attach(object sender, AttachEventArgs e)
         void servo_attach(object sender, AttachEventArgs e)
         {
         {
             ...
             ...
             //Set the default servo type to the one Phidgets sells
             //Set the individual servo parameters
             foreach (AdvancedServoServo motor in attached.servos)
             servo.MinPulseWidth = 540;
                //motor.Type = ServoServo.ServoType.HITEC_HS322HD;
            servo.MaxPulseWidth = 2370;
                  motor.setServoParameters(630, 2310, 9, 2949);
            servo.MinPosition = 0;
            servo.MaxPosition = 180;
            servo.VelocityLimit = 316;
             ...
             ...
         }
         }
Line 71: Line 75:




Your program has now been calibrated to your servo motor.  You can get calibration parameters for multiple motors and  
Your program has now been calibrated to your servo motor.  You can get calibration parameters for multiple motors and use all of them in one program should you require it.
use all of them in one program should you require it.

Latest revision as of 21:48, 18 November 2024

Each servo behaves slightly differently. The Phidgets API provides default calibration parameters that will work with many different models of servo motors; however these values are generic and not specific to each individual unit. It is possible to generate your own values through some manual calibration in the event that your application requires very accurate control or if you are using a servo for which default values are not effective. This is done as follows:

Open the Phidget control panel and open the GUI for the servo controller.

Servocalibrate1.png


Plug your servo in set the Minimum Pulse Width to ___ and the Maximum Pulse Width to the maximum pulse width limit described in the API for your device.

Set Position at Min and Position at Max to match the Min Pulse Width and Max Pulse Width, respectively. This will allow you to control the actual microsecond pulse width sent to the servo.

Servocalibrate2.png


Starting with the target position slider approximately in the middle, engage the motor. The motor should move into position.

Move the target position slider to the left until the motor stops turning. The servo should stop before the slider hits its limit. Take note of the value at which the motor stops, the more precise you can be the better, but the nearest multiple of 10 is usually sufficient. This is the minimum pulse width value and will be used later.

Move the slider to the right and again take note of where the servo stops turning. This will be the maximum pulse width value.

Using a protractor, measure the actual range of movement of the servo motor. This should be close to the rated value but it will likely not match exactly. Accuracy to the nearest degree is good enough.

To do this start with the motor at one extreme. Mark a spot on the motors output shaft in line with 0 degrees and then rotate the motor to its other extreme. Take the value of where the mark you made now rests and that is the motor’s full range of motion. For linear actuators, retract the arm all the way, mark the position of the end of the arm, extend it to its maximum length, and then measure the distance in millimeters from the end of the arm to the old position. In either case, the difference between the positions will correspond to the difference between the Position at Min Pulse Width and the Position at Max Pulse Width.

Finally, check the motor’s data sheet to see the maximum rated velocity. Now that all the measurements have been taken, you can calibrate for the servo.

To test your calibration parameters:

Type your new parameters into their respective boxes in the Motor Calibration box, and type Apply.

Next, set the Velocity slider to the rated velocity of the motor.

The program is now calibrated to the servo motor.

For example:

The HITEC HS-322HD used in testing has the following parameters:

HITEC HS-322HD Parameters
Argument Value
Min Pulse Width 540
max_us 2370
degrees 180
velocity_max 316


So for example, in C# to initialize the specific HS-322HD tested the following change would be made to the RCServo example code in the servo_attach function:


        void servo_attach(object sender, AttachEventArgs e)
        {
            ...
            //Set the individual servo parameters
            servo.MinPulseWidth = 540;
            servo.MaxPulseWidth = 2370;
            servo.MinPosition = 0;
            servo.MaxPosition = 180;
            servo.VelocityLimit = 316;
            ...
        }


Your program has now been calibrated to your servo motor. You can get calibration parameters for multiple motors and use all of them in one program should you require it.