Difference between revisions of "TETRIX Motor Controller"
From ROBOTC API Guide
(→ROBOTC Functions) |
|||
Line 2: | Line 2: | ||
|- | |- | ||
| | | | ||
− | ''[[Main_Page|Main]] | + | ''[[Main_Page|Main]] → [[TETRIX_Main|TETRIX]] → [[TETRIX:_Motor_Controller|Motor Controller]] '' |
|- | |- | ||
|} | |} |
Revision as of 18:01, 13 April 2012
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. |
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: |
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
bMotorReflected
bool bMotorReflected | |
(bool) Boolean array. Used to indicate that the direction of a motor should be reflected 180 degrees. Useful when mechanical design results in a logical "reversed" condition of a motor. This can also be configured in the Motors and Sensor Setup menu in ROBOTC. | |
|
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. | ||||||
| ||||||
|
nMotorEncoder
long nMotorEncoder | |
(long) Current value of the motor encoder. Range is -32768 to 32767 so it will "wrap" after about ~90 revolutions. The user's program should reset the value of the encoder often to avoid the value "resetting" itself when the maximum distance is met. | |
|