Difference between revisions of "TETRIX Servo Controller"
From ROBOTC API Guide
(Created page with "{| style="font-family:Verdana, Genega, sans-sarif; font-size:80%;color:gray;" width="100%" cellpadding="0%" cellspacing="0" border="0" |- | ''Main >> [[TETRIX_M...") |
|||
Line 17: | Line 17: | ||
{| class="wikiText" | {| class="wikiText" | ||
|- | |- | ||
− | |The HiTechnic | + | |The HiTechnic Servo Controller allows you to drive six different servo motors and read their positions via a single NXT sensor port. |
|- | |- | ||
|} | |} | ||
Line 25: | Line 25: | ||
{| class="wikiText" | {| class="wikiText" | ||
|- | |- | ||
− | |Once your HiTechnic | + | |Once your HiTechnic Servo Controller is configured in the "FTC Servo/Motor Ctrl" tab of the Motors and Sensors Setup screen, you can use the Servos tab of the Motors and Sensors Setup to rename your servos. |
− | [[File: | + | [[File:tetrix_servos_1.png]] |
|- | |- | ||
|} | |} | ||
Line 35: | Line 35: | ||
{| class="wikiText" | {| class="wikiText" | ||
|- | |- | ||
− | | | + | |Name of the servos - servos are given names "servo1" through "servo6". This is the name you would use to refer to a specific servo port (i.e. <span class="keywordB">servoTarget</span><span class="codePunc">[</span><span class="codeStringsNums">servo1</span><span class="codePunc">] = </span><span class="codeBasic">position</span><span class="codePunc">;</span>) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
Line 47: | Line 43: | ||
{| class="wikiText" | {| class="wikiText" | ||
|- | |- | ||
− | | | + | |You can rename the servo motor to something more descriptive, such as "FrontServo" or "RearServo". This name assigns an alias to your servo, so you can use your own user-defined name, or the default name of "servo#". |
|- | |- | ||
|} | |} | ||
Line 55: | Line 51: | ||
{| class="wikiText" | {| class="wikiText" | ||
|- | |- | ||
− | |This allows you to set the | + | |This allows you to set the types of servos. You can choose between a Standard Servo that has a limited movement range, or a Rotational Servo which can rotate freely. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
Line 82: | Line 62: | ||
|- | |- | ||
|} | |} | ||
− | === | + | === ServoValue === |
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class="variableType"| <span class="bigKeywordBI"> | + | | class="variableType"| <span class="bigKeywordBI">short </span><span class="bigKeywordB">ServoValue</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">TServoIndex servo</span><span class="bigCodePunc">]</span> |
|- | |- | ||
− | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types# | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_short|short]]) This read-only function is used to read the current position of the servos on a sensor port Servo controller. Values can range from 0 to 255. The value returned in this variable is the last position that the firmware has told the servo to move to. This may not be the actual position because the servo may not have finished the movement or the mechanical design may block the servo from fully reaching this position. To set the position of a servo, use the "servoTarget" or "servo" functions. |
+ | |- | ||
+ | | | ||
+ | {| class="parameterTable" cellpadding="5%" width="100%" | ||
+ | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
+ | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
+ | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
+ | |- | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''servo'' | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A servo port or name | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_TServoIndex|TServoIndex]] | ||
+ | |- | ||
+ | |} | ||
|- | |- | ||
| | | | ||
Line 93: | Line 85: | ||
|- | |- | ||
|<syntaxhighlight lang="robotc"> | |<syntaxhighlight lang="robotc"> | ||
− | + | int a = ServoValue[servo1]; // assigns the value of servo1 to integer variable 'a' | |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
Line 102: | Line 93: | ||
<br /> | <br /> | ||
− | === | + | === servo === |
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class="variableType"| <span class="bigKeywordBI"> | + | | class="variableType"| <span class="bigKeywordBI">short </span><span class="bigKeywordB">servo</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">TServoIndex servo</span><span class="bigCodePunc">]</span> |
|- | |- | ||
− | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types# | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_short|short]]) This function is used to set the position of the servos on a sensor port Servo controller. Values can range from 0 to 255. The firmware will automatically move the servo to this poisition over the next few update intervals. (Be sure to give the servo some amount of time to reach the new position before going on in your code.) |
+ | <br />'''''NOTE:''''' ''<span class="keywordB">servo</span> can be interchanged with <span class="keywordB">servoTarget</span>'' | ||
|- | |- | ||
| | | | ||
Line 115: | Line 107: | ||
! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
|- | |- | ||
− | | style="border-style: solid; border-width: 1px 0px 0px 0px"|'' | + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''servo'' |
− | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A | + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A servo port or name |
− | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types# | + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_TServoIndex|TServoIndex]] |
|- | |- | ||
|} | |} | ||
Line 125: | Line 117: | ||
|- | |- | ||
|<syntaxhighlight lang="robotc"> | |<syntaxhighlight lang="robotc"> | ||
− | + | servo[servo1] = 160; // changes the position of servo1 to 160 | |
− | + | servoTarget[servo1] = 160; // changes the position of servo1 to 160 | |
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
Line 134: | Line 126: | ||
<br /> | <br /> | ||
− | === | + | === servoChangeRate === |
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class="variableType"| <span class="bigKeywordBI"> | + | | class="variableType"| <span class="bigKeywordBI">short </span><span class="bigKeywordB">servoChangeRate</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">TServoIndex servo</span><span class="bigCodePunc">]</span> |
|- | |- | ||
− | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types# | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_short|short]]) Specifies the rate at which an individual servo value is changed. A value of zero inidcates servo will move at maximum speed. The change rate is a useful variable for "smoothing" the movement of the servos and preventing jerky motion from software calculated rapid and wide changes in the servo value. The default value is a change rate of 10 positions on every servo update which occurs. (updates occur every 20 milliseconds) |
+ | |- | ||
+ | | | ||
+ | {| class="parameterTable" cellpadding="5%" width="100%" | ||
+ | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
+ | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
+ | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
+ | |- | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''servo'' | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A servo port or name | ||
+ | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_TServoIndex|TServoIndex]] | ||
+ | |- | ||
+ | |} | ||
|- | |- | ||
| | | | ||
Line 145: | Line 149: | ||
|- | |- | ||
|<syntaxhighlight lang="robotc"> | |<syntaxhighlight lang="robotc"> | ||
− | + | servoChangeRate[servo1] = 2; // slows the Change Rate of servo1 to 2 positions per update | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- |
Revision as of 16:38, 4 April 2012
Main >> TETRIX >> Servo Controller |
Information
The HiTechnic Servo Controller allows you to drive six different servo motors and read their positions via a single NXT sensor port. |
Configuration
Once your HiTechnic Servo Controller is configured in the "FTC Servo/Motor Ctrl" tab of the Motors and Sensors Setup screen, you can use the Servos tab of the Motors and Sensors Setup to rename your servos. |
Port
Name of the servos - servos are given names "servo1" through "servo6". This is the name you would use to refer to a specific servo port (i.e. servoTarget[servo1] = position;) |
Name
You can rename the servo motor to something more descriptive, such as "FrontServo" or "RearServo". This name assigns an alias to your servo, so you can use your own user-defined name, or the default name of "servo#". |
Type
This allows you to set the types of servos. You can choose between a Standard Servo that has a limited movement range, or a Rotational Servo which can rotate freely. |
ROBOTC Functions
ServoValue
short ServoValue[TServoIndex servo] | ||||||
(short) This read-only function is used to read the current position of the servos on a sensor port Servo controller. Values can range from 0 to 255. The value returned in this variable is the last position that the firmware has told the servo to move to. This may not be the actual position because the servo may not have finished the movement or the mechanical design may block the servo from fully reaching this position. To set the position of a servo, use the "servoTarget" or "servo" functions. | ||||||
| ||||||
|
servo
short servo[TServoIndex servo] | ||||||
(short) This function is used to set the position of the servos on a sensor port Servo controller. Values can range from 0 to 255. The firmware will automatically move the servo to this poisition over the next few update intervals. (Be sure to give the servo some amount of time to reach the new position before going on in your code.)
| ||||||
| ||||||
|
servoChangeRate
short servoChangeRate[TServoIndex servo] | ||||||
(short) Specifies the rate at which an individual servo value is changed. A value of zero inidcates servo will move at maximum speed. The change rate is a useful variable for "smoothing" the movement of the servos and preventing jerky motion from software calculated rapid and wide changes in the servo value. The default value is a change rate of 10 positions on every servo update which occurs. (updates occur every 20 milliseconds) | ||||||
| ||||||
|