FTC Motor Controllers

UntitledHiTechnic FIRST Motor Controller Specification


HiTechnic First Motor Controller for LEGO NXT

HiTechnic FIRST Motor Controller Specification Rev1.3

HiTechnic First Motor Controller for LEGO NXT

  1. Summary

This specification defines the motor controller for use with the LEGO NXT Mindstorms system. The motor controller provides two channels each of which can support an FTC motor and two shaft encoders. The motors are driven by PWM power while the encoders are continuously monitored. The firmware supports position, speed and power control modes.

Power is supplied from an external 9v – 15v battery via a screw terminal block.

  1. Description

2.1. Function

The motor controller interfaces with the NXT using the 6 wire sensor interface. All of the 6 wires will be used.

The motor controller will communicate with the NXT using the LEGO Company’s defined use of the I2C interface.

The motor controller will time-out if no I2C communication is detected for 2½ seconds. If a timeout occurs, both motor channels will be set to float mode.

The motor controller will shut down if a fault condition such as an output short circuit, output over-current or internal overheating is detected. It will automatically restart after a one minute cool down period. If a shutdown occurs, both motor channels will be set to float mode.

The motor controller will accept 32 bit target values for the encoder counts for position setting mode.

The motor controller will return the readings for the encoder counts from both channels as 32 bit values.

The first motor controller in the daisy chain will use an I2C address of 02/03. Subsequent controllers will obtain addresses of 04/05, 06/07 and 08/09. Only four controllers may be daisy chained. Sensors and other I2C devices may not be connected to the controller daisy chain.

The motor controller will consume 5mA or less from the NXT “brick” 4.3v unregulated supply.

The motor controller will supply up to 4 amps on each motor channel when running from 9v – 15v.

The motor controller uses separate grounds for the NXT I2C interface and the battery supply to reduce ground loop problems. These grounds are tied together with (33 ohms) resistors in each module. Care should be taken when wiring the battery supply between modules to ensure that the terminals are tight and that an adequate gauge of wire is used for the likely motor current consumption. Inappropriate wiring will result in failure to operate correctly. Care has been taken to ensure that typical wiring errors should not HiTechnic FIRST Motor Controller Specification Rev1.3 May 30, 2008 Page 2 of 5 ©Dataport Systems, Inc 2008 – 2009

cause permanent damage. However, care should always be taken to avoid wiring errors. Do not use unfused battery packs.

  1. Technical Description

3.1. Operation

The motor controller firmware will support the LEGO company’s sensor memory model. Address Type Contents
00 – 07H chars Sensor version number
08 – 0FH chars Manufacturer
10 – 17H chars Sensor type
18 – 3DH bytes Not used
3E, 3FH chars Reserved
40H – 43H s/long Motor 1 target encoder value, high byte first
44H byte Motor 1 mode
45H s/byte Motor 1 power
46H s/byte Motor 2 power
47H byte Motor 2 mode
48 – 4BH s/long Motor 2 target encoder value, high byte first
4C – 4FH s/long Motor 1 current encoder value, high byte first
50 – 53H s/long Motor 2 current encoder value, high byte first
54, 55H word Battery voltage 54H high byte, 55H low byte
56H S/byte Motor 1 gear ratio
57H byte Motor 1 P coefficient*
58H byte Motor 1 I coefficient*
59H byte Motor 1 D coefficient*
5AH s/byte Motor 2 gear ratio
5BH byte Motor 2 P coefficient*
5CH byte Motor 2 I coefficient*
5DH byte Motor 2 D coefficient*

The Sensor version number field will report a revision number in the format “Vn.m” where n is the major version number and m is the revision level. Revision numbers will typically reflect the firmware level. The version number will be used to indicate the hardware level.

The Manufacturer field will contain “HiTechnc”.

The Sensor type field will contain “MotorCon”.

The Motor 1/2 mode fields select the operating mode for each channel.

The Motor 1/2 power fields set the operating power level for each channel. This value is a signed byte.

The Motor 1/2 target encoder value fields will accept a 32 bit target position setting for use in position setting mode. This value is a signed 32 bit value.

The Motor 1/2 current encoder value fields will return the 32 bits current encoder value. This value is a signed 32 bit value.

