Difference between revisions of "TETRIX Servo Controller"

From ROBOTC API Guide
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
{| style="font-family:Verdana, Genega, sans-sarif; font-size:80%;color:gray;" width="100%" cellpadding="0%" cellspacing="0" border="0"
+
<yambe:breadcrumb self="Servo Controller">TETRIX|TETRIX</yambe:breadcrumb>
|-
+
|
+
''[[Main_Page|Main]] >> [[TETRIX_Main|TETRIX]] >> [[TETRIX:_Servo_Controller|Servo Controller]] ''
+
|-
+
|}
+
 
<br />
 
<br />
  
{|
+
{{tl|1|}}
|-
+
|style="vertical-align:top"| __TOC__
+
|-
+
|}
+
 
<br />
 
<br />
  
Line 99: Line 90:
 
|-
 
|-
 
| 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.)
 
| 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>''
+
<br />'''''NOTE:''''' ''<span class="keywordB">servo</span> can be interchanged with <span class="keywordB">servoTarget</span>.''
 
|-
 
|-
 
|
 
|

Latest revision as of 19:59, 30 April 2012

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.

Tetrix servos 1.png


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.
Parameter Explanation Data Type
servo A servo port or name TServoIndex
int a = ServoValue[servo1];  // assigns the value of servo1 to integer variable 'a'


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.)


NOTE: servo can be interchanged with servoTarget.

Parameter Explanation Data Type
servo A servo port or name TServoIndex
servo[servo1] = 160;        // changes the position of servo1 to 160
servoTarget[servo1] = 160;  // changes the position of servo1 to 160


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)
Parameter Explanation Data Type
servo A servo port or name TServoIndex
servoChangeRate[servo1] = 2;  // slows the Change Rate of servo1 to 2 positions per update