You just got yourself a new Cube Servo, the G15, so it’s time to get started! I will guide you step by step, from how to connect and remove the joints until progamming Cytron’s G15 shield to control your G15. FIrst of all, you will need to have these:
- Cube Servo, G15
- Cytron G15 Shield
- Arduino Uno ( You can also use other types of Arduino main board if you have one)
- DC Adapter (You can choose to use batteries instead if you have one, voltage must be between 7 to 12V)
- U Joint for G15 (Optional)
Removing the Joints
The connection of G15 is unique where no screw is involved. The joining is all done with a sliding action with slots on the 5 faces of G15. The slots are in different orientation so that you can slide the joints from different directions. The G15 is specially designed in a cube form with the shaft at the center, combined with the sliding joint, enables you to assemble and dismantle your robot in a matter of minutes. In contrast with using screws, this would normally take hours just to build a single robot.
When you receive your G15, the External Joint and Inter Connect should be connected to it. So, the first thing to do would be to remove these two joints. You can skip this step if you plan to test the motor first and remove the joints later. To remove the External Joint connected to the shaft, use a long and flat object(we are using a screw driver as example) to press on the lock of the joint.
You can see clearly in this picture the location of the lock for the External Joint.
While pressing, push the External Joint in the direction against the lock.
Keep pushing until the joint comes off.
For the External Joint connected to the Inter Connect, Just use your finger(provided that your finger is the right size) to press on the semi-transparent lock on G15 and push on the External Joint until it comes out
You can see clearly in this picture the location of the lock for G15.
Using Cytron G15 Shield
The G15 shield converts UART duplex communication to half-duplex single line communication compatible for G15 Cube Servo. This basically means that the shield acts as a driver or converter for us to communicate easily with G15. For complete details on Cytron G15 Shield, you can refer to the user manual. We will be using Arduino Uno as an example, you can always choose other Arduino or compatible main board. For more info on using Arduino Uno, you can refer to Getting Started with Arduino Uno.
- First, download G15 Shield Arduino libraries and example code at the product page.
- Unzip the file and copy it over to your Arduino library folder.
- Plug your G15 to either one of the two ports on G15 shield.
- Connect the DC adapter or batteries to your main board. This is required as the power from USB is not sufficient.
- Finally connect your board to your PC or Laptop.
Setting the ID
Before you can proceed, you will have to set a unique ID for each G15 if you have more than one G15. The default ID from Cytron is ‘1’. You can set the ID as any number in between 0 – 253. The ID is a identification number assigned to each G15. This ID is used to identify each G15 on the communication network. Just like us, we have names to identify who we are, and G15 has ID to identify them. It’s as simple as that. If two of the G15 has the same ID, a communication collision may occur which result in error. If you are only using one G15, then you can skip this step. If you are using two G15, you do not have to change both the ID, changing either one will do, as long as they don’t have the same ID.
Start Arduino IDE and open the G15 example under Examples > G15 > SetID. Please make sure that you are using the latest Arduino IDE (version 1.0.2 and above) because Arduino has modified their standard libraries which affects G15 libraries.
Lets take a look at the code.
<pre class=”EnlighterJSRAW” data-enlighter-language=”cpp”> #include <G15.h> </pre>
This is to include the G15 library function.
This means that we are defining G15 with ID ‘1’ as servo1. In other words, servo1 represents G15 with ID ‘1’ in the following codes. You will have to know the existing ID of the G15 before you can change it. Remember that the default ID is ‘1’. The 3 in this code means that the control pin on G15 shield is set to D3 as shown in the picture below. If you change the jumper here to D9, the 3 should be replaced with 9 instead. If not, just ignore it and follow the sample code.
This is the setting initialization as shown in the comments. You can just skip this and follow the sample code.
This is the code to change the ID. This means that we are changing the ID of servo1 to ‘2’. You can always set it to any number in between 0 – 253, just that in this sample, we are changing it to ‘2’.
Upload the code, this should change the ID of your G15 to ‘2’. Now, you can label your G15 with the corresponding ID.
Start Arduino IDE and open the G15 example under Examples > G15 > Positioning.
This is to include the G15 library function.
G15 servo1(1,3); AX12 servo2(3,2);
This is defining the G15 as explained when we set the ID. You can add in this code with modification for additional motors, as shown below. For the second line, just ignore it as that is for Dynamixel AX12 which we are not using.
G15 servo1(1,3); G15 servo3(2,3); G15 servo4(3,3);
servo1 is for G15 ID ‘1’, servo3 is for G15 ID ‘2’ and servo4 is or G15 ID ‘3’. You don’t have to follow the example using ‘servo’ as definition, you can use whatever name you prefer, such as cube1, handX, etc.
G15ShieldInit(19200); servo1.init(); servo2.init();
This is the setting initialization as explained when we set the ID. You can just skip this and follow the sample code.
servo1.SetPos(0,iWRITE_DATA); delay(800); servo1.SetPos(170,iWRITE_DATA); delay(800); servo1.SetPos(853,iWRITE_DATA); delay(800);
This is the part where we make it move. You will notice that the only difference in the three lines is the value inside the bracket, that’s the position value. Change the value here to move the shaft to the position that you want. The value is between 0 to 1087. But how should I know what is the value for the position that i want? There is two triangle markers on the G15, one embossed on the body(we shall name it body mark) and one on the output shaft (we shall name it yellow mark). The yellow mark shows which direction the shaft is pointing and the body mark acts as a guiding point. When the two markers meet, the position value is 544 which is at 1800 as shown below.
When the position value is set to 0, the yellow marker should move to 0⁰ as shown below.
The resolution of each step is 0.33⁰. This means that if you increase the position value by 1, the shaft will turn 0.33⁰.
You can also calculate the position value by using the following formula:
Upload the code and you should be able to see the G15 in action!
Now, try to change the code to these value and see the changes:
servo1.SetPos(0,iWRITE_DATA); delay(800); servo1.SetPos(1087,iWRITE_DATA); delay(1600); servo1.SetPos(544,iWRITE_DATA); delay(800);
I have also changed the delay to 1600 as it would take a longer time for it to move from 0 to 1087. If the delay is too short, it will not reach the desired position. Play around with other position value and delay value, then observe the output. You will get the hang of it in no time.
There is one more interesting function that you may like to test, turning on the LED. Copy the code as below into your code to turn on and turn off your LED.
servo1.SetLED(1, iWRITE_DATA); //turn on LED delay(800); servo1.SetLED(0, iWRITE_DATA); //turn off LED delay(800);
There is lots more interesting feature of G15 that you can test such as controlling the speed, the direction, changing mode and limiting the rotation angle.
Connecting the Joints
By now, your G15 should be moving. It’s time to make some movement with the joints.
First of all, there is one little important thing that you should take note before you start connecting your G15. Do you still remember the yellow mark on the output shaft? Not only is it used to determine the position, it is also used as a indication of the sliding direction. the joints should slide in from the direction of the yellow mark. This only applies for the output shaft of G15, you can slide in any direction for the rest.
Let’s move on to the other joints, I will just show you a few examples. For more details on the joints, you can always refer to G15’s User Manual.
External Joint and Inter Connect
The External Joint is used to mount your G15 to any surface or object that does not have the sliding slots. The inter Connect acts as a block to connect 2 slots together.
I’m using a scraped PCB as my base. I drilled 3 holes with 3mm diameter each and screwed the External Joint to it. The picture below shows the steps.
Connect the Inter Connect
Connect another External Joint
Or you can connect a U Joint
U Joint and Rotatable Connect
The U Joint comes together with the Rotatable Connect. You must first connect the Rotatable Connect at the bottom(assuming the output shaft is the top) of G15 before you can connect the U Joint. Here’s how:
To remove the joint, its almost similar with removing the External Joint, press on the lock using a long and flat object. While pressing, slowly push the U Joint in the direction against the lock. You will have to do it for both side to release the locks and remove the U Joint.
That’s all from me for now. Stay tune and follow me as i will be doing a project using the G15. Do share your photos of your G15 and also your experience with us and all the robotic fans out there. We would love to be part of the excitement! You are more than welcome to share it at our facebook or forum. Last but not least, let me entice you with a glimpse of my coming project 😀
This guide should be able to get you started. If you need more details and info, you can refer to the following links