TREX Motor Controller Serial Commands


I am having a problem with the TREX Dual Motor Controller DMC01. I am connecting to it via a Raspberry Pi serial connection and running Node JS on the Raspberry Pi.

I can set the motors to move forward and backwards using the serial commands 0xC0 to 0xC3 for motor 1, 0xC8 to 0xCB for motor 2. However, I cannot make it accelerate instead using the 0xC4-0xC7, 0xCC-0xCF commands. When I try these commands, it doesn’t seem to do anything.

Using the motor setting speed means the vehicle jumps forward and flips over backwards; I need it to accelerate more gently.

I am using the compact protocol.

To move forward, the following code works after establishing the serial connection:


This moves both motors forward. The data byte doesn’t seem to work properly in that the speed doesn’t change when I change the value, but there is no movement if I don’t include.

If I try a similar set of commands with accelerate instead, it doesn’t work, even if I set it to max speed.


This should set an acceleration, but the motors never move.

Furthermore, I’m having difficulties setting the acceleration parameters. I give the command to set them, but there is no change. For example, for motor one to set the acceleration to 20:


Any help would be appreciated. Thanks very much!

Are you using any kind of signal conditioning between the Raspberry Pi and TReX? If not, please note that the TReX operates at 5V. While it can accept 3.3V signals, it will transmit 5V signals, so you should be using some kind of logic level shifter or even something like a simple voltage divider to protect your Raspberry Pi.

There seems to be multiple problems you are describing, so I think it would help to look at them separately:

  1. What have you tried changing the speed values to? Just to clarify, you see no difference in the motor speed when setting it to 0x10 compared to 0x7F?

  2. Can you try sending “get configuration parameter” commands (0x9F), to see what the “Motor 1 Acceleration” (0x0E) and “Motor 2 Acceleration” (0x0F) parameters are currently set to? It might also be helpful to see what the “Motor 1 Current Limit” (0x13) and “Motor 2 Current Limit” (0x14) are set to as well.

  3. For the last problem you described with setting the acceleration configuration parameter, the bytes you are sending are not correct. As detailed in the “TReX command documentation” (also found on the Resources tab on the controller’s product page), the “set configuration parameter” command, 0xAF, takes four data bytes and returns one byte. The sequence of bytes should be:

  4. parameter #

  5. parameter value (7-bit representation)

  6. 0x55 (format byte 1)

  7. 0x2A (format byte 2)

Also, it isn’t clear if you were trying to set the acceleration to 20 (in decimal) or if you were meaning to set it to 0x20 (i.e. 32 in decimal). So, to set the acceleration for motor 1 to 20, the byte sequence should be:

0xAF - “set configuration parameter” command byte
0x0E - parameter #
0x14 - parameter value
0x55 - format byte 1
0x2A - format byte 2

As noted, the command will return 1 byte; if that byte is 0 the command was accepted, otherwise it was rejected (see the command documentation for more details).

By the way, we generally recommend our newer, easier-to-use Simple Motor Controllers over the TReX controllers. If you haven’t done so yet, you might consider checking them out.



Thanks so much for your quick and detailed response!

I am not currently using any signal conditioning, as I missed that point until doing more research. I’ve now ordered some logic shifters, as I’ll be setting up several new Raspberry Pis with motor controllers and will do it correctly on those. I’m not sure if I’ve damaged the current one, as the motor controller responds to commands but I haven’t tried getting configs from it.

  1. It took me some time to understand the serial commands documentation, and I still don’t completely, so I tried different speed settings, from 0x00 to stop (which works), and other values like 0x10, 0x20, 0x40, 0x7F (all made the motor move fast and didn’t have a different speed). I also sometimes followed with command messages like 0xC1 and if I remember correctly, it moved (I assume it ignored the most significant bit and treated the byte as a data byte). I did finally manage to get the speed to slow, but I can’t remember now which speed did it, but it wasn’t what I expected. I’ll check and add the details later.
  2. I will try this. I don’t think I’ll be able to do it until I get the logic shifter, and may have already damaged the circuit.
  3. I misunderstood the documentation and obviously sent the wrong number of bytes. I was trying 0x20, but the exact speed doesn’t matter for now, I just need to see it change. I’ll try the information you have provided, and once I have the logic shifter, I’ll try to get the result.

I seem to think the board remembers the settings when it is reset, is that correct?

Can I confirm that the accelerate motor command, e.g. 0xC6, followed by a data byte, should start the motor moving and ramp it up over time to the specified speed, according to the acceleration parameter that’s been programmed?

And thank you for recommending the Simple Motor Controller. I originally chose this model a couple of years ago because the hardware components were more consistent with my project. And now I need to replicate it quite quickly, and this is the version I have tested.

Thanks again,



I’ve just worked out my main problem about the motor acceleration and speed setting. It wasn’t the content of the bytes I was sending, but the encoding, so the problem was in my program.

I had the configuration is several different parts of the program, so I was sending strings instead of bytes in some cases. It seems the string in the data byte must have been interpreted as full speed, so it basically worked. But obviously when I sent a string in the command byte, it didn’t work. I was accidentally sending set motor commands as bytes and accelerate motor commands as strings.

Problem solved, and thanks very much for your help!


1 Like