DC Gearhead Robot Motor

The DC Gearhead Robot Motor is a 7.2V 100 oz-in embedded-encoder DV motor. This motor is commonly used in the club's Tabletop Robotics robotics projects, interfaced and controlled by a Pololu TReX Jr Motor Controller. It's best feature is the built-in and easy to interface with wheel encoder



= Embedded Wheel Encoder =

This motor has a built-in wheel encoder which is based on four lines coming off of the body. The red and black cables are power and ground, respectively. The green and white wires are signals associated with channel A or channel B quadrature outputs. There are 624 signal pulses per full shaft revolution with 160 revolutions per minute under no load.

= Sample Arduino Code =

The following source code interfaces with this motor via a Pololu TReX Jr Motor Controller. The wheel-encoder interface is based on a hardware interrupt, which calls a function (in this case, it's EncoderEvent(...)) to measure the appropriate rotations based on quadrature encoding. The interrupt is set such that on any change of voltage from the green wire (though the white signal wire could be used instead) will call the software function. This software function is explained in the Wheel Encoders article.

There is a major issue with the way the Arduino processor handles both hardware interupts and serial communication a developer should be aware of. The Arduino attachInterrupt function description states that no serial data is saved/handled during the execution of the interrupt function, which is of a major concern with the motor controller communication standard, which requires reading back all sent commands. This is resolved by calling the attach/detachInterrupt functions at the top and bottom of the motor controller code. This is a subtle issue, but critical to correct handling of the motor controller while reading wheel encoder data.