Difference between revisions of "ROBOTIS DYNAMIXEL XL330 PID Example"

From Lofaro Lab Wiki
Jump to: navigation, search
(Code Explanation (Assuming Dynamixel library is already installed))
(Code Explanation (Assuming Dynamixel library is already installed))
Line 25: Line 25:
 
Note: No matter what we are trying to do, when using the DYNAMIXEL hardware components, we must always import the DYNAMIXEL library. This means that the Dynamixel2 library must be installed from this website:
 
Note: No matter what we are trying to do, when using the DYNAMIXEL hardware components, we must always import the DYNAMIXEL library. This means that the Dynamixel2 library must be installed from this website:
 
* [http://files.lofarolabs.com/software/Dynamixel2Arduino-master.zip http://files.lofarolabs.com/software/Dynamixel2Arduino-master.zip]
 
* [http://files.lofarolabs.com/software/Dynamixel2Arduino-master.zip http://files.lofarolabs.com/software/Dynamixel2Arduino-master.zip]
 +
 +
==Changing the Actuator ID==
 +
Since this tutorial requires two actuators, one of the actuator’s ID must be changed. Please note: that this tutorial will only change the ID of one of the IDs at a time. Please unplug one of the three string cables from the actuator. Furthermore, the default ID is 1.
 +
 +
===Setup serial ports===
 +
Because DYNAMIXEL runs on half-duplex, we must use pin A6 to turn the full-duplex communication into half duplex.
 +
 +
===Define the ID===
 +
(default = 1), protocol version, and baud rate, and initial values of our positions
 +
Note: creating a constant variable that holds the default ID will be used to identify the actuator whose ID needs to be changed.
 +
 +
Pos_d and pos_e are used to acquire each actuator’s current position. Here we are just initializing them to zero.
 +
 +
===Create an object of Dynamixel2Arduino type called dxl===
 +
 +
===Setup the control table===
 +
This control table is extremely important as it grants us access to the registers that regulate the values of the P gain and D gain. We are in essence writing to registers within this overall control table.

Revision as of 22:41, 16 September 2021

Prerequisites

To utilize this tutorial, the assumption is made that you have the following:

  • 1x DYNAMIXEL Shield for Arduino MKR Series (MKR Zero Preferred)
  • 1x Arduino MKR compatible device: Please note that this tutorial uses the MKR ZERO
  • 1xCompatible 1S LiPo battery with a JST2.0 connector
  • Nx DYNAMIXEL XL330-M288-T ROBOTIS actuators where N >= 2
  • 1x Micro-USB to USB-A Cable Overview

This tutorial gives examples of how to change the P gain, D gain, and, in the process, change the actuator ID of the XL330-M288-T ROBOTIS actuators when connected to the DYNAMIXEL Shield for MKR.

Tutorial

Written Explanation

To perform this tutorial the following steps must be completed:

  1. Put the DYNAMIXEL shield on top of the Arduino MKR Zero. The ports should exactly match each other. For instance, 5volts from the DYNAMIXEL shield should go into the 5volt channel of the MKR zero and so on.
  2. Connect one of the three stringed wires that came with the DYNAMIXEL actuator to the actuator. Please take care in how you attach the cable as the cable should easily fit into the connection port for the actuator.
  3. Please connect the other end of that wire to port DXL_T1 of the DYNAMIXEL shield.
  4. Once the cable has been attached from one actuator to the DYNAMIXEL shield, connect another 3 stringed cable into the other port on that same XL330 actuator.
  5. Connect the other end to a second XL330 actuator.
  6. Connect the fully charged 1S batter to the JSt2.0 battery port on the DYNAMIXEL shield. Note: this will power the actuators only!
  7. Connect the Micro-USB to USB-A cable to the MKR Zero.
  8. Connect the other end to the USB port of your computer.


Code Explanation (Assuming Dynamixel library is already installed)

Note: No matter what we are trying to do, when using the DYNAMIXEL hardware components, we must always import the DYNAMIXEL library. This means that the Dynamixel2 library must be installed from this website:

Changing the Actuator ID

Since this tutorial requires two actuators, one of the actuator’s ID must be changed. Please note: that this tutorial will only change the ID of one of the IDs at a time. Please unplug one of the three string cables from the actuator. Furthermore, the default ID is 1.

Setup serial ports

Because DYNAMIXEL runs on half-duplex, we must use pin A6 to turn the full-duplex communication into half duplex.

Define the ID

(default = 1), protocol version, and baud rate, and initial values of our positions Note: creating a constant variable that holds the default ID will be used to identify the actuator whose ID needs to be changed.

Pos_d and pos_e are used to acquire each actuator’s current position. Here we are just initializing them to zero.

Create an object of Dynamixel2Arduino type called dxl

Setup the control table

This control table is extremely important as it grants us access to the registers that regulate the values of the P gain and D gain. We are in essence writing to registers within this overall control table.