Contents

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: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

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[motorD] = 100; // motor D is given a power level of 100 (forward)motor[motorD] = -100; // motor D is given a power level of -100 (reverse)

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.

nMotorEncoder[motorD] = 0; // reset the Motor Encoder of Motor Dwhile(nMotorEncoder[motorD] < 360)// while the Motor Encoder of Motor D has not yet reached 360 counts:{motor[motorD] = 75; // motor D is given a power level of 75motor[motorE] = 75; // motor E is given a power level of 75}motor[motorD] = 0; // motor D is given a power level of 0 (stop)motor[motorE] = 0; // motor E is given a power level of 0 (stop)