Configure a RoboClaw-Controlled Motor
The roboclaw
model of the motor component supports standard brushed DC motors driven by Basicmicro’s RoboClaw motor controller.
Note
You must set up your RoboClaw before configuring it.
Make note of the baud rate that you set up during this process.
The default is 38400
.
Follow this guide to do so.
To use a roboclaw
motor as a component of your machine, first wire your DC motor to the RoboClaw motor driver, and wire the driver to a board.
Connect the system to power if you want to test it while configuring.
Configure the board to which the motor driver is wired.
Then configure the motor:
Navigate to the CONFIGURE tab of your machine’s page in the Viam app.
Click the + icon next to your machine part in the left-hand menu and select Component.
Select the motor
type, then select the roboclaw
model.
Enter a name or use the suggested name for your motor and click Create.
Edit and fill in the attributes as applicable.
{
"components": [
{
"name": "<your-roboclaw-motor-name>",
"model": "roboclaw",
"type": "motor",
"namespace": "rdk",
"attributes": {
"serial_path": "<your-serial-path>",
"motor_channel": <int>,
"serial_baud_rate": <int>
},
"depends_on": []
}
]
}
Example configuration for a roboclaw
DC brushed motor:
{
"components": [
{
"name": "your-roboclaw-motor",
"model": "roboclaw",
"type": "motor",
"namespace": "rdk",
"attributes": {
"serial_path": "/dev/serial/by-path/usb-0:1.1:1.0",
"motor_channel": 1,
"serial_baud_rate": 38400
},
"depends_on": []
}
]
}
The "serial_path"
filepath used in this example is specific to serial devices connected to Linux systems.
The "serial_path"
filepath on a macOS system might resemble
The following attributes are available for roboclaw
motors:
Name | Type | Required? | Description |
---|---|---|---|
serial_path | string | Required | The full filesystem path to the serial device, starting with
|
serial_baud_rate | int | Optional | Rate to send data over the serial line. This must match the baudrate you have set up using basicmicro’s setup program. You cannot have multiple roboclaw motors with different baud rates.Default: 38400 |
motor_channel | int | Required | Channel the motor is connected to on the controller. Must be 1 or 2 . |
address | int | Optional | Serial address of the controller. Default: 128 |
ticks_per_rotation | int | Optional | Number of full steps in a rotation. Update this if you connect encoders to your controller through its EN1 and EN2 pins. Default: 0 |
Refer to your motor and motor driver data sheets for specifics.
Test the motor
Once your motor is configured and connected, open the motor’s TEST panel on the CONFIGURE or CONTROL tabs. Use the buttons to try turning your motor forwards or backwards at different power levels and check whether it moves as expected.
If the motor does not appear on the TEST panel, or if you notice unexpected behavior, check your machine’s LOGS tab for errors, and review the configuration.
Troubleshooting
If your motor is not working as expected, follow these steps:
- Check your machine logs on the LOGS tab to check for errors.
- Review this motor model’s documentation to ensure you have configured all required attributes.
- Check that all wires are securely attached to the correct pins.
- Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the motor there.
If none of these steps work, reach out to us on the Community Discord and we will be happy to help.
Next steps
For more configuration and usage info, see:
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!