The Motor 1/2 gear ratio fields have not been implemented in the current version of the firmware.

The Motor 1/2 P coefficient fields specify the differential control loop P coefficient. This value is an unsigned byte.*

The Motor 1/2 I coefficient fields specify the differential control loop I coefficient. This value is an unsigned byte.*

The Motor 1/2 D coefficient fields specify the differential control loop D coefficient. This value is an unsigned byte.*

The Battery voltage field will return the current battery voltage. The high byte is the upper 8 bits of a 10 bit value. It may be used as an 8 bit representation of the battery voltage in units of 80mV. This provides a measurement range of 0 – 20.4 volts. The low byte has the lower 2 bits at bit locations 0 and 1 in the byte. This increases the measurement resolution to 20mV.

*Note: the preset PID coefficient values in the firmware have been tuned for the motors being used and it is recommended they not be changed. Any changes to these values will be lost at power down.

3.2. Parameter ordering

The motor controller mode, power and target position control parameters have been placed in order to permit single multi-byte writes to be used per channel to control its operation. If just the mode or power needs to be changed, then a single byte write can be used. If power and mode need to be changed, then a two-byte write of mode, followed by power, can be used. All six bytes can be written to set up a new mode, power and target position. Since the two channels six byte areas are contiguous, a 12 byte write can be used to command both channels simultaneously.

3.3. Channel mode

The motor controller has one mode control byte per channel to control and monitor its operation. D7 D6 D5 D4 D3 D2 D1 D0
Busy Error NTO Rev Lock Sel 1 Sel 0

The Sel 1 and 0 bits encode the operation thus;

Sel Action
00 Run with power control only
01 Run with constant speed
10 Run to position
11 Reset current encoder

The Run with constant speed command will cause the firmware to adjust the motor power to compensate for changing loads in order to maintain a constant motor speed.

The Run to position command will cause the firmware to run the motor to make the current encoder value to become equal to the target encoder value. It will do this using a maximum rotation rate as defined by the motor power byte. It will hold this position in a servo like mode until the Run to position command is changed or the target encoder value is changed. While the Run to position command is executing, the Busy bit will be set. Once the target position is achieved, the Busy bit will be cleared. There may be a delay of up to 50mS after a Run to position command is initiated before the Busy bit will be set.

The Reset current encoder will reset the current encoder value to 0 and then clear the command resulting in Off-braked state to be engaged.

In this FTC tutorial, learn how to set up a field control system in your home or practice space. This video includes step-by-step router and FCS setup procedures.

 

Configuring the Controls

In the following sections, you will configure the control for the motors and

the control for the servos.

Configuring the Control for the Motors

Complete the following steps to configure the RobotDCMotors control.

1. On the DC Motors page, enter Left Drive in the first Motor Name

text field to specify the name of the first motor.

2. Place a checkmark in the Reverse checkbox for Left Drive. This

option specifies that Left Drive will move in the opposite direction

of the command you send to it.

3. Click the Add Motor button to add a second motor to the motor list.

4. Name the second motor Right Drive.

5. Select Motor 2 from the corresponding Motor pull-down menu to

specify that the Right Drive motor is connected to the Motor 2

terminals on the HiTechnic DC Motor Controller.

6. Add a third motor and name that motor Arm Manipulator.

7. Select Port 2 from the corresponding NXT Port pull-down menu to

specify that the Arm Manipulator motor is connected to port 2 on the

NXT brick.

8. Add a fourth motor and name that motor Wrist Manipulator.

9. Select Port 2 from the corresponding NXT Port pull-down menu to

specify that the Wrist Manipulator motor is connected to port 2 on the

NXT brick.

10. Select Motor 2 from the corresponding Motor pull-down menu to

specify that the Wrist Manipulator motor is connected to the Motor 2

terminals on the HiTechnic DC Motor Controller.

11. Click the Save button to save the motor names and configurations

Configuring the Control for the Servos

Complete the following steps to configure the RobotServoMotors control.

1. Click the Servos tab to display the Servos page in the TETRIX Motor

Configurator.

2. Name the first servo Left Gripper.

3. Select Controller 2 from the corresponding Servo Controller

pull-down menu to specify that Left Gripper is connected to channel 1

of servo controller 2.

