Control a Trex Jr. Motor Controller w/ arduino Duemilanove

I have been reading the documentation for the Trex Jr. Motor controller and last night was my first attempt to send a serial command from the arduino to the motor controller. From what I understood from the documentation I removed the blue jumpers from the motor controller and I connected the arduino RX to the Trex’s RX and the TX to TX and the ground to the ground. I have two 6v motors connected to the M1 and M2 leads and I have 6v from 4 AA batteries connected to the VIN and GRD. All I did in my code was setup the Serial to run at 19200 baud and then try to transmit a command to the motor controller. When I turned on the power to the motor controller the middle red led blinked 5 times. I do not know if I did something wrong in the code or if I have the jumpers wrong on the board or if I need to configure the motor controller differently. Can anyone provide me with a simple sketch that sends a command from the arduino to the motor controller, or tell me what I did wrong wiring.
I am new to all this so if I could just get started I am sure I can figure out the rest. :smiley:
-Joe

Hello Joe.

Section 3.d of the user’s guide explains how to interpret the LED feedback from the TReX. More importantly, section 3.b explains how to make proper signal connections to your board (your case is represented by the bottom picture that shows a microcontroller connected to the TReX Jr). By connecting TX on your Arduino to TX on the TReX Jr, you are connecting two outputs together that could potentially be driving in different directions, which runs the risk of burning out the pin on the Arduino or the TReX Jr (or both). You need to connect your Arduino’s transmit line, TX, to your TReX Jr’s TTL serial receive line, SI. It’s very easy to damage electronics components by using them improperly, so it’s very important that you read and understand the user’s guide. If there’s something in the user’s guide you find confusing, please tell us about it so we can try to make it more clear.

Since the Arduino’s serial lines are used for programming and debugging, I recommend you use the SoftwareSerial library to send data to the TReX on pins other than the hardware serial lines (0 and 1). There should be plenty of example sketches out there that show how to use SoftwareSerial to send bytes; you just need to modify one to send the particular bytes that make up a TReX Jr command packet. If you have trouble getting something working, feel free to post a simple sketch here for us to take a look at.

Note that you can also try connecting your TReX Jr directly to your computer using a USB-to-TTL-serial adapter (I think the Arduino can be used as such a device, but I’m not sure) and try sending command packets using the Pololu Serial Transmiter utility. This would let you see how the board responds to various commands, and, if your code isn’t working, it would let you test whether the problem is with your code or elsewhere (e.g. a problem with the board or with your connections).

- Ben