RoboClaw Motor Driver Arduino Support Package Addon

Arduino Hardware Support Addon for RoboClaw Motor Diver
1 Download
Updated 10 Dec 2024

View License

Greetings!
The RoboClaw 2x60A Motor Controller is a versatile and robust device designed to control two brushed DC motors, delivering 60 amps continuously and up to 120 amps peak per channel. It supports multiple control interfaces, including USB, RC radio, PWM, TTL serial, analog, and microcontrollers such as Arduino or Raspberry Pi, making it adaptable to various applications.
Key features of the RoboClaw 2x60A include:
  • Dual Quadrature Encoder Support: Handles up to 19.6 million pulses per second, enabling precise position and velocity control.
  • Advanced Protection Mechanisms: Includes safeguards against temperature extremes, over-current, over-voltage, and under-voltage conditions to ensure reliable operation.
  • Built-in Commands: Offers commands for controlling acceleration, deceleration, distance, speed, current sensing, and voltage limits, providing comprehensive control over motor operations.
This MATLAB package facilitates seamless integration between MATLAB and the RoboClaw 2x60A Motor Controller connected to an Arduino Serial Port, allowing users to leverage MATLAB's computational and visualization capabilities for advanced motor control applications. By providing a user-friendly interface, it simplifies the process of implementing complex control algorithms and data analysis, making it a valuable tool for researchers, engineers, and hobbyists working on robotics and automation projects.
Installation:
  • Download the RoboClaw Arduino Library and save it to an easy to find location (e.g. Desktop or Downloads).
  • Do NOT Unzip!
  • Find the location where you need to install the libraries by running the following command in the MATLAB® Command window.
CLIPath = arduinoio.CLIRoot
  • Navigate to that directory on your host machine
  • Edit the arduino-cli.yaml file to enable zip files (change from false to true)
  • Run the command as shown
Windows®
arduino-cli.exe lib install --zip-path <WHERE/YOU/SAVED/THE/FILE/RoboClaw.zip --config-file arduino-cli.yaml
For Mac with Intel® or Apple Silicon Processor and Linux®
./arduino-cli lib install --zip-path <WHERE/YOU/SAVED/THE/FILE/RoboClaw.zip --config-file arduino-cli.yaml
  • Follow the documentation found here to create the needed folders with specific naming conventions.
  • Simply extract the zip file downloaded from this File Exchange and paste it into the +arduinoioaddons folder
  • The result should look like this once complete:
Usage:
  • You will need to follow the wiring instructions relevant to your motors and encoders.
  • You will need to connect a jumper from the Arduino GND to any of the GND pins on the RoboClaw
  • You will need to connect a jumper from SerialPort 1 TX pin on the Arduino to the S1 outer pin (NOT +/-)
  • You will need to connect a jumper from the SerialPort 1 RX pin on the Arduino to the S2 outer pin (NOT +/-)
  • Run this command first to create an Aruino Object
a = arduino('COM4', 'Mega2560', 'Libraries', {'BasicMicro/RoboClawML'}, 'ForceBuildOn', true)
  • Next run a command to create a RoboClaw Object
Foward Commands are Greater than 65 and no more than 127
Reverse Commands are less than 63 and no less than 0
A value of the 64 will stop the motors
rc.cmdForwardBackwardM2(69) % Really Slow Forward
rc.cmdForwardBackwardM1(69) % Really Slow Forward
rc.cmdForwardBackwardM2(55) % Really Slow Reverse
rc.cmdForwardBackwardM1(55) % Really Slow Reverse
rc.cmdForwardBackwardM2(127) % Max Speed Forward
rc.cmdForwardBackwardM1(127) % Max Speed Forward
rc.cmdForwardBackwardM2(0) % Max Speed Reverse
rc.cmdForwardBackwardM1(0) % Max Speed Reverse
rc.cmdForwardBackwardM2(64) % Really Slow Stop
rc.cmdForwardBackwardM1(64) % Really Slow Stop
rc.cmdResetEncoders() % Reset Both Encoders
rc.cmdReadEncoderM1() % Read Encoder for M1
rc.cmdReadEncoderM2() % Read Encoder for M2
There are some bugs with the Encoder readings at the moment that I am trying to solve. If you find a solution please share!
I spent two weeks learning how to make this and really hope you will benifit from this effort!
Cheers,

Cite As

Clayton Allen (2025). RoboClaw Motor Driver Arduino Support Package Addon (https://www.mathworks.com/matlabcentral/fileexchange/177139-roboclaw-motor-driver-arduino-support-package-addon), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

+BasicMicro

Version Published Release Notes
1.0.1

- Added the ability to read speeds from motor 1 and motor 2
- Switch from uint32 to int32 because speeds and encoder readings can become signed integers
- Changed to baud rate of 115200 from 38400 for more reliability and timing.

1.0.0