4. Click the Add Servo button to add a second servo to the servo list.

5. Name the second servo Right Gripper.

6. Select Controller 2 from the corresponding Servo Controller

pull-down menu.

7. Select Channel 2 from the corresponding Servo Channel pull-down

menu to specify that Right Gripper is connected to channel 2 of servo

controller 2.

8. Click the Save button to save the servo names and configurations.

9. Click the OK button to close the TETRIX Motor Configurator.

After you create and save the controls, each control appears on the

Functions»TETRIX»Motor Configurations palette and the

Controls»Motor Configurations palette, shown as follows.

Editing Existing Motor and Servo Controls

You also can edit existing motor and servo controls that you created with

the TETRIX Motor Configurator.

Complete the following steps to update an existing motor or servo control.

1. Click the Browse button in the TETRIX Motor Configurator and

navigate to the directory that contains the control you want to edit.

2. Select the control and click the OK button.

3. Edit the control in the TETRIX Motor Configurator.

4. Click the Save button to save the new configurations.

5. Click the OK button to close the TETRIX Motor Configurator. The

Apply Changes? dialog box appears and prompts you to update this

control in the VIs that use the control.

6. Click the Yes button and navigate to the directory that contains the VIs

that use this control.

7. Select all of the folders that contain the VIs that use this control.

8. Click the Current Folder button in the file dialog box. The TETRIX

Motor Configurator updates the control in all of the VIs you specify,

including VIs in subfolders.

Note Applying the changes to the VIs might take several minutes if the directory contains

a large number of VIs. Remove any unused VIs from the directory before you apply the

changes to speed up this process.

Troubleshooting the Robot

In previous chapters, you built a robot that you can drive using a game

controller. However, at times, the robot might not work as you expect.

Table 6-1 describes common issues you might encounter when working

with the robot and solutions to address those issues.

 

Issue:

I cannot connect to the NXT brick using

Bluetooth.

Solution:

Shut down any programs running on the NXT brick

before you try using Bluetooth to connect to the

NXT brick.

Ensure that the NXT brick is not connected to

another program using Bluetooth. For example, the

NXT brick cannot connect to the FTC Controller

Station using Bluetooth if the NXT brick is already

connected to LabVIEW using Bluetooth.

Ensure the NXT brick is within range of the

Bluetooth device. Bluetooth has a limited range of

approximately 50 feet.

Ensure Bluetooth is on and the Bluetooth icon is

visible on the NXT brick. If Bluetooth is on and

visible but you cannot connect to the NXT brick, try

power cycling the brick. Turn the NXT brick off,

turn the brick back on, and then try reconnecting to

the brick using Bluetooth. You also might need to

remove and reinsert the batteries in the NXT brick

before reconnecting to the brick.

Issue:

I try to run the program on the NXT brick,

but the robot is not responsive.

Solution:

Ensure that the 12V battery pack is plugged in and

that the power switch is turned to ON.

Ensure you have enough battery power on the NXT

brick. If you are using a rechargeable battery pack,

ensure the battery pack is fully charged. The battery

pack takes between five and six hours to charge.

When charging is complete, the red light on the

battery charger turns off.

You can monitor the battery voltage of the NXT

brick in the following ways.

• Use the FTC Robot Status VI to monitor the

battery voltage of the NXT brick and the 12V

battery pack connected to the robot. The FTC

Robot Status VI displays the battery voltage of the

NXT brick and of the battery pack at the bottom

of the NXT screen.

• Use the Read Sensor VI, located on the NXT

I/O palette, to monitor the battery voltage of the

NXT brick. Add the Read Sensor VI to the block

diagram and then select the Read Battery Level

instance from the pull-down menu on the VI.

• If you use TETRIX hardware on the robot, use

the Check Battery VI, located on the HiTechnic

palette, to monitor the battery voltage of the

motor and servo controllers.

Ensure the NXT brick is not in sleep mode. By

default, the NXT brick enters sleep mode after

10 minutes of inactivity. On the NXT brick, you can

set Sleep to Never to prevent the brick from

shutting down. Select Settings»Sleep and use the

left and right arrow buttons to select Never. Then

press the orange button on the NXT brick.

Ensure the game controllers are connected to the

