====== How To Move Gantry Using Visual Studio C++ ======
**Author:** Yunki Hong and Myong Geon Kim Email: m.geon.kim@gmail.com
\\
**Date:** Last modified on <06/20/19>
\\
**Keywords:** Tutorial, how to, step-by-step, gantry, CPP, intern
\\
{{ mgkim:gantry_1.jpg?600 |}}
===== Motivation and Audience =====
\\
\\
\\
This tutorial offers you the step-by-step method to control DASL Gantry crane with modifying Dynamixel SDK in Windows environment.
\\
\\
\\
\\
\\
Readers of this tutorial assumes the reader has the following background and interests:
\\
* Basic background of CPP \\
* Full understanding of Dynamixel tutorial : [[dynamixel_set_up|Dynamixel tutorial]] \\
* Full understanding of Modifying Dynamixel SDK code : [[dynamixel_modification|Modifying Dynamixel SDK code]]
\\
\\
The rest of this tutorial is presented as follows:
\\
* [[how_to_move_gantry#gantry_set_up|Gantry Set Up]] \\
* [[how_to_move_gantry#moving_x_axis|Moving X axis]] \\
* [[how_to_move_gantry#moving_backward|Moving Backward]] \\
* [[how_to_move_gantry#moving_all_axis|Moving All axis]] \\
* [[how_to_move_gantry#go_home|How to go back home]] \\
* [[how_to_move_gantry#accuracy|Accuracy]] \\
* Final Words
\\
\\
==== Gantry Set Up ====
\\
\\
First of all, Dynamixels installed in DASL Gantry are MX-106 model. You should check control table for MX-106.
\\
Here is the link. http://emanual.robotis.com/docs/en/dxl/mx/mx-106/
\\
You would find that there is no address or parameter difference between MX-28, Fortunately.
\\
\\
We are going to use this power supply for Gantry because we can switch off the power when we need an emergency stop.
\\
{{ mgkim:ds_18.jpg?200 |}}
\\
\\
Just turn the switch backward for an emergency stop
\\
\\
\\
The photo below is the basic structure of gantry system.
\\
{{ mgkim:ds_16.jpg?200 |}}
\\
You need to measure some dimensions of this system for distance control.
\\
{{ mgkim:ds_17.jpg?200 |}}
\\
This photo will help you to understand the system.
\\
\\
==== Moving X axis ====
\\
\\
For moving gantry to x axis, we will use Dynanixel #1,2
\\
In gantry system, rotation angle of Dynamixel during sleep time will be changed to displacement of belt.
\\
So we need to do measurement and calculation to move gantry.
\\
If we know exact distance between each teeth in the belt and gear,
\\
we can calculate displacement of belt accurately.
\\
\\
- Measurement
\\
\\
G1 = 28 teeth , G2 = 14 teeth, G3 = 24 teeth
\\
Distance between teeth = 5mm = 0.5 cm
\\
1 dynamixel speed unit = 0.11445 rpm
\\
\\
- Calculation
\\
\\
{{ mgkim:ds_19.jpg?600 |}}
{{ mgkim:ds_20.jpg?600 |}}
\\
\\
Now we know sleep time we need.
\\
\\
\\
=======================================================================================================
\\
\\
Exercise. Using only Gantry Dynamixel #1 and #2, make Dynamixels actuate until they reach to desired distance.
\\
Set the moving speed value as 200 (Gantry will not work if the moving speed is too high).
\\
\\
Here is an {{https://drive.google.com/file/d/1fj95C_-Pr8NK6m9B8G-3SAEY4oNIW3Ph/view?usp=sharing|answer}}
\\
\\
=======================================================================================================
\\
\\
\\
==== Moving Backward ====
\\
\\
Problem of previous code is that gantry can not move backward.
\\
How can we modify code to move backward?
\\
\\
Discover the method in this code.
{{https://drive.google.com/file/d/1_2MN9d0GRw5eQWwrcQUP9LzIKec4Tt1c/view?usp=sharing|Moving backward}}
\\
\\
==== Moving All axis ====
\\
\\
Now you know everything to move all axis.
\\
\\
=======================================================================================================
\\
\\
Exercise. Move gantry along all axis.(X,Y,Z axis)
\\
\\
Here is an {{https://drive.google.com/file/d/1NNSCatAnJ9nLW2lZw1tIvLvpOPigcs57/view?usp=sharing|answer}}
\\
\\
=======================================================================================================
\\
\\
\\
\\
==== How to go back home ====
\\
\\
After moving it, gantry need to go back to home position for next use.
\\
If we know current position of gantry, going back to home position is easy.
\\
\\
=======================================================================================================
\\
\\
Exercise. Lets make it go back to home location after we move gantry.
\\
\\
Here is an {{https://drive.google.com/file/d/1lJ9_IZ4xCaNBoBDNQAfajQw0aeIAMgSX/view?usp=sharing|answer}}
\\
\\
=======================================================================================================
\\
\\
\\
\\
==== Accuracy ====
\\
\\
Now you are ready to check the accuracy of your code.
\\
{{ mgkim:ds_21.jpg?600 |}}
\\
There is a plate where the 10cm by 10cm grid is drawn.
\\
Try setting the origin at any intersecting point and run your code at 10cm resolution.
\\
If it is accurate enough, try narrowing down the resolution at 5cm.
\\
If not, find out the problems by yourself.
\\
The reason would be poor measurement or hardware out of work.
\\
Checking the tension of the threads would help you finding problems.
\\
\\
==== Final Words ====
For questions, clarifications, etc, Email: m.geon.kim@gmail.com