Difference between revisions of "TETRIX Motor Controller"

From ROBOTC API Guide
Jump to: navigation, search
(Configuration)
Line 40: Line 40:
 
<span class="codeStringsNums">mtr_S1_C1_1</span> - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 1 (1)<br />
 
<span class="codeStringsNums">mtr_S1_C1_1</span> - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 1 (1)<br />
 
<span class="codeStringsNums">mtr_S1_C1_2</span> - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 2 (2)
 
<span class="codeStringsNums">mtr_S1_C1_2</span> - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 2 (2)
 +
|-
 +
|}
 +
<br />
 +
 +
=== Name ===
 +
{| class="wikiText"
 +
|-
 +
|Motors can be given more descriptive names, such as "LeftMotor" or "FrontMotor". This name is an alias for the motor port name, so you can use it anywhere you want to specify that motor. The first two configured TETRIX motors are given the names "motorD" and "motorE" by default,  but these names can be changed based on your preference.
 +
|-
 +
|}
 +
<br />
 +
 +
=== Type ===
 +
{| class="wikiText"
 +
|-
 +
|This allows you to set the type of motors, wether they are 12V DC motors or NXT motors.
 +
|-
 +
|}
 +
<br />
 +
 +
=== PID Control ===
 +
{| class="wikiText"
 +
|-
 +
|This checkbox enables the PID Speed Control functionality for a motor. The TETRIX DC motors don't have built-in encoders, so they must first be installed to use this feature.
 +
|-
 +
|}
 +
<br />
 +
 +
=== Reverse ===
 +
{| class="wikiText"
 +
|-
 +
|This checkbox will reverse the direction of a motor in an entire program. This is useful when motors are installed opposite one another. Instead of giving one motor a positive power level and the other motor a negative power level to make the robot move forward, both can be given a positive power level, simplifying your code.
 +
|-
 +
|}
 +
<br />
 +
 +
== ROBOTC Functions ==
 +
{| class="wikiText"
 +
|-
 +
|
 +
=== motor ===
 +
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
| class="variableType"| <span class="bigKeywordBI">int </span><span class="bigKeywordB">motor</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">tMotor motor</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#dataType_int|int]]) Contains the motor power or speed level (-100 to +100). Negative values are reverse; positive formward. A power level of 0 (zero) stops the motors.
 +
|-
 +
|
 +
  {| 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"|''motor''
 +
  | style="border-style: solid; border-width: 1px 0px 0px 0px"|A motor port or name
 +
  | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_tMotor|tMotor]]
 +
  |-
 +
  |}
 +
|-
 +
|
 +
  {|
 +
  |-
 +
  |<syntaxhighlight lang="robotc">
 +
motor[motorA] = 100;  // motor A is given a power level of 100 (forward)
 +
motor[motorA] = -100;  // motor A is given a power level of -100 (reverse)
 +
</syntaxhighlight>
 +
  |-
 +
  |}
 +
|-
 +
|}
 +
<br />
 
|-
 
|-
 
|}
 
|}
 
<br />
 
<br />

Revision as of 16:11, 4 April 2012

Main >> NXT >> Motor Controller



Information

The HiTechnic Motor Controller allows you to drive two 12V motors and read values from two shaft encoders.


Configuration

Once your HiTechnic DC Motor Controller is configured in the "TETRIX Controllers" tab of the Motors and Sensor Setup screen, you can use the Motors tab of the Motors and Sensors Setup to configure your motors.

Tetrix motors 1.png


Port

The name of the motor. NXT motors are given names "motorA" through "motorC". The TETRIX DC motors are named based on how they're connected to the NXT. The port name can be used to reference a motor in your program (i.e. motor[motorC] = speed;)

The TETRIX motor names can be translated as follows:
mtr_S1_C1_1 - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 1 (1)
mtr_S1_C1_2 - Motor (mtr) on Sensor Port 1 (S1) connected on the first controller (C1) in the daisy chain attached to Motor Port 2 (2)


Name

Motors can be given more descriptive names, such as "LeftMotor" or "FrontMotor". This name is an alias for the motor port name, so you can use it anywhere you want to specify that motor. The first two configured TETRIX motors are given the names "motorD" and "motorE" by default, but these names can be changed based on your preference.


Type

This allows you to set the type of motors, wether they are 12V DC motors or NXT motors.


PID Control

This checkbox enables the PID Speed Control functionality for a motor. The TETRIX DC motors don't have built-in encoders, so they must first be installed to use this feature.


Reverse

This checkbox will reverse the direction of a motor in an entire program. This is useful when motors are installed opposite one another. Instead of giving one motor a positive power level and the other motor a negative power level to make the robot move forward, both can be given a positive power level, simplifying your code.


ROBOTC Functions

motor

int motor[tMotor motor]
(int) Contains the motor power or speed level (-100 to +100). Negative values are reverse; positive formward. A power level of 0 (zero) stops the motors.
Parameter Explanation Data Type
motor A motor port or name tMotor
motor[motorA] = 100;   // motor A is given a power level of 100 (forward)
motor[motorA] = -100;  // motor A is given a power level of -100 (reverse)