host computer. If you unplug a game controller, you

must click the Refresh List button in the FIRST

Tech Challenge (FTC) Controller Station and

reselect the controller you want to use.

Issue:

I am trying to connect to the NXT brick from

the FTC Controller Station, but the FTC

Controller Station cannot find the NXT

brick.

Solution:

Connecting to the NXT brick from the FTC

Controller Station for the first time can take up to

one minute. Subsequent connections take less time.

Ensure you entered the correct name of the NXT

brick in the NXT Name text box in the FTC

Controller Station. This field is case sensitive.

Ensure the NXT brick is not in sleep mode. By

default, the NXT brick enters sleep mode after

10 minutes of inactivity. On the NXT brick, you can

set Sleep to Never to prevent the brick from

shutting down. Select Settings»Sleep and use the

left and right arrow buttons to select Never. Then

press the orange button on the NXT brick.

Issue:

I accidentally unplugged a game controller

but plugged it back in. Now the FTC

Controller Station does not recognize the

game controller.

Solution:

Click the Refresh List button in the FTC Controller

Station and reselect the controller you want to use.

Issue:

The robot moves, but the motors do not turn

in the correct direction.

Solution:

Ensure that the motors are connected to the correct

terminals on the HiTechnic Motor Controller.

You can check the motor configurations in the

following ways.

• Use TheMechanic VI, located in the National

Instruments\LabVIEW 2009\examples\

FTC Toolkit directory, to test the motor

configurations. Refer to Chapter 3, Building an

Electrical Control System for the Robot, for

information about TheMechanic VI.

• If you created motor controls in the TETRIX

Motor Configurator, ensure that you entered the

correct configurations for the motors and servos

on the robot.

Issue:

My VI runs on the host computer, but when

I target the VI to the NXT brick and click the

Run button, I get a compiler error.

Solution:

Ensure that the NXT brick supports the VI you want

to run. Refer to Chapter 1, Introduction, of the

LabVIEW LEGO® MINDSTORMS® NXT Module

Programming Guide for information about

LabVIEW objects that the NXT brick supports.

Access this guide by navigating to the

National Instruments\LabVIEW 2009\

manuals directory and opening

NXT_Advanced_Programming_Guide.pdf.

To control the movement of the robot, you must connect the motors to a

motor controller, which you then connect to an NXT brick. You also must

provide a power source for the electrical control system.

Wiring the Motors

To allow the NXT brick to communicate with the motors, you must wire

the motors to a motor controller.

Complete the following steps to wire the motors to the HiTechnic DC

Motor Controller.

1. Connect the red and black wires of one motor cable to the two

terminals on one motor.

The polarity of each wire must match the polarity of the motor terminal

to which it connects. For example, the red wire is positive (+), so you

must connect the red wire to the terminal marked positive (+) on the

motor.

Tip After you connect the two cables to a motor, use a zip tie to attach the cables to the

motor to ensure the cables do not get caught on other objects when the robot is in motion.

2. Repeat step 1 to wire the remaining three motors.

3. Place the motor controller on the metal plate that is toward the rear of

the robot. Position the motor controller so that the blue terminals face

the front of the robot. This position allows each of the four motor

cables to easily reach the motor controller.

4. From underneath the robot, insert machine screws up through the

four corner holes of the motor controller.

5. Tighten the screws into the hex nuts. Do not overtighten the screws

because overtightening can break the plastic tabs on the motor

controller.

6. Connect the black wires of the two motor cables from the left side of

the robot to the Motor 1 terminal on the motor controller. Connect

the red wires of the two motor cables from the left side of the robot to

the Motor 1 + terminal on the motor controller.

7. Repeat step 6 to connect the motor cables on the right side of the robot

to the Motor 2 and the Motor 2 + terminals on the motor controller.

In the next section, you will connect the battery that provides power to the

motors and the power switch that allows you to turn the robot off and on.

Providing Power to the Motors

As with any electrical system, you must provide a power source for the

system.

Complete the following steps to provide power to the motors.

1. Connect the two cables from the power switch to the Battery and the

Battery + terminals on the HiTechnic DC Motor Controller.

The polarity of each cable must match the polarity of the battery

terminal to which it connects. For example, the red cable is positive

