This is a library for the Arduino IDE that helps interface with Motoron motor controllers using I²C or UART serial.
It supports the following Motoron controllers:
- Motoron M1T550 Single I²C Motor Controller
- Motoron M1U550 Single Serial Motor Controller
- Motoron M2T550 Dual I²C Motor Controller
- Motoron M2U550 Dual Serial Motor Controller
- Motoron M3S550 Triple Motor Controller Shield for Arduino
- Motoron M3H550 Triple Motor Controller for Raspberry Pi
- Motoron M1T256 Single I²C Motor Controller
- Motoron M1U256 Single Serial Motor Controller
- Motoron M2T256 Dual I²C Motor Controller
- Motoron M2U256 Dual Serial Motor Controller
- Motoron M3S256 Triple Motor Controller Shield for Arduino
- Motoron M3H256 Triple Motor Controller for Raspberry Pi
- Motoron M2S Dual High-Power Motor Controllers for Arduino (M2S18v20, M2S18v18, M2S24v16, M2S24v14)
- Motoron M2H Dual High-Power Motor Controllers for Raspberry Pi (M2H18v20, M2H18v18, M2H24v16, M2H24v14)
This library is designed to work with the Arduino IDE versions 1.8.x or later; we have not tested it with earlier versions. This library should support any Arduino-compatible board, including the Pololu A-Star controllers.
The Motoron motor controllers can be purchased from Pololu's website. Before continuing, careful reading of the Motoron user's guide is recommended.
To control a Motoron with its I²C interface (SCL and SDA), you will need to power the Motoron's logic and connect the Motoron to your board's I²C pins. Plugging the Motoron shield into a standard Arduino-compatible board achieves this.
If you are not plugging the Motoron in as a shield, you will need to connect the GND pins of both boards, connect the SDA pins of both boards, connect the SCL pins of both boards. You should also supply power to the Motoron's logic voltage pin (which is named VDD, IOREF, or 3V3) by connecting it to the logic voltage supply of your controller board, which should be between 3.0 V and 5.5 V.
To control a Motoron with a UART serial interface (RX and TX), you need to at least connect your board's TX pin (as defined in the table below) to the Motoron's RX pin, and connect your board's ground pin to one of the Motoron's GND pins. If you want to read information from the Motoron, you must also connect your board's RX pin to the Motoron's TX pin. You should also supply power to the Motoron's logic voltage pin (which is named VDD, IOREF, or 3V3) by connecting it to the logic voltage supply of your controller board, which should be between 3.0 V and 5.5 V.
The example sketches for this library use a hardware serial port on your Arduino
if one is available: if your Arduino environment defines
SERIAL_PORT_HARDWARE_OPEN
, the examples will use that port. The pins for this
serial port are different depending on which Arduino you are using.
Microcontroller Board | Hardware serial? | MCU RX pin | MCU TX pin |
---|---|---|---|
A-Star 32U4 | Yes | 0 | 1 |
A-Star 328PB | Yes | 12 | 11 |
Arduino Leonardo | Yes | 0 | 1 |
Arduino Micro | Yes | 0 | 1 |
Arduino Mega 2560 | Yes | 19 | 18 |
Arduino Due | Yes | 19** | 18 |
Arduino Uno | No | 10 | 11 |
Arduino Yun | No | 10 | 11 |
You can use the Library Manager to install this library:
- In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries...".
- Search for "Motoron Motor Controller".
- Click the Motoron entry in the list.
- Click "Install".
If this does not work, you can manually install the library:
- Download the latest release archive from GitHub and decompress it.
- Rename the folder "motoron-arduino-xxxx" to "Motoron".
- Drag the "Motoron" folder into the "libraries" directory inside your Arduino sketchbook directory. You can view your sketchbook location by opening the "File" menu and selecting "Preferences" in the Arduino IDE. If there is not already a "libraries" folder in that location, you should make the folder yourself.
- After installing the library, restart the Arduino IDE.
Several example sketches are available that show how to use the library. You can access them from the Arduino IDE by opening the "File" menu, selecting "Examples", and then selecting "Motoron". If you cannot find these examples, the library was probably installed incorrectly and you should retry the installation instructions above.
The main classes provided by this library are MotoronI2C and MotoronSerial. Each of these is a subclass of MotoronBase.
For complete documentation of this library, see the motoron-arduino documentation. If you are already on that page, then click the links in the "Classes" section above.
By default, the Motoron will turn off its motors if it has not received a valid command in the last 1.5 seconds. You can change the amount of time it takes for the Motoron to time out using MotoronBase::setCommandTimeoutMilliseconds() or you can disable the feature using MotoronBase::disableCommandTimeout().
- 1.4.0 (2023-06-09): Added support for the new 550 class Motorons.
The
getVinVoltageMv
method now takes an optionaltype
parameter to specify what scaling to apply. - 1.3.0 (2023-01-20): Added support for the M1T256 and M1U256 motorons.
- 1.2.0 (2022-12-16): Added support for the M2T256 and M2U256 motorons.
- 1.1.0 (2022-07-22): Added support for the M2S and M2H Motorons.
- 1.0.0 (2022-03-25): Original release.