Serial Controlled Motor Driver Hookup Guide

Contributors: MTaylor
Favorited Favorite 1

UART Commands


The command parser is built to accept short strings of ascii data, compacted to reduce data transfer size while being easy to handle by standard UART hardware. The general form is a letter indicating which operation to perform followed by a series of numbers and letters, and finally a carriage return and line feed. As a string, an example command would be “M0F50\r\n”.

Return codes:

Overflow ("ovf"): The input buffer is filled (no command should be that long). Send delimiter to clear buffer

Invalid Syntax ("inv"): The first character in the command is not one of the defined prefixes.

Formatting Error ("fmt"): There was something generally wrong with the command, like it had the wrong number of characters or an out of range value was detected.

No Motor ("nom"): The motor's number is past the most downstream slave detected.



"H" or "?"

Prints command reference to serial.

"H\r\n" – Drive master motor B forward at 34%.

Drive motor:

n = motor number, single or double digits
d = direction, R or F
l = level, 0 to 100

"M1F34\r\n" – Drive master motor B forward at 34%.
"M2R80\r\n" – Drive slave motor A reverse at 80%.

Invert motor polarity:

n = motor number, single or double digits

"M1I\r\n" – Invert the polarity of motor 1.

Clear motor inversion:

n = motor number, single or double digits

"M1C\r\n" – Set polarity of motor 1 to default.

Enable and disable Drivers "E" and "D"

The drivers boot in the disabled state so that other settings can be configured before beginning to drive the motors. Use these commands to enable and disable them.

"E\r\n" – Enable all outputs
"D\r\n" – Disable all outputs

Bridge and un-bridge outputs

"Brr" and "Nrr"
rr = Motor driver number, 0 is master, 1-16 is slave

This causes a motor driver to start or stop synchronous PWM on both 'A' and 'B' ports. Notice that the input is by board number, not motor number.

"B0\r\n" – Bridge master's outputs "B2\r\n" – Bridge the 2nd physical slave's outputs (motors 4&5) "N0\r\n" – Un-bridge master's outputs "N2\r\n" – Un-bridge the 2nd physical slave's outputs (motors 4&5)

Change the Baud Rate

n = baud rate selection

This command changes the bitrate of the UART. The serial terminal will need to be reconfigured after this command. The command reports new rate at old baud before changing to the new one.

Rates supported:
1 – 2400
2 – 4800
3 – 9600
4 – 14400
5 – 19200
6 – 38400
7 – 57600
8 – 115200

"U3\r\n" – Set baud rate to 9600
"U8\r\n" – Set baud rate to 115200

Write Register

rr = two digit hex address
hh = two digit hex data

"W20FF\r\n" – Write 0xFF to register 0x20 (MA_DRIVE).

Read Register

rr = two digit hex address

"R01\r\n" – Read address 0x01 (ID), bus will display "A9", ID word of 0xA9

Arbitrary register access Some of the more intricate features like bus settings and debug information can be accessed by reading from a user-facing memory space, called registers. Use the SCMD datasheet for mapping and function.