The MotorControl program

One of the disadvantages when running wireless is that direct-commands do not give you a very exact way of controlling your motors. The usual result is that the motors "overshoots" the position where you want to drive them to.

There is various workarounds to this problem: Enter the MotorControl program.

MotorControl is a program (a rxe-file, not a new firmware) that you download to your NXT brick. Instead of issuing the normal direct-commands i.e. SetOutputState for running the motor, you give commands to the MotorControl program which in turn runs the motor for you. This gives you a much improved accuracy, down to 1 degree.

With MindSqualls v2.1, support has been added for MotorControl. You can either run your NXT in the old fashion, using the NxtMotor, NxtMotorSync and NxtBrick classes, or you can use the new McNxtMotor, McNxtMotorSync and McNxtBrick classes instead to take advantage of MotorControl if you have downloaded this to your NXT. These new classes hides away the much of the technical details, but if you want those you are free to call through the MotorControlProxy class as well.

About MotorControl

You can find the MotorControl homepage here:

http://www.mindstorms.rwth-aachen.de/trac/wiki/MotorControl

You can download the compiled MotorControl program here:

http://www.mindstorms.rwth-aachen.de/trac/browser/tags/version-4.04/RWTHMindstormsNXT/tools/MotorControl/MotorControl22.rxe

Note that this is a link pointing to the stable version 4.04 tag, corresponding to MotorControl v2.2. That version won't be touched. To get the newest development version go here:

http://www.mindstorms.rwth-aachen.de/trac/browser/trunk/tools/MotorControl

The MotorControl is part of the "RWTH - Mindstorms NXT toolbox for MATLAB" toolbox which you can find here:

http://www.mindstorms.rwth-aachen.de/

Downloading MotorControl22.rxe to your NXT

In order to download MotorControl22.rxe to your NXT brick, you will need a utility like NeXTExplorer. You can find it here – just drag the rxe-file on to your NXT:

http://bricxcc.sourceforge.net/utilities.html

Sample code

As always you will need to add a reference to the MindSqualls library and you will add usings as well:

using NKH.MindSqualls;
using NKH.MindSqualls.MotorControl;

Calling MotorControl directly through MotorControlProxy:

// Create a NXT brick,
// and use Bluetooth on COM3 to communicate with it.
NxtBrick brick = new NxtBrick(NxtCommLinkType.Bluetooth, 3);

// Attach a motor to port B.
brick.MotorB = new NxtMotor();

// Connect to the NXT.
brick.Connect();

// Start the MotorControl program on the NXT and wait intill it is running.
MotorControlProxy.StartMotorControl(brick.CommLink);
System.Threading.Thread.Sleep(500);

// Run the motor in port B with fill power forward for 3600 degrees.
MotorControlProxy.CONTROLLED_MOTORCMD(brick.CommLink, MotorControlMotorPort.PortB, "100", "003600", '5');

// Disconnect from the NXT.
brick.Disconnect();

Using it "under the hood":

// Create a NXT brick,
// and use Bluetooth on COM3 to communicate with it.
McNxtBrick brick = new McNxtBrick(NxtCommLinkType.Bluetooth, 3);

// Attach motors to port B and C on the NXT.
brick.MotorB = new McNxtMotor();
brick.MotorC = new McNxtMotor();

// Syncronize the two motors.
McNxtMotorSync motorPair = new McNxtMotorSync(brick.MotorB, brick.MotorC);

// Connect to the NXT.
brick.Connect();

// If not already running, start the MotorControl program.
if (brick.IsMotorControlRunning())
    brick.StartMotorControl();

// Run the motor-pair at 75% power, for a 3600 degree run.
motorPair.Run(75, 3600, 0);

// Disconnect from the NXT.
brick.Disconnect();

Thanks

... to Linus Atorf and all the other people at RWTH Aachen University for the MotorControl program, not to forget the "RWTH - Mindstorms NXT toolbox for MATLAB" toolbox itself.

... to John Hansen for NeXTExplorer and other tools, not to forget the BricxCC IDE.

Menu

Home
Introduction
Quick Start v1.1 (C#)
Quick Start v1.2 (C#)
Quick Start v2.0 (C#)
MotorControl
Samples (C#)
User Contributions
Documentation
Downloads
Updates
Future?
You People Using It
Credits
Legal Stuff

Links

MINDSTORMS
Tech stuff
HiTechnic

Visit Steve Hassenplug's
NXT site for a list of similar tools.


The NXT STEP
MindBOARDS

Feedback

Forum
Guestbook
E-Mail