(+), so you must connect the red cable to the terminal marked positive

(+) on the HiTechnic DC Motor Controller.

Tip After you connect both cables to the battery terminals, use zip ties to attach the cables

to the frame of the robot to ensure the cables do not get caught on other objects when the

robot is in motion.

2. Use plastic LEGO® pieces and machine screws with hex nuts to

connect the power switch to the left side of the robot. Position the

power switch to face outward so you easily can access the power

switch.

3. Turn the power switch to OFF.

4. Attach a Velcro strap to the rear metal plate of the robot next to the

HiTechnic DC Motor Controller.

5. Attach the corresponding Velcro strap to the bottom of the 12V battery.

6. Use the Velcro straps to connect the 12V battery to the rear metal plate.

Position the battery so that the cable faces the front of the robot.

7. Connect the power switch cable to the 12V battery cable. The cable

connectors fit together in only one way. Do not force the cable

connectors together if they do not connect easily.

In the next section, you will connect the NXT brick to the robot.

Connecting the NXT Brick to the Robot

The NXT brick is the computer that directs the movements of the robot.

You must connect the NXT brick to the robot and then wire the NXT brick

to the motor controller to allow the NXT brick to direct the robot.

Complete the following steps to connect the NXT brick to the robot.

1. Use plastic LEGO® pieces and machine screws with hex nuts to

connect the NXT brick to the front end of the robot. Position the NXT

brick so that the screen and buttons face forward and so that you can

access the USB port easily. Also, make sure you can remove the NXT

battery without removing the NXT brick.

2. Connect one end of the NXT cable to port 1 on the NXT brick.

3. Connect the other end of the cable to the nearest port on the HiTechnic

DC Motor Controller.

Tip After you connect the NXT brick to the motor controller, use zip ties to attach the

NXT cable to the frame of the robot to ensure the cable does not get caught on other objects

when the robot is in motion.

The robot is complete. In the following section, you will test the electrical

control system.

Testing the Electrical Control System

The robot is now ready to perform automated tasks. However, you first will

want to test the electrical control system with a test program to make sure

the robot works as you expect it to work.

Downloading the Firmware

Before you can use the test program to test the electrical control system,

you must ensure that the host computer can communicate with the NXT

brick. The NXT brick must be running the correct firmware to

communicate with the host computer.

Complete the following steps to download the correct firmware to the NXT

brick from LabVIEW.

1. Connect the NXT brick to the computer through USB or Bluetooth and

power on the NXT brick. Do not power on the robot.

2. Launch LabVIEW.

3. In the Getting Started window, click the Blank VI link to open a

new VI.

4. Select Tools»NXT Tools»NXT Terminal to launch the NXT

Terminal dialog box.

5. Click the Update Firmware button to launch the Update NXT

Firmware dialog box.

6. Click the Browse button next to the Look in text box to display a file

dialog box.

7. Navigate to the National Instruments\LabVIEW 2009\

Targets\NI\NXT\NXTToolkit\Firmware directory and click the

Current Folder button.

8. In the Available Firmware Files list, select LEGO MINDSTORMS

NXT Firmware V1.28.

9. Click the Update button to begin downloading the firmware to the

NXT brick. The Progress section of the Update NXT Firmware

dialog box displays the progress of the firmware update.

10. When the Update NXT Firmware dialog box displays

Successfully Downloaded Firmware!, click the Close button to

close the dialog box.

The host computer now can communicate with the NXT brick.

Running the Test Program

After you download the correct firmware to the NXT brick, you can use a

test program to test the electrical control system of the robot.

Complete the following steps to test the electrical control system.

1. Turn the power switch on the robot to ON.

Tip When you test the electrical control system, raise the robot off the ground so that the

wheels are not in contact with any surface. If the electrical control system is not wired

correctly, the robot might drive in an unexpected direction.

2. Navigate to the National Instruments\LabVIEW 2009\

examples\FTC Toolkit directory and open TheMechanic.vi.

3. Click the Run button, shown at left, to run TheMechanic VI.

When the electrical control system is connected to the robot correctly, the

robot performs the following moves when you run TheMechanic VI.

• Move left wheel forward, reverse, then stop.

• Move right wheel forward, reverse, then stop.

