DC Motor Controller

The HiTechnic DC Motor Controller is available from Lego Education. It can control up to 2 DC motors via a Sensor Port on a LEGO NXT brick.

You can view the Motor Controller service using a web browser as shown in the following diagram:

Click for larger image

The range for the motors is -100 to +100. If you set the motors to zero (0) then they go into Off/Brake mode. This causes a sudden stop. Unrestrained motors will jump. You should be able to set the motors to -128 to enter Off/Float mode. However, this has not been tested.

You can change one motor at a time using the MotorPowerUpdate operation. Alternatively you can update both at the same time using the DrivePowerUpdate operation.

There are also MotorStateUpdate and DriveStateUpdate operations that change both the motor mode and power at the same time.

Mode has the following format (bits from MSB to LSB):
Busy | Error | Unused | NTO | Rev | Lock | Sel1 | Sel0
NTO means No Timeout. It must be set on BOTH motors in order for it to work.
Rev reverses the direction of the motor.
Lock is not implemented in the firmware.
Sel1 and Sel0 define the Run mode of the motor:
  • Run in Power Control mode: 0,0
  • Run in Constant Speed mode: 0,1
  • Run to Position mode: 1,0 (Requires Encoders)
  • Reset Encoders: 1,1
See the MotorControllerMode enum for more information.

Changing the PID values is not currently implemented by this service. In any case, the documentation suggests that they should be left alone.

Generic contracts for Motors and a Drive have not yet been implemented.

Encoders are not yet implemented.


It takes some time for Servo or Motor update requests to be processed. If you send requests too fast, they will queue up. This results in behavior that causes servos/motors to keep moving long after they should have reached their target. For example, this happens if you try to control servos using a joystick. To get around this problem, you can "throttle" the request. See the ServoControllerTest and MotorControllerTest VPL programs for examples of how to do this.

Sometimes the polling will interfere with update commands and there will be a communications error on the controller. This causes the LEGO Brick service to reset the controller. Unfortunately, this disables the servos. It therefore appears that the service has died. To resolve this problem temporarily, the Disable command has been removed from the initialization code.

Servo Controllers and DC Motor Controllers are designed to be daisy-chained up to 4 deep on a single NXT sensor port. The I2C bus address is determined by the position in the chain by using the voltage on one of the pins. It will be 2, 4, 6 or 8 as you move further away from the brick. This makes configuration a little complicated.
NOTE: For the first version of this service, daisy-chaining is NOT supported.

Last edited Mar 2, 2010 at 7:12 AM by TrevorTaylor, version 8


No comments yet.