4.2. Connecting a Serial Device
The serial pins make it possible to connect the Simple Motor Controller to a microcontroller (e.g. an A-Star, Orangutan Robot Controller, Arduino, or Basic Stamp) or other logic-level serial device, allowing for the creation of autonomous, self-contained systems. The following section explains the serial pins in detail (see Section 6 for information on using the serial interface).
Simple Motor Controller 18v7 serial connections.
Simple High-Power Motor Controller 18v15 or 24v12 serial connections.
Simple High-Power Motor Controller 18v25 or 24v23 serial connections.
Serial Connections Overview
The pins along the left side of the Simple Motor Controller can be used to communicate with devices with logic-level (TTL) serial interfaces, such as microcontrollers. As explained in Section 4.1, the Simple Motor Controller uses 3.3V logic, but all of the digital pins in the above diagrams (everything except for VIN and GND) are 5V-tolerant, which means that the Simple Motor Controller can be used directly with a microcontroller running at 5 V as long as that microcontroller is guaranteed to read a 3.3 V signal as high.
The Simple Motor Controller uses its RX and TX pins to receive and transmit asynchronous, logic-level (TTL), non-inverted serial signals with 8-bit characters and one stop bit (often expressed as 8-N-1). This is the type of serial typically used by microcontroller UART modules.
Whenever connecting devices, remember to wire the grounds together, and ensure that each device is properly powered. Unpowered devices with a TTL serial port can turn on or partially on, drawing power from the serial line, which means that extra care must be taken when turning power off and on to reset the devices.
Note: You must use an inverter and level shifter such as a MAX232 or a Pololu 23201a Serial Adapter if you want to interface an RS-232 device with the Simple Motor Controller. Connecting an RS-232 device directly to the Simple Motor Controller can permanently damage it.
Serial Interface Pin Descriptions
|Simple Motor Controller TTL serial receive pin. This should be connected to the TTL serial output (transmit line) of your other device. This connection is only required if you want to send serial commands to the motor controller from your other device.
|Simple Motor Controller TTL serial transmit pin. This should be connected to the TTL serial input (receive line) of your other device. This connection is only required if you want to receive serial feedback from the motor controller.
|Simple Motor Controller active-low reset pin. This pin is internally pulled high; driving it low resets the motor controller. You must wait for at least 1 ms after a reset to transmit to the Simple Motor Controller. This pin can be left disconnected in most applications.
|Simple Motor Controller error output. This pin outputs high when there is an error that is stopping the motor, turning on the red error LED in the process; otherwise, it is weakly pulled low. This pin is documented in more detail below.
|Simple Motor Controller chained transmission input pin. Connecting the transmit output of another serial device to this pin will cause that device’s transmissions to be output from the Simple Motor Controller’s TX pin. This pin is documented in more detail below.
|Ground connection point. Your serial device must share a common ground with the Simple Motor Controller.
|Board power access point. This pin is internally connected to the large VIN pad where motor power is supplied and can be used to power other components in the system, but it should not be used to supply more than 500 mA. This is not a regulated, logic-level output.
These pins have a 0.1" spacing.
Simple Wiring Example: Connecting to a Microcontroller
All you need to control the Simple Motor Controller with a microcontroller is a connection between the microcontroller’s TTL serial transmit pin and the Simple Motor Controller’s RX pin. If you want to get feedback from the controller, you can connect the TX pin to the microcontroller’s TTL serial receive pin and/or connect the ERR pin to one of the microcontroller’s digital inputs. Connecting one of the microcontroller’s digital outputs to the RST pin allows the microcontroller to selectively reset the Simple Motor Controller.
The ERR Pin in Detail
One function of the ERR pin is to communicate that an error is preventing the motor from moving. When such an error occurs, the red error LED turns on and the ERR pin outputs 3.3 V. When there are no errors stopping the motor, the ERR pin is pulled low and the red error LED is off. Because the ERR pin never drives low, it is safe to connect the ERR pins of multiple Simple Motor Controllers to the same microcontroller input. If any one of those controllers experiences an error, the microcontroller error input goes high and the error LEDs of all connected Simple Motor Controllers light up.
By default, the ERR pin is also configured to serve as an input that stops the motor when externally driven above 2.3 V. This means that the error lines of multiple Simple Motor Controllers can be connected together and all motor controllers will shut down their motors when any one motor controller experiences an error. This technique of connecting error lines can be used even when RC signals or analog voltages are used to control the motors. An example of this can be seen in Section 4.3.
The following diagrams show the internal circuitry of the ERR pin in the error case (driving high to report an error) and in the error-free case (pulled low and configured as an input):
The TXIN Pin in Detail
The TXIN pin is a special input that allows multiple Simple Motor Controllers to be chained together without requiring an external AND gate. The following diagram shows how multiple motor controllers can be connected to a single microcontroller UART:
Wiring diagram for controlling multiple Simple Motor Controllers with single TTL serial source, such as a microcontroller.
Inside each Simple Motor Controller, an AND gate is used to combine the input from the TXIN pin with the controller’s serial transmissions. As long as only one chained controller is transmitting at any given time, the above method of chaining will funnel the transmissions of all chained devices to a single microcontroller receive line. The following diagram shows the internal circuitry of the TX and TXIN pins:
Schematic diagram of the Simple Motor Controller TXIN and TX pins.
See Section 6.6 for more information on connecting multiple controllers on the same serial line.