Difference between revisions of "ROBOTIS DYNAMIXEL XL330 PID Example"

From Lofaro Lab Wiki
Jump to: navigation, search
(Created page with "<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>Microsoft Word - Change in PID Gain</title><meta na...")
 
Line 1: Line 1:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>Microsoft Word - Change in PID Gain</title><meta name="author" content="dmanc"/><style type="text/css"> * {margin:0; padding:0; text-indent:0; }
+
=Prerequisites=
.p, p { color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: normal; text-decoration: none; font-size: 10pt; margin:0pt; }
+
To utilize this tutorial, the assumption is made that you have the following:
.s1 { color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: normal; text-decoration: underline; font-size: 10pt; }
+
* 1x DYNAMIXEL Shield for Arduino MKR Series (MKR Zero Preferred)
h2 { color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: bold; text-decoration: none; font-size: 10pt; }
+
* 1x Arduino MKR compatible device: Please note that this tutorial uses the MKR ZERO
.s2 { color: black; font-family:"Courier New", serif; font-style: normal; font-weight: normal; text-decoration: none; font-size: 10pt; }
+
* 1xCompatible 1S LiPo battery with a JST2.0 connector
.s3 { color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: bold; text-decoration: underline; font-size: 10pt; }
+
* Nx DYNAMIXEL XL330-M288-T ROBOTIS actuators where N >= 2
.s4 { color: black; font-family:Arial, sans-serif; font-style: normal; font-weight: bold; text-decoration: none; font-size: 10pt; }
+
* 1x Micro-USB to USB-A Cable Overview
h1 { color: black; font-family:Arial, sans-serif; font-style: normal; font-weight: bold; text-decoration: none; font-size: 11pt; }
+
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.
li {display: block; }
+
#l1 {padding-left: 0pt; }
+
#l1> li>*:first-child:before {content: "• "; color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: normal; text-decoration: none; font-size: 10pt; }
+
#l2 {padding-left: 0pt; }
+
#l2> li>*:first-child:before {content: "• "; color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: normal; text-decoration: none; font-size: 10pt; }
+
#l3 {padding-left: 0pt;counter-reset: c3 1; }
+
#l3> li>*:first-child:before {counter-increment: c3; content: counter(c3, decimal)") "; color: black; font-family:"Times New Roman", serif; font-style: normal; font-weight: normal; text-decoration: none; font-size: 10pt; }
+
#l3> li:first-child>*:first-child:before {counter-increment: c3 0;  }
+
</style></head><body><p style="padding-top: 3pt;padding-left: 161pt;text-indent: 0pt;text-align: left;">Change in PID Gain (P Gain + D Gain)</p><p class="s1" style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">Prerequisites</p><p style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">To utilize this tutorial, the assumption is made that you have the following:</p><ul id="l1"><li><p style="padding-top: 9pt;padding-left: 42pt;text-indent: -18pt;text-align: left;">1x DYNAMIXEL Shield for Arduino MKR Series (MKR Zero Preferred)</p></li><li><p style="padding-top: 1pt;padding-left: 42pt;text-indent: -18pt;text-align: left;">1x Arduino MKR compatible device: Please note that this tutorial uses the MKR ZERO</p></li><li><p style="padding-top: 1pt;padding-left: 42pt;text-indent: -18pt;text-align: left;">1xCompatible 1S LiPo battery with a JST2.0 connector</p></li><li><p style="padding-top: 1pt;padding-left: 42pt;text-indent: -18pt;text-align: left;">Nx DYNAMIXEL XL330-M288-T ROBOTIS actuators where N &gt;= 2</p></li><li><p style="padding-top: 1pt;padding-left: 6pt;text-indent: 18pt;line-height: 177%;text-align: left;">1x Micro-USB to USB-A Cable <u>Overview</u></p><p style="padding-left: 6pt;text-indent: 0pt;line-height: 107%;text-align: left;">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.</p><p class="s1" style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">Tutorial</p><ul id="l2"><li><p style="padding-top: 9pt;padding-left: 46pt;text-indent: -18pt;text-align: left;">Wiring Explanation</p><p style="padding-left: 46pt;text-indent: 0pt;text-align: left;">To perform this tutorial the following steps must be completed:</p><ol id="l3"><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 108%;text-align: left;">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.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 107%;text-align: left;">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.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;text-align: left;">Please connect the other end of that wire to port DXL_T1 of the DYNAMIXEL shield.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 109%;text-align: left;">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.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 11pt;text-align: left;">Connect the other end to a second XL330 actuator.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 109%;text-align: left;">Connect the fully charged 1S batter to the JSt2.0 battery port on the DYNAMIXEL shield. Note: this will power the actuators only!</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;line-height: 11pt;text-align: left;">Connect the Micro-USB to USB-A cable to the MKR Zero.</p></li><li><p style="padding-left: 64pt;text-indent: -18pt;text-align: left;">Connect the other end to the USB port of your computer.</p><p style="text-indent: 0pt;text-align: left;"><br/></p></li></ol></li><li><p style="padding-left: 46pt;text-indent: -18pt;text-align: justify;">Code Explanation <b>(Assuming Dynamixel library is already installed)</b></p></li></ul></li></ul><p style="padding-top: 1pt;padding-left: 46pt;text-indent: 0pt;line-height: 108%;text-align: justify;">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:</p><p style="padding-left: 46pt;text-indent: 0pt;line-height: 216%;text-align: justify;">http://files.lofarolabs.com/software/Dynamixel2Arduino-master.zip #include &lt;Dynamixel2Arduino.h&gt;</p><p class="s2" style="padding-left: 64pt;text-indent: 0pt;text-align: left;">o <span class="p">Changing the Actuator ID</span></p><p style="padding-left: 82pt;text-indent: 0pt;line-height: 108%;text-align: left;">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. <b>Please unplug one of the three string cables from the actuator. </b>Furthermore, the default ID is 1.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Setup serial ports</h2><p style="padding-left: 82pt;text-indent: 0pt;line-height: 109%;text-align: left;">Because DYNAMIXEL runs on half-duplex, we must use pin A6 to turn the full-duplex communication into half duplex.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><span><img width="618" height="46" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_001.jpg"/></span></p><h2 style="padding-top: 4pt;padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Define the ID (default = 1), protocol version, and baud rate, and initial values of our positions</h2><p style="padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Note: creating a constant variable that holds the default ID will be used to identify the actuator whose ID needs to be changed.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 86pt;text-indent: 0pt;text-align: left;"><span><img width="274" height="51" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_002.jpg"/></span></p><p style="padding-top: 3pt;padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Pos_d and pos_e are used to acquire each actuator’s current position. Here we are just initializing them to zero.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-bottom: 4pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">Create an object of Dynamixel2Arduino type called dxl</h2><p style="padding-left: 86pt;text-indent: 0pt;text-align: left;"><span><img width="343" height="23" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_003.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Setup the control table</h2><p style="padding-left: 82pt;text-indent: 0pt;line-height: 108%;text-align: left;">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.</p><p style="padding-left: 86pt;text-indent: 0pt;line-height: 11pt;text-align: left;"><span><img width="231" height="15" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_004.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Inside the setup function</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-top: 4pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">Create the variable that will hold your new ID for your actuator.</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 86pt;text-indent: 0pt;line-height: 11pt;text-align: left;"><span><img width="149" height="14" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_005.jpg"/></span></p><h2 style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Set the baud rate, define it for your dxl object, and define your protocol version</h2><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;"><span><img width="603" height="41" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_006.jpg"/></span></p><h2 style="padding-top: 3pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">Turn off the torque and set your new ID</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 86pt;text-indent: 0pt;text-align: left;"><span><img width="399" height="84" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_007.jpg"/></span></p><p style="padding-top: 2pt;padding-left: 82pt;text-indent: 5pt;line-height: 107%;text-align: left;">Note: from here on out, your actuator that used to have the ID of 1 now has an ID of 150. Therefore, any reference to it other than 150 will not be recognized by the program.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Inside the loop function</p><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Please leave the loop empty.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Acknowledgement about changing ID</p><p style="padding-left: 82pt;text-indent: 0pt;line-height: 108%;text-align: left;">All that will happen is that the ID will change. The ID has now been changed from 1 to 150. Please repeat these steps, however. Set new_id = 100 instead of 150. <b>Please replace the actuator with ID =150 with an actuator with ID =1. </b>This will change the ID from 1 to 100.</p><p style="padding-top: 3pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">After the second run, you should have two actuators. One should have ID = 100 and the other ID</p><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;">= 150.We may now begin to change the gains!</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s2" style="padding-left: 64pt;text-indent: 0pt;text-align: left;">o <span class="p">Changing P gain and D gain</span></p><p style="padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Note: our loop will not remain empty, and we will be building on top of the code that was used to change the ID.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 82pt;text-indent: 0pt;text-align: left;">Back inside the setup loop</p><h2 style="padding-bottom: 3pt;padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Change the baud rate, set the operating modes and turn the torque on for both the actuators</h2><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;"><span><img width="492" height="82" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_008.jpg"/></span></p><p style="padding-top: 3pt;padding-left: 82pt;text-indent: 0pt;line-height: 108%;text-align: left;">Note: It was brought to my attention that I should not limit the velocity value to a maximum value. This will limit some of the affects that changing the pid gain will have on the actuators. I received my values before realizing that a more noticeable output could be produced if the velocity wasn’t limited. My tutorial limits the velocity, however, for more pronounced outputs, ignore the next step.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;"><span><img width="584" height="26" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_009.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">Using the control table, as mentioned before, we can write to the P gain register and the D gain register to write a value to it.</p><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;"><span><img width="489" height="57" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_010.png"/></span></p><p style="padding-top: 1pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">*We have now changed the P gain and D gain and are exiting the setup loop.</p><p style="padding-bottom: 3pt;padding-left: 82pt;text-indent: 0pt;line-height: 108%;text-align: left;">Create variables that will be used to toggle between 0 degrees and 90 degrees. Also, create a variable that will be used as our goal position and define a variable that will be used to iterate up to 150 intervals.</p><p style="padding-left: 82pt;text-indent: 0pt;text-align: left;"><span><img width="328" height="82" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_011.jpg"/></span></p><p class="s3" style="padding-top: 4pt;padding-left: 82pt;text-indent: 0pt;text-align: left;">Loop function</p><p style="padding-top: 1pt;padding-bottom: 3pt;padding-left: 82pt;text-indent: 0pt;line-height: 107%;text-align: left;">We are using GOAL_POS_I_MAX to iterate up to 150 times. (This translates to a 3 second delay). During those 3 seconds, we are going to toggle between 0 degrees and 90 degrees.</p><p style="padding-left: 86pt;text-indent: 0pt;text-align: left;"><span><img width="347" height="129" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_012.jpg"/></span></p><p style="padding-top: 9pt;padding-bottom: 4pt;padding-left: 81pt;text-indent: 0pt;text-align: center;">After toggling the actuator’s angle of degree, acquire the position of each actuator and print it.</p><p style="padding-left: 86pt;text-indent: 0pt;text-align: left;"><span><img width="389" height="133" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_013.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s1" style="padding-left: 6pt;text-indent: 0pt;text-align: left;">Examples</p><h2 style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">P Gain</h2><p style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;line-height: 108%;text-align: left;">The P gain determines how forcefully the actuator responds to its position command. Higher P gains cause the actuator to reach its position quicker and with more accuracy. Lower P gains cause the actuator to be more slack in its response to the position command so the movement will be slower and less accurate. These actuators have a maximum P gain of 16,383 and the factory or default setting is 400.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="453" height="196" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_014.jpg"/></span></p><h2 style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">No Change to p-gain or d-gain (for reference) Fig. 1</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="502" height="183" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_015.png"/></span></p><h2 style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">Fig 2:P gain is 1200 P                                                                                            Fig3. Closeup of P = 1200</h2><h2 style="padding-left: 6pt;text-indent: 0pt;text-align: left;">D gain is default value (0)</h2><p style="padding-top: 3pt;padding-left: 6pt;text-indent: 0pt;line-height: 108%;text-align: left;">On this graph, the blue line represents the control actuator with P gain of 400. But the other actuator’s p gain is 1200. Notice the overshoot of the red line because the increased P gain is making the actuator respond more aggressively to the position command.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 306pt;text-indent: 0pt;text-align: left;"><span><img width="61" height="62" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_016.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><span><img width="335" height="166" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_017.jpg"/></span></p><h2 style="padding-left: 294pt;text-indent: 0pt;text-align: left;">Fig 5. Closup of P = 3000</h2><h2 style="padding-top: 8pt;padding-left: 78pt;text-indent: 0pt;text-align: left;">Fig4. P Gain = 3000</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 6pt;text-indent: 0pt;line-height: 108%;text-align: justify;">In Figures 4 and 5, the control actuator has a p gain of 400 but increased the P gain for the other actuator to 3000. Notice, the overshoot of the red line, representing the 3000 P gain. The actuator responded so aggressively to the position command that it overshot the goal position but then readjusted itself.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="300" height="154" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_018.jpg"/></span> <span><img width="102" height="82" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_019.jpg"/></span></p><h2 style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: justify;">Fig. 6 P gain = 6000 Fig. 7 Closeup of P gain = 6000</h2><p style="padding-top: 9pt;padding-left: 6pt;text-indent: 0pt;line-height: 107%;text-align: justify;">In figures, 6 and 7, I increased the actuator from 3000 to 6000. There is even more oscillation after the overshoot, showing that the 6000 P gain caused the actuator to respond with an even greater amount of force than the 3000 P gain.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="343" height="164" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_020.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 6pt;text-indent: 0pt;text-align: justify;">Fig. 8 P gain = 9000</h2><p style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;line-height: 107%;text-align: justify;">This graph shows the P gain of the actuator increased from 6000 to 9000. The actuator responded so aggressively that it was constantly overshooting and having to readjust. This is why there are constant zigzag lines showing the</p><p style="padding-top: 3pt;padding-left: 6pt;text-indent: 0pt;line-height: 107%;text-align: left;">actuator trying to readust itself to obtain the goal position. Even though the manual says that the max p gain is 16383, I didn’t go past 9000 because I didn’t want to break the actuator since it was going out of control at 9000.</p><h2 style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">D gain</h2><p style="text-indent: 0pt;text-align: left;"><span><img width="320" height="157" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_021.jpg"/></span></p><h2 style="padding-top: 9pt;padding-left: 253pt;text-indent: 0pt;line-height: 177%;text-align: left;">P Gain = 3000 D Gain = 2000 (Control) P Gain = 3000 D Gain = 0 Fig. 9</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><span><img width="62" height="53" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_022.jpg"/></span></p><h2 style="padding-left: 89pt;text-indent: 0pt;text-align: left;">Fig. 10 <span class="s4">P Gain = 3000 D Gain = 2000 (close up)</span></h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 6pt;text-indent: 0pt;line-height: 108%;text-align: left;">The D gain is short for the derivative gain. The derivative gain can be likened to brakes on a car because the D gain causes the actuator to slow down as it reaches its desired position. To show the affect that the D gain has, I set both p gain of both actuators at 3000 so that each will have an overshoot. The control actuator will have a d gain of zero and I will increase the D gain of the other actuator to show how the brakes being applied will lessen the overshoot. Figs. 9 and 10, on the left shows the D Gain of one of the actuators increased to 2000. Notice that the red line doesn’t have as big of an overshoot as the blue line because the D gain is higher for that actuator.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="253" height="123" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_023.jpg"/></span> <span><img width="80" height="86" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_024.jpg"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><h1 style="padding-left: 6pt;text-indent: 0pt;text-align: left;">Fig. 11 P Gain = 3000 D Gain = 3000                Fig. 12 P Gain = 3000 D Gain = 3000 (close up)</h1><h2 style="padding-top: 1pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">(Control) P Gain = 3000 D gain = 0</h2><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;line-height: 107%;text-align: left;">In Fig. 11 and 12, the graph represents the d gain of the actuator being increased to 3000. That increase in D gain almost completely eliminated the overshoot.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s1" style="padding-top: 4pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">Code</p><p style="text-indent: 0pt;text-align: left;"><span><img width="618" height="387" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_025.png"/></span></p><p class="s3" style="padding-top: 8pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">change_id (Only)</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s1" style="padding-top: 4pt;padding-left: 6pt;text-indent: 0pt;text-align: left;">Full Code</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="590" height="404" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_026.jpg"/></span></p><p style="padding-left: 5pt;text-indent: 0pt;text-align: left;"><span><img width="597" height="777" alt="image" src="https://www.file.lofaro.net/wiki/robotis/pid/PID_Gain_files/Image_027.png"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s1" style="padding-top: 4pt;padding-left: 6pt;text-indent: 0pt;line-height: 177%;text-align: left;">Video<span class="p"> https://youtu.be/TqI9bkx-RoM</span></p></body></html>
+

Revision as of 22:35, 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.