• Turn clockwise.

• Turn counter-clockwise, then stop.

If the robot does not follow the previous movements, repeat the steps in this

chapter to make sure the electrical control system is configured correctly.

You must connect the NXT brick to the FTC Controller Station to use the

game controllers to move the robot.

Complete the following steps to connect the NXT brick to the FTC

Controller Station.

1. Navigate to the National Instruments\LabVIEW 2009\

examples\FTC Toolkit\FTC Controller Station directory

and double-click FTC Controller Station.exe to launch the FTC

Controller Station.

2. Notice that the FTC Controller Station automatically assigns any

connected game controllers to Controller 1 and Controller 2.

3. Enter the name of the NXT brick in the NXT Name text box. You also

can click the Browse button to select the NXT brick.

Note The FTC competition requires that you use your four-digit FTC team name as the

name of the NXT brick during the competition.

4. Click the Connect button, shown at left, to connect to the NXT brick.

When an NXT brick is connected, the Connect button changes to the

Disconnect button.

When the NXT brick connects successfully, the FTC Controller Station

automatically downloads two default programs, FTC Teleop Basic and

Program Chooser, to the NXT brick.

Running a Program in Teleoperated Mode

Use the Program Chooser program that the FTC Controller Station

downloads to the NXT brick to specify which program you want to run on

the NXT brick in Teleoperated mode. When you select the program you

want to run, the Program Chooser program creates a.txt configuration file

that specifies the program you selected.

When the mode of the robot changes from Autonomous to Teleoperated in

the competition, the field management system stops any currently running

Autonomous program and starts running the Teleoperated program that the

.txt configuration file specifies.

In this exercise, you will choose and run a program in Teleoperated mode

on the NXT brick.

Complete the following steps to use the Program Chooser program to select

the program you want to run in Teleoperated mode.

1. On the NXT brick, navigate to My Files»Software files»Program

Chooser and press the orange button.

2. Use the left and right arrow buttons to select FTCTeleopBasic.rxe

from the list of programs, and press the orange button. The Program

Chooser program creates an FTCConfig.txt configuration file on the

NXT brick that specifies FTC Teleop Basic as the program to run in

Teleoperated mode.

3. Press the orange button to end the Program Chooser program.

4. In the FTC Controller Station, click the Refresh button to detect

the FTCConfig.txt configuration file on the NXT brick. Notice

that the FTCConfig.txt Present round LED turns green, and

FTCTeleopBasic.rxe is listed as the Designated Teleoperated

Program.

5. In the FTC Controller Station, set the mode of the NXT brick to

Teleoperated. Because you specified a Designated Teleoperated

Program, the FTC Controller Station stops any program running in

Autonomous mode on the NXT brick and begins running the

Designated Teleoperated Program.

Using the Game Controllers

After you connect the NXT brick to the FTC Controller Station and select

the Teleoperated mode, you can use game controllers to drive the robot.

Complete the following steps to select the game controllers you want to use

to drive the robot.

1. Click the Refresh List button for Controller 1. An updated list of

game controllers connected to the host computer appears in the text

box above the Refresh List button.

2. From the list of connected game controllers, select the game controller

you want to correspond to Controller 1. Controller 1 now displays

any movements or button presses you make on the physical game

controller. For example, if you press button 2 on the game controller,

button 2 on Controller 1 appears to be pressed as well. The FTC

Controller Station sends any game controller data for Controller 1 to

the FTC Teleop Basic program running on the NXT brick, which

drives the robot accordingly.

Note Buttons 9–12 are not shown on Controller 1 or Controller 2 of the FTC Controller

Station. Buttons 11 and 12 correspond to the left and right joystick buttons, respectively.

3. If you want to use two game controllers to drive the robot, repeat

steps 1 and 2 for Controller 2. However, while you run the FTC

Teleop Basic program, the robot responds only to the joystick on

Controller 1.

4. Push the joystick forward and backward to move the robot forward

and backward. Move the joystick left and right to turn the robot

counter-clockwise and clockwise.

5. Click the QUIT button in the FTC Controller Station to stop both the

FTC Controller Station and the program running on the NXT brick.

An explanation of H bridges (a type of motor control circuit). I also show you how to build a bidirectional motor speed controller.