3.6. Changing serial settings with an Arduino

The Motoron’s default settings are sufficient for most applications consisting of one Motoron and one serial controller. If you do not have a specific reason to change a setting, you can skip this section.

Each Motoron with a UART serial interface has several settings for its serial interface that are stored in its non-volatile EEPROM memory and documented in Section 7. If you want to independently control multiple Motoron controllers from a single serial transmit line, you will need to assign a unique device number to each device using the procedure below. Another common reason to use the procedure below is if you want to use a baud rate other than the default rate of 115200 bps (bits per second).

If you need to change the settings in the EEPROM of a Motoron with a UART serial interface, the recommended procedure is:

  1. Connect a single Motoron to an Arduino or Arduino-compatible controller so that it can receive serial commands and send serial responses back to the Arduino. If you are not sure how to do this, refer to the Motoron library’s README.
  2. To successfully follow this procedure, you will need to know what baud rate your Motoron is using. It also helps if you know whether it is configured to use 7-bit responses and whether it is configured to use 14-bit device numbers. If you are not sure about the values the Motoron is currently using for any of those serial settings, then power cycle it (or reset it) while its JMP1 pin is shorted to GND. This causes the Motoron to use 9600 baud, 8-bit responses, and 7-bit device numbers until the next time it is reset.
  3. Install the Motoron Arduino library using the Arduino library manager. You can open the Library Manager from the “Tools” menu by selecting “Manage Libraries…”. If necessary, see the library’s README for more information about how to install it.
  4. Open the SerialSetup example. If the Motoron library is installed properly, you can find this example under Files > Examples > Motoron > SerialSetup.
  5. Find the line near the top of the code that defines assignBaudRate and other parameters. If you want your Motorons to be configured to use a baud rate other than 115200 bps, or if you want them to use non-default values for any of the other settings defined in this area of the code, then you should change the definitions there to match what you want.
  6. Upload the sketch to your Arduino.
  7. Open the Arduino IDE’s Serial Monitor, which you can find in the “Tools” menu. The top of the serial monitor contains a box where you can type commands and send them to the Arduino by pressing Enter.
  8. If your Motoron is currently using a baud rate other than the default of 115200 bps, use the Serial Monitor to send “b” followed by the baud rate in decimal (for example, “b9600”). This configures the Arduino to use the same baud rate so the Arduino can communicate with the Motoron.
  9. If your Motoron is currently using 7-bit responses or 14-bit device numbers, you should change the sketch to use the same settings so the sketch can detect the Motoron in the next step. To do this, type “o” and press Enter until the sketch reports the correct settings.
  10. To check your connections and configuration, send “i”. You should get output that looks something like this:
    Identifying Motoron controllers (115200 baud, 7-bit device number, 8-bit responses)…
     16: product=0x00CF version=1.02 JMP1=off EEPROM=10 00 00 00 00 8B 00 00 
    Done.  
    This particular output shows that a Motoron M2U256 with device number 16 was detected and its EEPROM still contains factory settings. Note that the “i” command can take several minutes if you are using 14-bit device numbers, because the code checks each device number, one at a time.
  11. Connect the JMP1 pin of the Motoron to GND. If you do not do this, the Motoron will ignore all commands that write to its EEPROM. This connection does not have to last for long, so it is OK to just hold it in place with your hand.
  12. Type “a” followed by the device number you want to assign to the Motoron, and optionally followed by the alternative device number you want to assign. This will write to the Motoron’s EEPROM, setting its device number, setting (or disabling) its alternative device number, and applying all the hardcoded settings that you set up step 5. For example send “a 17” to assign device number 17 and disable the alternative device number.
  13. Disconnect the JMP1 pin from GND.
  14. Send “r” using the Serial Monitor to reset the Motoron and make the new settings take effect. Alternatively you can power cycle the Motoron or reset it with its reset pin.
  15. To make sure the steps above worked and the Motoron is using the expected settings, you might want to send the “k” command followed by the “i” command. The “k” command tells the sketch to use the hardcoded serial settings that are being written to the Motorons, and “i” is the command to identify connected Motorons (as we already used above).
  16. Please note that most of the example code we provide is configured to use 115200 bps, use the Compact protocol (so all devices respond to the commands regardless of their device number), and use default values for all of the Motoron’s serial settings. If you change the serial settings of your Motoron, you will most likely need to configure your code to use the same settings. The documentation of the Motoron Arduino library (and in particular the MotoronSerial class) has information about the functions you can call to do that. The baud rate your code uses is not controlled by the Motoron library: it is controlled by the argument you pass when calling begin() on the serial port object.

Related Products

Motoron M3S256 Triple Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M1T550 Single I²C Motor Controller (Header Pins Soldered)
Motoron M3H550 Triple Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M3S550 Triple Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M1T256 Single I²C Motor Controller (Header Pins Soldered)
Motoron M2T256 Dual I²C Motor Controller (Header Pins Soldered)
Motoron M2H18v18 Dual High-Power Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M2S18v18 Dual High-Power Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M3H256 Triple Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M2T550 Dual I²C Motor Controller (Header Pins Soldered)

Related Categories

Motoron Motor Controllers
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors