Pololu TReX Jr Motor Controller

The Pololu TReX Jr Motor Controller is a powerful multi-functional motor controller ideal for table-top robotics. Though it is larger than the dual serial motor controller from Pololu, it is much more sturdy and can drive a range of powerful DC motors. The club supports this device as our official motor controller.

It is important to note that not all jumpers are needed on the device, and that several may be removed without issues. Please refer to the official user's guide for which jumpers may be removed.



= Communication Protocol =

The TReX Jr motor controller can be controlled via three different means: standard radio-control pulses, variable analog voltage, and by serial communication. This tutorial focuses on serial (RS-232) communication, since serial communication is quick and easy to do with an Arduino. You can, using the right cable and drivers, directly communicate between a computer and TReX Jr, though this is well out of this article's scope.

= Wiring to the Arduino =

Wiring the TReX Jr to the Arduino is quick and simple! To the left is an image of the input/output connections of the motor controller. The only needed cables are the input/output wires used for the serial communications, as well as a tied ground. Select two pins on your Arduino as the serial communication pairs. Then, wire these two cables from those two pins to the appropriate SO and SI TTL pins. Then, a common ground must be wired, such that the serial ground on the motor controller is wired to the ground on the Arduino.



Jump Pins
Jumpers are the little blue components that jumps (connects) two pins, which are common for configuring hardware. Based on certain jumper locations for the TReX Jr Motor Controller, you can set it to receive RC analog inputs, or different types of serial inputs. For our usage, in which we only connect this device to the Arduino, we have the following settings:



Using the image to the right, remove the red jumper (which is used for RC control), then remove the green jumper (which sets RC control voltage properties), and the last blue jumper can be left alone or removed. If there are any jumpers on the COM, G, or TTL pins (which are the column of 5 pins), remove them.

Controller LEDs
The device contains several LEDs that can help you debug and track the current state of the controller. There are eight total LEDs. For each motor there is a red and green pair that show the current speed and direction of the motor. The bright blue LED, located towards a corner of the device, indicates that the device is communicating correctly with whichever interface is being used. The red and green LED pairs found between the two center capacitors are the communication status lights. The green LED flickers for each communication, while the red shows the current communication state.

Much more information about the LEDs can be found on the official user's guide. This document also contains debugging information.

Motor Power
This controller supports between 5 to 24 V. Most club DC motors work on 7.2 volts, and should thus be the target use of this controller. The internal on-board logic runs at 5V, though does not to be supplied (though the grounds between the controller and the Arduino should be tied).

= Controller Communication =

Though there are several methods of communication with this motor controller, the easiest is by serial communication via the compact pololu protocol. The compact pololu protocol is based on a series of instructions that are single byte values that are sent via TTL. Some instructions may be given parameters, such as motor index or target speed, which are sent as a second byte. A full list of commands can be found here or within the official user's guide. Note that the default communication speed for this device is set at 19200 baud (bits per second), which the Arduino supports.

A second protocol, the standard "pololu" protocol, may be used, but is much more complicated and requires multi-byte message lengths. Read more about these communication methods in the official user's guide.

Sample Arduino Code
The following code is an example that can be loaded onto any Arduino that has a connection to the TReX Jr motor controller. The default communication pins are that of 4 (serial out) and 5 (serial in). The core of the example is found within the SetSpeed(...) function, which sets the target motor both speed and direction.

= External References =
 * Official Product Page
 * Official User's Guide